diff --git a/composer.json b/composer.json index 2e22e348..0d2a328d 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "buckaroo/sdk", "description": "Buckaroo payment SDK", "license": "MIT", - "version": "1.23.2", + "version": "1.24.0", "type": "library", "require": { "php": ">=7.4|^8.0", diff --git a/example/transactions/banking.php b/example/transactions/banking.php new file mode 100644 index 00000000..91d821b2 --- /dev/null +++ b/example/transactions/banking.php @@ -0,0 +1,30 @@ +method('banking')->paymentOrder([ + 'amountCredit' => 0.1, + 'invoice' => uniqid(), + 'description' => 'Banking PaymentOrder Test', + 'accountHolderName' => 'John Smith', + 'iban' => 'NL44RABO0123456789', + 'processingDate' => '12/12/2026', + 'bic' => 'PAYMINBBXXX', + 'purpose' => 'Testing', + 'structuredIssuerType' => 'ISO', + 'structuredReference' => 'RF18539007547034', +]); + +// InstantPaymentOrder +$instantResponse = $buckaroo->method('banking')->instantPaymentOrder([ + 'amountCredit' => 0.1, + 'invoice' => uniqid(), + 'description' => 'Banking Instant PaymentOrder Test', + 'accountHolderName' => 'John Smith', + 'iban' => 'NL44RABO0123456789', +]); diff --git a/src/PaymentMethods/Banking/Banking.php b/src/PaymentMethods/Banking/Banking.php new file mode 100644 index 00000000..9bfcd1ec --- /dev/null +++ b/src/PaymentMethods/Banking/Banking.php @@ -0,0 +1,67 @@ +payload); + + $this->request->setPayload($paymentOrderPayload); + + $this->setServiceList('PaymentOrder', $model ?? new PaymentOrderAdapter(new PaymentOrder($this->payload))); + + return $this->postRequest(); + } + + /** + * @return TransactionResponse + */ + public function instantPaymentOrder(?Model $model = null): TransactionResponse + { + $paymentOrderPayload = new PaymentOrderPayload($this->payload); + + $this->request->setPayload($paymentOrderPayload); + + $this->setServiceList('InstantPaymentOrder', $model ?? new PaymentOrderAdapter(new InstantPaymentOrder($this->payload))); + + return $this->postRequest(); + } +} diff --git a/src/PaymentMethods/Banking/Models/InstantPaymentOrder.php b/src/PaymentMethods/Banking/Models/InstantPaymentOrder.php new file mode 100644 index 00000000..bf99a345 --- /dev/null +++ b/src/PaymentMethods/Banking/Models/InstantPaymentOrder.php @@ -0,0 +1,36 @@ + 'AccountHolderName', + 'iban' => 'IBAN', + 'processingDate' => 'ProcessingDate', + 'bic' => 'BIC', + 'purpose' => 'Purpose', + 'structuredIssuerType' => 'StructuredIssuerType', + 'structuredReference' => 'StructuredReference', + ]; +} diff --git a/src/PaymentMethods/PaymentMethodFactory.php b/src/PaymentMethods/PaymentMethodFactory.php index 859a73c0..6f32878f 100644 --- a/src/PaymentMethods/PaymentMethodFactory.php +++ b/src/PaymentMethods/PaymentMethodFactory.php @@ -26,6 +26,7 @@ use Buckaroo\PaymentMethods\Alipay\Alipay; use Buckaroo\PaymentMethods\ApplePay\ApplePay; use Buckaroo\PaymentMethods\Bancontact\Bancontact; +use Buckaroo\PaymentMethods\Banking\Banking; use Buckaroo\PaymentMethods\BankTransfer\BankTransfer; use Buckaroo\PaymentMethods\Belfius\Belfius; use Buckaroo\PaymentMethods\Billink\Billink; @@ -84,6 +85,7 @@ class PaymentMethodFactory Afterpay::class => ['afterpay'], AfterpayDigiAccept::class => ['afterpaydigiaccept'], Bancontact::class => ['bancontact', 'bancontactmrcash'], + Banking::class => ['banking'], Bizum::class => ['bizum'], Billink::class => ['billink'], Blik::class => ['blik'], diff --git a/tests/Feature/PaymentMethods/BankingTest.php b/tests/Feature/PaymentMethods/BankingTest.php new file mode 100644 index 00000000..0000fdda --- /dev/null +++ b/tests/Feature/PaymentMethods/BankingTest.php @@ -0,0 +1,196 @@ +mockBuckaroo->mockTransportRequests([ + BuckarooMockRequest::json('POST', '*/json/Transaction*', [ + 'Key' => $transactionKey, + 'Status' => [ + 'Code' => ['Code' => 794, 'Description' => 'Pending approval'], + 'SubCode' => ['Code' => 'C000', 'Description' => 'Pending approval'], + 'DateTime' => date('Y-m-d\TH:i:s'), + ], + 'RequiredAction' => null, + 'Services' => [ + [ + 'Name' => 'Banking', + 'Action' => null, + 'Parameters' => [ + ['Name' => 'Processed', 'Value' => 'Classic'], + ], + ], + ], + 'AmountCredit' => 150.00, + 'IsTest' => true, + 'CustomerName' => 'John Doe', + ]), + ]); + + $response = $this->buckaroo->method('banking')->paymentOrder([ + 'amountCredit' => 150.00, + 'invoice' => 'INV-BANKING-001', + 'description' => 'Banking PaymentOrder Test', + 'accountHolderName' => 'John Doe', + 'iban' => 'NL91ABNA0417164300', + 'processingDate' => '12/12/2026', + 'bic' => 'ABNANL2A', + 'purpose' => 'Testing', + ]); + + $this->assertTrue($response->isPendingApproval()); + $this->assertEquals(150.00, $response->getAmountCredit()); + $this->assertSame($transactionKey, $response->getTransactionKey()); + $this->assertTrue($response->get('IsTest')); + } + + /** @test */ + public function it_creates_a_banking_payment_order_with_minimal_parameters(): void + { + $transactionKey = TestHelpers::generateTransactionKey(); + + $this->mockBuckaroo->mockTransportRequests([ + BuckarooMockRequest::json('POST', '*/json/Transaction*', [ + 'Key' => $transactionKey, + 'Status' => [ + 'Code' => ['Code' => 794, 'Description' => 'Pending approval'], + 'SubCode' => ['Code' => 'C000', 'Description' => 'Pending approval'], + 'DateTime' => date('Y-m-d\TH:i:s'), + ], + 'RequiredAction' => null, + 'Services' => [ + [ + 'Name' => 'Banking', + 'Action' => null, + 'Parameters' => [ + ['Name' => 'Processed', 'Value' => 'Classic'], + ], + ], + ], + 'Invoice' => 'INV-BANKING-002', + 'Currency' => 'EUR', + 'AmountCredit' => 100.00, + 'IsTest' => true, + ]), + ]); + + $response = $this->buckaroo->method('banking')->paymentOrder([ + 'amountCredit' => 100.00, + 'invoice' => 'INV-BANKING-002', + 'description' => 'Banking PaymentOrder Minimal Test', + 'accountHolderName' => 'Jane Smith', + 'iban' => 'NL44RABO0123456789', + ]); + + $this->assertTrue($response->isPendingApproval()); + $this->assertEquals(100.00, $response->getAmountCredit()); + $this->assertTrue($response->get('IsTest')); + $this->assertSame($transactionKey, $response->getTransactionKey()); + } + + /** @test */ + public function it_creates_a_banking_instant_payment_order(): void + { + $transactionKey = TestHelpers::generateTransactionKey(); + + $this->mockBuckaroo->mockTransportRequests([ + BuckarooMockRequest::json('POST', '*/json/Transaction*', [ + 'Key' => $transactionKey, + 'Status' => [ + 'Code' => ['Code' => 794, 'Description' => 'Pending approval'], + 'SubCode' => ['Code' => 'C000', 'Description' => 'Pending approval'], + 'DateTime' => date('Y-m-d\TH:i:s'), + ], + 'RequiredAction' => null, + 'Services' => [ + [ + 'Name' => 'Banking', + 'Action' => null, + 'Parameters' => [ + ['Name' => 'Processed', 'Value' => 'Instant'], + ], + ], + ], + 'Invoice' => 'INV-BANKING-INSTANT-001', + 'Currency' => 'EUR', + 'AmountCredit' => 75.00, + 'IsTest' => true, + ]), + ]); + + $response = $this->buckaroo->method('banking')->instantPaymentOrder([ + 'amountCredit' => 75.00, + 'invoice' => 'INV-BANKING-INSTANT-001', + 'description' => 'Banking Instant PaymentOrder Test', + 'accountHolderName' => 'Bob Johnson', + 'iban' => 'NL91ABNA0417164300', + ]); + + $this->assertTrue($response->isPendingApproval()); + $this->assertEquals(75.00, $response->getAmountCredit()); + $this->assertTrue($response->get('IsTest')); + $this->assertSame($transactionKey, $response->getTransactionKey()); + } + + /** @test */ + public function it_creates_a_banking_payment_order_with_structured_reference(): void + { + $transactionKey = TestHelpers::generateTransactionKey(); + + $this->mockBuckaroo->mockTransportRequests([ + BuckarooMockRequest::json('POST', '*/json/Transaction*', [ + 'Key' => $transactionKey, + 'Status' => [ + 'Code' => ['Code' => 794, 'Description' => 'Pending approval'], + 'SubCode' => ['Code' => 'C000', 'Description' => 'Pending approval'], + 'DateTime' => date('Y-m-d\TH:i:s'), + ], + 'RequiredAction' => null, + 'Services' => [ + [ + 'Name' => 'Banking', + 'Action' => null, + 'Parameters' => [ + ['Name' => 'Processed', 'Value' => 'Instant'], + ], + ], + ], + 'Invoice' => 'INV-BANKING-003', + 'Currency' => 'EUR', + 'AmountCredit' => 200.00, + 'IsTest' => true, + ]), + ]); + + $response = $this->buckaroo->method('banking')->paymentOrder([ + 'amountCredit' => 200.00, + 'invoice' => 'INV-BANKING-003', + 'description' => 'Banking PaymentOrder with Structured Reference', + 'accountHolderName' => 'Alice Brown', + 'iban' => 'NL91ABNA0417164300', + 'structuredIssuerType' => 'ISO', + 'structuredReference' => 'RF18539007547034', + ]); + + $this->assertTrue($response->isPendingApproval()); + $this->assertEquals(200.00, $response->getAmountCredit()); + $this->assertTrue($response->get('IsTest')); + $this->assertSame($transactionKey, $response->getTransactionKey()); + } +}