From c0e4264d6bc7a4e994cf76324ec52809080aa4b2 Mon Sep 17 00:00:00 2001 From: Silviana Ghita Date: Mon, 2 Oct 2023 12:48:53 +0300 Subject: [PATCH] Added Ideal and Giropay mops --- MangoPay/Libraries/ApiBase.php | 2 + MangoPay/PayIn.php | 2 + MangoPay/PayInPaymentDetailsGiropay.php | 16 +++++++ MangoPay/PayInPaymentDetailsIdeal.php | 29 ++++++++++++ MangoPay/PayInPaymentType.php | 2 + tests/Cases/Base.php | 61 +++++++++++++++++++++++++ tests/Cases/PayInsTest.php | 34 ++++++++++++++ 7 files changed, 146 insertions(+) create mode 100644 MangoPay/PayInPaymentDetailsGiropay.php create mode 100644 MangoPay/PayInPaymentDetailsIdeal.php diff --git a/MangoPay/Libraries/ApiBase.php b/MangoPay/Libraries/ApiBase.php index 2a942128..022ddb10 100644 --- a/MangoPay/Libraries/ApiBase.php +++ b/MangoPay/Libraries/ApiBase.php @@ -75,6 +75,8 @@ protected function getLogger() 'payins_satispay-web_create' => ['/payins/payment-methods/satispay', RequestType::POST], 'payins_blik-web_create' => ['/payins/payment-methods/blik', RequestType::POST], 'payins_klarna-web_create' => ['/payins/payment-methods/klarna', RequestType::POST], + 'payins_ideal-web_create' => ['/payins/payment-methods/ideal', RequestType::POST], + 'payins_giropay-web_create' => ['/payins/payment-methods/giropay', RequestType::POST], 'payins_recurring_registration' => ['/recurringpayinregistrations', RequestType::POST], 'payins_recurring_registration_get' => ['/recurringpayinregistrations/%s', RequestType::GET], diff --git a/MangoPay/PayIn.php b/MangoPay/PayIn.php index e14c9d9e..a484137f 100644 --- a/MangoPay/PayIn.php +++ b/MangoPay/PayIn.php @@ -67,6 +67,8 @@ public function GetDependsObjects() PayInPaymentType::Satispay => 'MangoPay\PayInPaymentDetailsSatispay', PayInPaymentType::Blik => 'MangoPay\PayInPaymentDetailsBlik', PayInPaymentType::Klarna => 'MangoPay\PayInPaymentDetailsKlarna', + PayInPaymentType::Ideal => 'MangoPay\PayInPaymentDetailsIdeal', + PayInPaymentType::Giropay => 'MangoPay\PayInPaymentDetailsGiropay', // ...and more in future... ], diff --git a/MangoPay/PayInPaymentDetailsGiropay.php b/MangoPay/PayInPaymentDetailsGiropay.php new file mode 100644 index 00000000..97ec8878 --- /dev/null +++ b/MangoPay/PayInPaymentDetailsGiropay.php @@ -0,0 +1,16 @@ +_api->PayIns->Create($payIn); } + protected function getNewPayInIdealWeb($userId = null) + { + $wallet = $this->getJohnsWalletWithMoney(); + if (is_null($userId)) { + $user = $this->getJohn(); + $userId = $user->Id; + } + + $payIn = new \MangoPay\PayIn(); + $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\PayInPaymentDetailsIdeal(); + $payIn->PaymentDetails->Bic = 'REVOLT21'; + $payIn->PaymentDetails->StatementDescriptor = 'test'; + + // 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->Tag = "Ideal tag"; + + return $this->_api->PayIns->Create($payIn); + } + + protected function getNewPayInGiropayWeb($userId = null) + { + $wallet = $this->getJohnsWalletWithMoney(); + if (is_null($userId)) { + $user = $this->getJohn(); + $userId = $user->Id; + } + + $payIn = new \MangoPay\PayIn(); + $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\PayInPaymentDetailsGiropay(); + $payIn->PaymentDetails->StatementDescriptor = 'test'; + + // 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->Tag = "Giropay tag"; + + return $this->_api->PayIns->Create($payIn); + } + /** * Creates Pay-In Card Direct object * @return \MangoPay\PayIn diff --git a/tests/Cases/PayInsTest.php b/tests/Cases/PayInsTest.php index b34e14e5..9dcc67f4 100644 --- a/tests/Cases/PayInsTest.php +++ b/tests/Cases/PayInsTest.php @@ -815,6 +815,40 @@ public function test_PayIns_Create_KlarnaWeb() $this->assertEquals($payIn->Id, $fetchedPayIn->Id); } + public function test_PayIns_Create_IdealWeb() + { + $payIn = $this->getNewPayInIdealWeb(); + + $this->assertNotNull($payIn->Id > 0); + $this->assertEquals(\MangoPay\PayInPaymentType::Ideal, $payIn->PaymentType); + $this->assertInstanceOf('\MangoPay\PayInPaymentDetailsIdeal', $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); + + $fetchedPayIn = $this->_api->PayIns->Get($payIn->Id); + $this->assertEquals($payIn->Id, $fetchedPayIn->Id); + } + + public function test_PayIns_Create_Giropay_Web() + { + $payIn = $this->getNewPayInGiropayWeb(); + + $this->assertNotNull($payIn->Id > 0); + $this->assertEquals(\MangoPay\PayInPaymentType::Giropay, $payIn->PaymentType); + $this->assertInstanceOf('\MangoPay\PayInPaymentDetailsGiropay', $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); + + $fetchedPayIn = $this->_api->PayIns->Get($payIn->Id); + $this->assertEquals($payIn->Id, $fetchedPayIn->Id); + } + // /** // * @throws \Exception // */