From 1abbd66626ef0b2a336a534a7c7b1e619026d69e Mon Sep 17 00:00:00 2001 From: Silviana Ghita <> Date: Tue, 5 Dec 2023 17:18:35 +0200 Subject: [PATCH 1/3] Added new parameters to legacy IDEAL payin --- MangoPay/PayInPaymentDetailsCard.php | 10 ++++++++ tests/Cases/Base.php | 35 ++++++++++++++++++++++++++++ tests/Cases/PayInsTest.php | 15 ++++++++++++ 3 files changed, 60 insertions(+) diff --git a/MangoPay/PayInPaymentDetailsCard.php b/MangoPay/PayInPaymentDetailsCard.php index 9b77159b..ecce8f01 100644 --- a/MangoPay/PayInPaymentDetailsCard.php +++ b/MangoPay/PayInPaymentDetailsCard.php @@ -47,4 +47,14 @@ class PayInPaymentDetailsCard extends Libraries\Dto implements PayInPaymentDetai * @var string */ public $Reference; + + /** + * @var string + */ + public $Bic; + + /** + * @var string + */ + public $BankName; } diff --git a/tests/Cases/Base.php b/tests/Cases/Base.php index 057e9047..3cc68d5a 100644 --- a/tests/Cases/Base.php +++ b/tests/Cases/Base.php @@ -968,6 +968,41 @@ protected function getNewPayInKlarnaWeb($userId = null) return $this->_api->PayIns->Create($payIn); } + protected function getLegacyPayInIdealWeb($userId = null) + { + $wallet = $this->getJohnsWalletWithMoney(); + if (is_null($userId)) { + $user = $this->getJohn(); + $userId = $user->Id; + } + + $payIn = new \MangoPay\PayIn(); + $payIn->PaymentType = "CARD"; + $payIn->AuthorId = $userId; + $payIn->CreditedWalletId = $wallet->Id; + $payIn->Fees = new \MangoPay\Money(); + $payIn->Fees->Amount = 10; + $payIn->Fees->Currency = 'EUR'; + $payIn->DebitedFunds = new \MangoPay\Money(); + $payIn->DebitedFunds->Amount = 1000; + $payIn->DebitedFunds->Currency = 'EUR'; + + $payIn->PaymentDetails = new \MangoPay\PayInPaymentDetailsCard(); + $payIn->PaymentDetails->Bic = 'REVOLT21'; + $payIn->PaymentDetails->CardType = 'IDEAL'; + $payIn->PaymentDetails->StatementDescriptor = 'test'; + + $payIn->ExecutionType = \MangoPay\PayInExecutionType::Web; + // execution type as WEB + $payIn->ExecutionDetails = new \MangoPay\PayInExecutionDetailsWeb(); + $payIn->ExecutionDetails->ReturnURL = "http://www.my-site.com/returnURL?transactionId=wt_71a08458-b0cc-468d-98f7-1302591fc238"; + $payIn->ExecutionDetails->Culture = "EN"; + + $payIn->Tag = "Ideal tag"; + + return $this->_api->PayIns->Create($payIn); + } + protected function getNewPayInIdealWeb($userId = null) { $wallet = $this->getJohnsWalletWithMoney(); diff --git a/tests/Cases/PayInsTest.php b/tests/Cases/PayInsTest.php index 9e3e01f0..b7932eae 100644 --- a/tests/Cases/PayInsTest.php +++ b/tests/Cases/PayInsTest.php @@ -14,6 +14,7 @@ use MangoPay\PayInExecutionType; use MangoPay\PayInPaymentDetails; use MangoPay\PayInPaymentDetailsBankWire; +use MangoPay\PayInPaymentDetailsCard; use MangoPay\PayInPaymentType; use MangoPay\PayInRecurringRegistrationUpdate; use MangoPay\PayInStatus; @@ -832,6 +833,20 @@ public function test_PayIns_Create_KlarnaWeb() $this->assertEquals($payIn->Id, $fetchedPayIn->Id); } + public function test_PayIns_Create_Legacy_IdealWeb() + { + $payIn = $this->getLegacyPayInIdealWeb(); + + $this->assertNotNull($payIn->Id > 0); + $this->assertEquals(\MangoPay\PayInPaymentType::Card, $payIn->PaymentType); + $this->assertInstanceOf('\MangoPay\PayInPaymentDetailsCard', $payIn->PaymentDetails); + $this->assertEquals(\MangoPay\PayInExecutionType::Web, $payIn->ExecutionType); + $this->assertInstanceOf('\MangoPay\PayInExecutionDetailsWeb', $payIn->ExecutionDetails); + $this->assertEquals(PayInStatus::Created, $payIn->Status); + $this->assertEquals('PAYIN', $payIn->Type); + $this->assertEquals('REGULAR', $payIn->Nature); + } + public function test_PayIns_Create_IdealWeb() { $payIn = $this->getNewPayInIdealWeb(); From 83a784eeda4ea8d9c3edf33a06e3e34840bba5b0 Mon Sep 17 00:00:00 2001 From: Iulian Masar Date: Wed, 6 Dec 2023 15:46:07 +0200 Subject: [PATCH 2/3] updated test --- tests/Cases/PayInsTest.php | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/Cases/PayInsTest.php b/tests/Cases/PayInsTest.php index b7932eae..7d34c7e6 100644 --- a/tests/Cases/PayInsTest.php +++ b/tests/Cases/PayInsTest.php @@ -845,6 +845,7 @@ public function test_PayIns_Create_Legacy_IdealWeb() $this->assertEquals(PayInStatus::Created, $payIn->Status); $this->assertEquals('PAYIN', $payIn->Type); $this->assertEquals('REGULAR', $payIn->Nature); + $this->assertNotNull($payIn->PaymentDetails->BankName); } public function test_PayIns_Create_IdealWeb() From 4f295868fe0ceaa18fefe68544b8323a1eeece28 Mon Sep 17 00:00:00 2001 From: Iulian Masar Date: Wed, 6 Dec 2023 16:20:04 +0200 Subject: [PATCH 3/3] run linter --- MangoPay/ApiInstantConversion.php | 15 +++++++++------ MangoPay/ConversionRate.php | 2 +- MangoPay/InstantConversion.php | 2 +- MangoPay/PayInPaymentDetailsGiropay.php | 2 +- MangoPay/PayInPaymentDetailsIdeal.php | 2 +- tests/Cases/InstantConversionTest.php | 5 +++-- 6 files changed, 16 insertions(+), 12 deletions(-) diff --git a/MangoPay/ApiInstantConversion.php b/MangoPay/ApiInstantConversion.php index 4bef5b6b..b0263635 100644 --- a/MangoPay/ApiInstantConversion.php +++ b/MangoPay/ApiInstantConversion.php @@ -15,16 +15,18 @@ class ApiInstantConversion extends Libraries\ApiBase * @param string $creditedCurrency The buy currency – the currency of the wallet to be credited. * @return \MangoPay\ConversionRate object returned from API */ - public function GetConversionRate($debitedCurrency, $creditedCurrency){ - return $this->GetObject('get_conversion_rate', '\MangoPay\ConversionRate', $debitedCurrency, $creditedCurrency); - } + public function GetConversionRate($debitedCurrency, $creditedCurrency) + { + return $this->GetObject('get_conversion_rate', '\MangoPay\ConversionRate', $debitedCurrency, $creditedCurrency); + } /** * This endpoint allows the platform to move funds between two * wallets of different currencies instantaneously. * @return \MangoPay\InstantConversion object returned from API */ - public function CreateInstantConversion($instantConversion){ + public function CreateInstantConversion($instantConversion) + { return $this->CreateObject('create_instant_conversion', $instantConversion, '\MangoPay\InstantConversion'); } @@ -34,7 +36,8 @@ public function CreateInstantConversion($instantConversion){ * @param string $id The unique identifier of the conversion. * @return \MangoPay\InstantConversion object returned from API */ - public function GetInstantConversion($id){ + public function GetInstantConversion($id) + { return $this->GetObject('get_instant_conversion', '\MangoPay\InstantConversion', $id); } -} \ No newline at end of file +} diff --git a/MangoPay/ConversionRate.php b/MangoPay/ConversionRate.php index f667d1db..4963a74a 100644 --- a/MangoPay/ConversionRate.php +++ b/MangoPay/ConversionRate.php @@ -31,4 +31,4 @@ class ConversionRate extends Libraries\EntityBase * @var string */ public $MarketRate; -} \ No newline at end of file +} diff --git a/MangoPay/InstantConversion.php b/MangoPay/InstantConversion.php index 4b07e447..781b78c2 100644 --- a/MangoPay/InstantConversion.php +++ b/MangoPay/InstantConversion.php @@ -83,4 +83,4 @@ class InstantConversion extends Libraries\EntityBase * @var int */ public $ExecutionDate; -} \ No newline at end of file +} diff --git a/MangoPay/PayInPaymentDetailsGiropay.php b/MangoPay/PayInPaymentDetailsGiropay.php index 97ec8878..22faccf1 100644 --- a/MangoPay/PayInPaymentDetailsGiropay.php +++ b/MangoPay/PayInPaymentDetailsGiropay.php @@ -13,4 +13,4 @@ class PayInPaymentDetailsGiropay extends Libraries\Dto implements PayInPaymentDe * @var string */ public $StatementDescriptor; -} \ No newline at end of file +} diff --git a/MangoPay/PayInPaymentDetailsIdeal.php b/MangoPay/PayInPaymentDetailsIdeal.php index 0712feda..aed8b494 100644 --- a/MangoPay/PayInPaymentDetailsIdeal.php +++ b/MangoPay/PayInPaymentDetailsIdeal.php @@ -26,4 +26,4 @@ class PayInPaymentDetailsIdeal extends Libraries\Dto implements PayInPaymentDeta * @var string */ public $StatementDescriptor; -} \ No newline at end of file +} diff --git a/tests/Cases/InstantConversionTest.php b/tests/Cases/InstantConversionTest.php index 8bfdfbdb..78638a95 100644 --- a/tests/Cases/InstantConversionTest.php +++ b/tests/Cases/InstantConversionTest.php @@ -40,7 +40,8 @@ public function test_getInstantConversion() $this->assertSame(TransactionType::Conversion, $returnedInstantConversion->Type); } - private function createInstantConversion() { + private function createInstantConversion() + { $john = $this->getJohn(); $creditedWallet = new \MangoPay\Wallet(); $creditedWallet->Owners = [$john->Id]; @@ -69,4 +70,4 @@ private function createInstantConversion() { return $this->_api->InstantConversion->CreateInstantConversion($instantConversion); } -} \ No newline at end of file +}