From 6c34c458a2d9f906499ab764d4214b39587632d8 Mon Sep 17 00:00:00 2001 From: Mihai Moiseanu Date: Wed, 21 Feb 2024 15:36:05 +0200 Subject: [PATCH 1/6] fix typo in conversion endpoint --- MangoPay/Libraries/ApiBase.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/MangoPay/Libraries/ApiBase.php b/MangoPay/Libraries/ApiBase.php index 7b519a29..e01a7b29 100644 --- a/MangoPay/Libraries/ApiBase.php +++ b/MangoPay/Libraries/ApiBase.php @@ -225,9 +225,9 @@ protected function getLogger() 'deposits_get' => ['/deposit-preauthorizations/%s', RequestType::GET], 'deposits_cancel' => ['/deposit-preauthorizations/%s', RequestType::PUT], - 'get_conversion_rate' => ['/conversion/rate/%s/%s', RequestType::GET], - 'create_instant_conversion' => ['/instant-conversion', RequestType::POST], - 'get_instant_conversion' => ['/instant-conversion/%s', RequestType::GET] + 'get_conversion_rate' => ['/conversions/rate/%s/%s', RequestType::GET], + 'create_instant_conversion' => ['/conversions/instant-conversion', RequestType::POST], + 'get_instant_conversion' => ['/conversions/%s', RequestType::GET] ]; /** From 830e34e6c3bead492247f3bb33102eb574de6a75 Mon Sep 17 00:00:00 2001 From: Mihai Moiseanu Date: Wed, 21 Feb 2024 15:56:54 +0200 Subject: [PATCH 2/6] add fees param to instant conversion --- MangoPay/InstantConversion.php | 7 +++++++ tests/Cases/InstantConversionTest.php | 5 +++++ 2 files changed, 12 insertions(+) diff --git a/MangoPay/InstantConversion.php b/MangoPay/InstantConversion.php index 781b78c2..9848270f 100644 --- a/MangoPay/InstantConversion.php +++ b/MangoPay/InstantConversion.php @@ -83,4 +83,11 @@ class InstantConversion extends Libraries\EntityBase * @var int */ public $ExecutionDate; + + /** + * Information about the fees taken by the platform for + * this transaction (and hence transferred to the Fees Wallet). + * @var Money + */ + public $Fees; } diff --git a/tests/Cases/InstantConversionTest.php b/tests/Cases/InstantConversionTest.php index 78638a95..f59c9903 100644 --- a/tests/Cases/InstantConversionTest.php +++ b/tests/Cases/InstantConversionTest.php @@ -66,6 +66,11 @@ private function createInstantConversion() $debitedFunds->Amount = 79; $instantConversion->DebitedFunds = $debitedFunds; + $fees = new Money(); + $fees->Currency = 'EUR'; + $fees->Amount = 9; + $instantConversion->Fees = $fees; + $instantConversion->Tag = "create instant conversion"; return $this->_api->InstantConversion->CreateInstantConversion($instantConversion); From d848c30dec7d24563e6200b2f39e7aeb94b29dcf Mon Sep 17 00:00:00 2001 From: Mihai Moiseanu Date: Wed, 21 Feb 2024 17:09:54 +0200 Subject: [PATCH 3/6] rename `InstantConversion` to `Conversions` added quote endpoints --- ...stantConversion.php => ApiConversions.php} | 23 ++++++++- MangoPay/Libraries/ApiBase.php | 4 +- MangoPay/MangoPayApi.php | 6 +-- MangoPay/Quote.php | 43 ++++++++++++++++ ...ConversionTest.php => ConversionsTest.php} | 50 +++++++++++++++++-- 5 files changed, 117 insertions(+), 9 deletions(-) rename MangoPay/{ApiInstantConversion.php => ApiConversions.php} (71%) create mode 100644 MangoPay/Quote.php rename tests/Cases/{InstantConversionTest.php => ConversionsTest.php} (57%) diff --git a/MangoPay/ApiInstantConversion.php b/MangoPay/ApiConversions.php similarity index 71% rename from MangoPay/ApiInstantConversion.php rename to MangoPay/ApiConversions.php index b0263635..ee6801d4 100644 --- a/MangoPay/ApiInstantConversion.php +++ b/MangoPay/ApiConversions.php @@ -5,7 +5,7 @@ /** * Class to management MangoPay API for instant conversions */ -class ApiInstantConversion extends Libraries\ApiBase +class ApiConversions extends Libraries\ApiBase { /** * This endpoint allows the platform to get a real @@ -40,4 +40,25 @@ public function GetInstantConversion($id) { return $this->GetObject('get_instant_conversion', '\MangoPay\InstantConversion', $id); } + + /** + * This call guarantees a conversion rate to let you Create a Quoted Conversion. + * @param Quote $quote + * @return Quote + */ + public function CreateQuote($quote) + { + return $this->CreateObject('create_conversion_quote', $quote, '\MangoPay\Quote'); + } + + /** + * This endpoint allows the platform to get the details of a quote + * @param string $quoteId + * @return Quote + */ + public function GetQuote($quoteId) + { + return $this->GetObject('get_conversion_quote', '\MangoPay\Quote', $quoteId); + } + } diff --git a/MangoPay/Libraries/ApiBase.php b/MangoPay/Libraries/ApiBase.php index 7b519a29..c3f4ad37 100644 --- a/MangoPay/Libraries/ApiBase.php +++ b/MangoPay/Libraries/ApiBase.php @@ -227,7 +227,9 @@ protected function getLogger() 'get_conversion_rate' => ['/conversion/rate/%s/%s', RequestType::GET], 'create_instant_conversion' => ['/instant-conversion', RequestType::POST], - 'get_instant_conversion' => ['/instant-conversion/%s', RequestType::GET] + 'get_instant_conversion' => ['/instant-conversion/%s', RequestType::GET], + 'create_conversion_quote' => ['/conversions/quote', RequestType::POST], + 'get_conversion_quote' => ['/conversions/quote/%s', RequestType::GET] ]; /** diff --git a/MangoPay/MangoPayApi.php b/MangoPay/MangoPayApi.php index eae8122a..d2f588ec 100644 --- a/MangoPay/MangoPayApi.php +++ b/MangoPay/MangoPayApi.php @@ -199,9 +199,9 @@ class MangoPayApi /** * Provides Instant conversion API methods - * @var ApiInstantConversion + * @var ApiConversions */ - public $InstantConversion; + public $Conversions; /** * Constructor @@ -239,7 +239,7 @@ public function __construct() $this->Repudiations = new ApiRepudiations($this); $this->Regulatory = new ApiRegulatory($this); $this->Deposits = new ApiDeposits($this); - $this->InstantConversion = new ApiInstantConversion($this); + $this->Conversions = new ApiConversions($this); // Setting default NullLogger $this->logger = new NullLogger(); diff --git a/MangoPay/Quote.php b/MangoPay/Quote.php new file mode 100644 index 00000000..4293b940 --- /dev/null +++ b/MangoPay/Quote.php @@ -0,0 +1,43 @@ +_api->InstantConversion->GetConversionRate('EUR', 'GBP'); + $response = $this->_api->Conversions->GetConversionRate('EUR', 'GBP'); $this->assertNotNull($response); $this->assertNotNull($response->ClientRate); @@ -31,7 +32,7 @@ public function test_createInstantConversion() public function test_getInstantConversion() { $instantConversion = $this->createInstantConversion(); - $returnedInstantConversion = $this->_api->InstantConversion->GetInstantConversion($instantConversion->Id); + $returnedInstantConversion = $this->_api->Conversions->GetInstantConversion($instantConversion->Id); $this->assertNotNull($returnedInstantConversion); $this->assertNotNull($returnedInstantConversion->DebitedFunds->Amount); @@ -40,6 +41,27 @@ public function test_getInstantConversion() $this->assertSame(TransactionType::Conversion, $returnedInstantConversion->Type); } + public function test_createQuote(){ + $response = $this->createQuote(); + + $this->assertNotNull($response); + $this->assertNotNull($response->DebitedFunds->Amount); + $this->assertNotNull($response->CreditedFunds->Amount); + $this->assertNotNull($response->ConversionRateResponse->ClientRate); + $this->assertSame('ACTIVE', $response->Status); + } + + public function test_getQuote(){ + $quote = $this->createQuote(); + $response = $this->_api->Conversions->GetQuote($quote->Id); + + $this->assertNotNull($response); + $this->assertNotNull($response->DebitedFunds->Amount); + $this->assertNotNull($response->CreditedFunds->Amount); + $this->assertNotNull($response->ConversionRateResponse->ClientRate); + $this->assertSame('ACTIVE', $response->Status); + } + private function createInstantConversion() { $john = $this->getJohn(); @@ -68,6 +90,26 @@ private function createInstantConversion() $instantConversion->Tag = "create instant conversion"; - return $this->_api->InstantConversion->CreateInstantConversion($instantConversion); + return $this->_api->Conversions->CreateInstantConversion($instantConversion); + } + + private function createQuote() + { + + $quote = new Quote(); + $creditedFunds = new Money(); + $creditedFunds->Currency = 'USD'; + $quote->CreditedFunds = $creditedFunds; + + $debitedFunds = new Money(); + $debitedFunds->Currency = 'GBP'; + $debitedFunds->Amount = 1000; + $quote->DebitedFunds = $debitedFunds; + + $quote->Duration = 90; + $quote->Tag = "Created using the Mangopay PHP SDK"; + + return $this->_api->Conversions->CreateQuote($quote); + } } From 54a0656b9a0df5442fa72228d86c72b78f4302f2 Mon Sep 17 00:00:00 2001 From: Mihai Moiseanu Date: Wed, 21 Feb 2024 20:36:43 +0200 Subject: [PATCH 4/6] added quote conversion endpoints --- MangoPay/ApiConversions.php | 11 +++++++++ MangoPay/Libraries/ApiBase.php | 3 ++- MangoPay/QuotedConversion.php | 21 +++++++++++++++++ tests/Cases/ConversionsTest.php | 40 ++++++++++++++++++++++++++++----- 4 files changed, 68 insertions(+), 7 deletions(-) create mode 100644 MangoPay/QuotedConversion.php diff --git a/MangoPay/ApiConversions.php b/MangoPay/ApiConversions.php index ee6801d4..adca6c22 100644 --- a/MangoPay/ApiConversions.php +++ b/MangoPay/ApiConversions.php @@ -61,4 +61,15 @@ public function GetQuote($quoteId) return $this->GetObject('get_conversion_quote', '\MangoPay\Quote', $quoteId); } + /** + * This call triggers a conversion, at the rate guaranteed by its quote, of the debited funds to the credited wallet. + * + * @param QuotedConversion $quotedConversion + * @return QuotedConversion + */ + public function CreateQuotedConversion($quotedConversion) + { + return $this->CreateObject('create_quoted_conversion', $quotedConversion, '\MangoPay\QuotedConversion'); + } + } diff --git a/MangoPay/Libraries/ApiBase.php b/MangoPay/Libraries/ApiBase.php index c3f4ad37..7e489981 100644 --- a/MangoPay/Libraries/ApiBase.php +++ b/MangoPay/Libraries/ApiBase.php @@ -229,7 +229,8 @@ protected function getLogger() 'create_instant_conversion' => ['/instant-conversion', RequestType::POST], 'get_instant_conversion' => ['/instant-conversion/%s', RequestType::GET], 'create_conversion_quote' => ['/conversions/quote', RequestType::POST], - 'get_conversion_quote' => ['/conversions/quote/%s', RequestType::GET] + 'get_conversion_quote' => ['/conversions/quote/%s', RequestType::GET], + 'create_quoted_conversion' => ['/conversions/quoted-conversion', RequestType::POST], ]; /** diff --git a/MangoPay/QuotedConversion.php b/MangoPay/QuotedConversion.php new file mode 100644 index 00000000..e3e8c387 --- /dev/null +++ b/MangoPay/QuotedConversion.php @@ -0,0 +1,21 @@ +assertSame(TransactionType::Conversion, $returnedInstantConversion->Type); } - public function test_createQuote(){ + public function test_createQuote() + { $response = $this->createQuote(); $this->assertNotNull($response); @@ -51,7 +54,8 @@ public function test_createQuote(){ $this->assertSame('ACTIVE', $response->Status); } - public function test_getQuote(){ + public function test_getQuote() + { $quote = $this->createQuote(); $response = $this->_api->Conversions->GetQuote($quote->Id); @@ -62,6 +66,31 @@ public function test_getQuote(){ $this->assertSame('ACTIVE', $response->Status); } + public function test_createQuotedConversion() + { + $john = $this->getJohn(); + $creditedWallet = new \MangoPay\Wallet(); + $creditedWallet->Owners = [$john->Id]; + $creditedWallet->Currency = 'GBP'; + $creditedWallet->Description = 'WALLET IN EUR WITH MONEY'; + + $creditedWallet = $this->_api->Wallets->Create($creditedWallet); + + $debitedWallet = $this->getJohnsWalletWithMoney(); + + $quote = $this->createQuote(); + + $quotedConversion = new QuotedConversion(); + $quotedConversion->QuoteId = $quote->Id; + $quotedConversion->AuthorId = $debitedWallet->Owners[0]; + $quotedConversion->CreditedWalletId = $creditedWallet->Id; + $quotedConversion->DebitedWalletId = $debitedWallet->Id; + + $response = $this->_api->Conversions->CreateQuotedConversion($quotedConversion); + + assertNotNull($response); + } + private function createInstantConversion() { $john = $this->getJohn(); @@ -98,18 +127,17 @@ private function createQuote() $quote = new Quote(); $creditedFunds = new Money(); - $creditedFunds->Currency = 'USD'; + $creditedFunds->Currency = 'GBP'; $quote->CreditedFunds = $creditedFunds; $debitedFunds = new Money(); - $debitedFunds->Currency = 'GBP'; - $debitedFunds->Amount = 1000; + $debitedFunds->Currency = 'EUR'; + $debitedFunds->Amount = 50; $quote->DebitedFunds = $debitedFunds; $quote->Duration = 90; $quote->Tag = "Created using the Mangopay PHP SDK"; return $this->_api->Conversions->CreateQuote($quote); - } } From 4d864919f13938b3a9674a3dd1b384a3e192ea21 Mon Sep 17 00:00:00 2001 From: Mihai Moiseanu Date: Thu, 22 Feb 2024 11:01:11 +0200 Subject: [PATCH 5/6] rename `Quote` to `ConversionQuote` --- MangoPay/ApiConversions.php | 14 +++++++------- MangoPay/{Quote.php => ConversionQuote.php} | 2 +- tests/Cases/ConversionsTest.php | 18 +++++++++--------- 3 files changed, 17 insertions(+), 17 deletions(-) rename MangoPay/{Quote.php => ConversionQuote.php} (94%) diff --git a/MangoPay/ApiConversions.php b/MangoPay/ApiConversions.php index ee6801d4..ad99f0ef 100644 --- a/MangoPay/ApiConversions.php +++ b/MangoPay/ApiConversions.php @@ -43,22 +43,22 @@ public function GetInstantConversion($id) /** * This call guarantees a conversion rate to let you Create a Quoted Conversion. - * @param Quote $quote - * @return Quote + * @param ConversionQuote $quote + * @return ConversionQuote */ - public function CreateQuote($quote) + public function CreateConversionQuote($quote) { - return $this->CreateObject('create_conversion_quote', $quote, '\MangoPay\Quote'); + return $this->CreateObject('create_conversion_quote', $quote, '\MangoPay\ConversionQuote'); } /** * This endpoint allows the platform to get the details of a quote * @param string $quoteId - * @return Quote + * @return ConversionQuote */ - public function GetQuote($quoteId) + public function GetConversionQuote($quoteId) { - return $this->GetObject('get_conversion_quote', '\MangoPay\Quote', $quoteId); + return $this->GetObject('get_conversion_quote', '\MangoPay\ConversionQuote', $quoteId); } } diff --git a/MangoPay/Quote.php b/MangoPay/ConversionQuote.php similarity index 94% rename from MangoPay/Quote.php rename to MangoPay/ConversionQuote.php index 4293b940..54e0ddcf 100644 --- a/MangoPay/Quote.php +++ b/MangoPay/ConversionQuote.php @@ -4,7 +4,7 @@ use MangoPay\Libraries\EntityBase; -class Quote extends EntityBase +class ConversionQuote extends EntityBase { /** * Expiration date diff --git a/tests/Cases/ConversionsTest.php b/tests/Cases/ConversionsTest.php index d045a67c..372190d8 100644 --- a/tests/Cases/ConversionsTest.php +++ b/tests/Cases/ConversionsTest.php @@ -2,9 +2,9 @@ namespace MangoPay\Tests\Cases; +use MangoPay\ConversionQuote; use MangoPay\InstantConversion; use MangoPay\Money; -use MangoPay\Quote; use MangoPay\TransactionType; class ConversionsTest extends Base @@ -41,8 +41,8 @@ public function test_getInstantConversion() $this->assertSame(TransactionType::Conversion, $returnedInstantConversion->Type); } - public function test_createQuote(){ - $response = $this->createQuote(); + public function test_createConversionQuote(){ + $response = $this->createConversionQuote(); $this->assertNotNull($response); $this->assertNotNull($response->DebitedFunds->Amount); @@ -51,9 +51,9 @@ public function test_createQuote(){ $this->assertSame('ACTIVE', $response->Status); } - public function test_getQuote(){ - $quote = $this->createQuote(); - $response = $this->_api->Conversions->GetQuote($quote->Id); + public function test_getConversionQuote(){ + $quote = $this->createConversionQuote(); + $response = $this->_api->Conversions->GetConversionQuote($quote->Id); $this->assertNotNull($response); $this->assertNotNull($response->DebitedFunds->Amount); @@ -93,10 +93,10 @@ private function createInstantConversion() return $this->_api->Conversions->CreateInstantConversion($instantConversion); } - private function createQuote() + private function createConversionQuote() { - $quote = new Quote(); + $quote = new ConversionQuote(); $creditedFunds = new Money(); $creditedFunds->Currency = 'USD'; $quote->CreditedFunds = $creditedFunds; @@ -109,7 +109,7 @@ private function createQuote() $quote->Duration = 90; $quote->Tag = "Created using the Mangopay PHP SDK"; - return $this->_api->Conversions->CreateQuote($quote); + return $this->_api->Conversions->CreateConversionQuote($quote); } } From fe49ef57d3f0c948a2a5bbd53db1aab367c89b45 Mon Sep 17 00:00:00 2001 From: Mihai Moiseanu Date: Thu, 7 Mar 2024 15:57:52 +0200 Subject: [PATCH 6/6] code improvement on conversions --- MangoPay/ApiConversions.php | 34 +++++----- .../{InstantConversion.php => Conversion.php} | 67 ++++++++++--------- MangoPay/CreateInstantConversion.php | 53 +++++++++++++++ MangoPay/CreateQuotedConversion.php | 42 ++++++++++++ MangoPay/Libraries/ApiBase.php | 4 +- MangoPay/Libraries/Configuration.php | 2 +- MangoPay/QuotedConversion.php | 21 ------ tests/Cases/ConversionsTest.php | 33 ++++++--- 8 files changed, 175 insertions(+), 81 deletions(-) rename MangoPay/{InstantConversion.php => Conversion.php} (88%) create mode 100644 MangoPay/CreateInstantConversion.php create mode 100644 MangoPay/CreateQuotedConversion.php delete mode 100644 MangoPay/QuotedConversion.php diff --git a/MangoPay/ApiConversions.php b/MangoPay/ApiConversions.php index e556c8ba..874299ff 100644 --- a/MangoPay/ApiConversions.php +++ b/MangoPay/ApiConversions.php @@ -23,22 +23,34 @@ public function GetConversionRate($debitedCurrency, $creditedCurrency) /** * This endpoint allows the platform to move funds between two * wallets of different currencies instantaneously. - * @return \MangoPay\InstantConversion object returned from API + * @param CreateInstantConversion $instantConversion + * @return \MangoPay\Conversion object returned from API */ public function CreateInstantConversion($instantConversion) { - return $this->CreateObject('create_instant_conversion', $instantConversion, '\MangoPay\InstantConversion'); + return $this->CreateObject('create_instant_conversion', $instantConversion, '\MangoPay\Conversion'); + } + + /** + * This call triggers a conversion, at the rate guaranteed by its quote, of the debited funds to the credited wallet. + * + * @param CreateQuotedConversion $quotedConversion + * @return Conversion + */ + public function CreateQuotedConversion($quotedConversion) + { + return $this->CreateObject('create_quoted_conversion', $quotedConversion, '\MangoPay\Conversion'); } /** * This endpoint allows the platform to get * the details of a conversion which has been carried out. * @param string $id The unique identifier of the conversion. - * @return \MangoPay\InstantConversion object returned from API + * @return \MangoPay\Conversion object returned from API */ - public function GetInstantConversion($id) + public function GetConversion($id) { - return $this->GetObject('get_instant_conversion', '\MangoPay\InstantConversion', $id); + return $this->GetObject('get_conversion', '\MangoPay\Conversion', $id); } /** @@ -60,16 +72,4 @@ public function GetConversionQuote($quoteId) { return $this->GetObject('get_conversion_quote', '\MangoPay\ConversionQuote', $quoteId); } - - /** - * This call triggers a conversion, at the rate guaranteed by its quote, of the debited funds to the credited wallet. - * - * @param QuotedConversion $quotedConversion - * @return QuotedConversion - */ - public function CreateQuotedConversion($quotedConversion) - { - return $this->CreateObject('create_quoted_conversion', $quotedConversion, '\MangoPay\QuotedConversion'); - } - } diff --git a/MangoPay/InstantConversion.php b/MangoPay/Conversion.php similarity index 88% rename from MangoPay/InstantConversion.php rename to MangoPay/Conversion.php index 9848270f..cd8a6c11 100644 --- a/MangoPay/InstantConversion.php +++ b/MangoPay/Conversion.php @@ -2,8 +2,36 @@ namespace MangoPay; -class InstantConversion extends Libraries\EntityBase +class Conversion extends Libraries\EntityBase { + /** + * The unique identifier of the active quote which guaranteed the rate for the conversion. + * @var string + */ + public $QuoteId; + + /** + * The type of transaction + * @var string + * @see \MangoPay\TransactionType + */ + public $Type; + + /** + * The nature of the transaction, providing more + * information about the context in which the transaction occurred: + * @var string + * @see \MangoPay\TransactionNature + */ + public $Nature; + + /** + * The status of the transaction. + * @var string + * @see \MangoPay\TransactionStatus + */ + public $Status; + /** * The unique identifier of the user at the source of the transaction. * @var string @@ -36,32 +64,11 @@ class InstantConversion extends Libraries\EntityBase public $CreditedFunds; /** - * Real time indicative market rate of a specific currency pair - * @var ConversionRate - */ - public $ConversionRate; - - /** - * The status of the transaction. - * @var string - * @see \MangoPay\TransactionStatus - */ - public $Status; - - /** - * The type of transaction - * @var string - * @see \MangoPay\TransactionType - */ - public $Type; - - /** - * The nature of the transaction, providing more - * information about the context in which the transaction occurred: - * @var string - * @see \MangoPay\TransactionNature + * Information about the fees taken by the platform for + * this transaction (and hence transferred to the Fees Wallet). + * @var Money */ - public $Nature; + public $Fees; /** * The code indicates the result of the operation. @@ -85,9 +92,9 @@ class InstantConversion extends Libraries\EntityBase public $ExecutionDate; /** - * Information about the fees taken by the platform for - * this transaction (and hence transferred to the Fees Wallet). - * @var Money + * Real time indicative market rate of a specific currency pair + * @var ConversionRate */ - public $Fees; + public $ConversionRateResponse; + } diff --git a/MangoPay/CreateInstantConversion.php b/MangoPay/CreateInstantConversion.php new file mode 100644 index 00000000..d76929a7 --- /dev/null +++ b/MangoPay/CreateInstantConversion.php @@ -0,0 +1,53 @@ + ['/conversions/rate/%s/%s', RequestType::GET], 'create_instant_conversion' => ['/conversions/instant-conversion', RequestType::POST], - 'get_instant_conversion' => ['/conversions/%s', RequestType::GET], + 'create_quoted_conversion' => ['/conversions/quoted-conversion', RequestType::POST], + 'get_conversion' => ['/conversions/%s', RequestType::GET], 'create_conversion_quote' => ['/conversions/quote', RequestType::POST], 'get_conversion_quote' => ['/conversions/quote/%s', RequestType::GET], - 'create_quoted_conversion' => ['/conversions/quoted-conversion', RequestType::POST], ]; /** diff --git a/MangoPay/Libraries/Configuration.php b/MangoPay/Libraries/Configuration.php index c262f7df..f1a4d949 100644 --- a/MangoPay/Libraries/Configuration.php +++ b/MangoPay/Libraries/Configuration.php @@ -42,7 +42,7 @@ class Configuration * [INTERNAL USAGE ONLY] * Switch debug mode: log all request and response data */ - public $DebugMode = false; + public $DebugMode = true; /** * Set the logging class if DebugMode is enabled diff --git a/MangoPay/QuotedConversion.php b/MangoPay/QuotedConversion.php deleted file mode 100644 index e3e8c387..00000000 --- a/MangoPay/QuotedConversion.php +++ /dev/null @@ -1,21 +0,0 @@ -assertNotNull($response); $this->assertNotNull($response->DebitedFunds->Amount); $this->assertNotNull($response->CreditedFunds->Amount); + $this->assertNotNull($response->Fees); $this->assertSame('SUCCEEDED', $response->Status); $this->assertSame(TransactionType::Conversion, $response->Type); } @@ -35,11 +35,12 @@ public function test_createInstantConversion() public function test_getInstantConversion() { $instantConversion = $this->createInstantConversion(); - $returnedInstantConversion = $this->_api->Conversions->GetInstantConversion($instantConversion->Id); + $returnedInstantConversion = $this->_api->Conversions->GetConversion($instantConversion->Id); $this->assertNotNull($returnedInstantConversion); $this->assertNotNull($returnedInstantConversion->DebitedFunds->Amount); $this->assertNotNull($returnedInstantConversion->CreditedFunds->Amount); + $this->assertNotNull($returnedInstantConversion->Fees); $this->assertSame('SUCCEEDED', $returnedInstantConversion->Status); $this->assertSame(TransactionType::Conversion, $returnedInstantConversion->Type); } @@ -68,6 +69,20 @@ public function test_getConversionQuote() } public function test_createQuotedConversion() + { + $response = $this->createQuotedConversion(); + assertNotNull($response); + assertNotNull($response->QuoteId); + } + + public function test_getQuotedConversion(){ + $createdQuotedConversion = $this->createQuotedConversion(); + $response = $this->_api->Conversions->GetConversion($createdQuotedConversion->Id); + assertNotNull($response); + assertNotNull($response->QuoteId); + } + + private function createQuotedConversion() { $john = $this->getJohn(); $creditedWallet = new \MangoPay\Wallet(); @@ -79,17 +94,15 @@ public function test_createQuotedConversion() $debitedWallet = $this->getJohnsWalletWithMoney(); - $quote = $this->createQuote(); + $quote = $this->createConversionQuote(); - $quotedConversion = new QuotedConversion(); + $quotedConversion = new CreateQuotedConversion(); $quotedConversion->QuoteId = $quote->Id; $quotedConversion->AuthorId = $debitedWallet->Owners[0]; $quotedConversion->CreditedWalletId = $creditedWallet->Id; $quotedConversion->DebitedWalletId = $debitedWallet->Id; - $response = $this->_api->Conversions->CreateQuotedConversion($quotedConversion); - - assertNotNull($response); + return $this->_api->Conversions->CreateQuotedConversion($quotedConversion); } private function createInstantConversion() @@ -104,7 +117,7 @@ private function createInstantConversion() $debitedWallet = $this->getJohnsWalletWithMoney(); - $instantConversion = new InstantConversion(); + $instantConversion = new CreateInstantConversion(); $instantConversion->AuthorId = $debitedWallet->Owners[0]; $instantConversion->CreditedWalletId = $creditedWallet->Id; $instantConversion->DebitedWalletId = $debitedWallet->Id;