From 568ff22d291f6e36d0642ba9e93bd2b217511d48 Mon Sep 17 00:00:00 2001 From: Ivascu Madalin Date: Fri, 20 Oct 2023 11:11:04 +0300 Subject: [PATCH] BP-3020 Add payment method "Multibanco" (#148) * BP-3020 Add payment method "Multibanco" * fix tests --------- Co-authored-by: Ivascu Madalin --- example/transactions/multibanco.php | 21 ++++++++ src/PaymentMethods/Multibanco/Multibanco.php | 30 +++++++++++ src/PaymentMethods/PaymentMethodFactory.php | 2 + tests/Buckaroo/Payments/MultibancoTest.php | 55 ++++++++++++++++++++ 4 files changed, 108 insertions(+) create mode 100644 example/transactions/multibanco.php create mode 100644 src/PaymentMethods/Multibanco/Multibanco.php create mode 100644 tests/Buckaroo/Payments/MultibancoTest.php diff --git a/example/transactions/multibanco.php b/example/transactions/multibanco.php new file mode 100644 index 0000000..74d8ce3 --- /dev/null +++ b/example/transactions/multibanco.php @@ -0,0 +1,21 @@ +method('multibanco')->pay([ + 'invoice' => uniqid(), + 'amountDebit' => 10.10, +]); + +//Refund +$response = $buckaroo->method('multibanco')->refund([ + 'invoice' => '', //Set invoice number of the transaction to refund + 'originalTransactionKey' => '', //Set transaction key of the transaction to refund + 'amountCredit' => 10.10, +]); diff --git a/src/PaymentMethods/Multibanco/Multibanco.php b/src/PaymentMethods/Multibanco/Multibanco.php new file mode 100644 index 0000000..5444842 --- /dev/null +++ b/src/PaymentMethods/Multibanco/Multibanco.php @@ -0,0 +1,30 @@ + ['in3old'], KlarnaPay::class => ['klarna', 'klarnain'], KlarnaKP::class => ['klarnakp'], + Multibanco::class => ['multibanco'], MBWay::class => ['mbway'], Surepay::class => ['surepay'], Subscriptions::class => ['subscriptions'], diff --git a/tests/Buckaroo/Payments/MultibancoTest.php b/tests/Buckaroo/Payments/MultibancoTest.php new file mode 100644 index 0000000..b8d4c75 --- /dev/null +++ b/tests/Buckaroo/Payments/MultibancoTest.php @@ -0,0 +1,55 @@ +buckaroo->method('multibanco')->pay([ + 'invoice' => uniqid(), + 'amountDebit' => 10.10, + ]); + + $this->assertTrue($response->isPendingProcessing()); + } + + /** + * @test + */ + public function it_creates_a_multibanco_refund() + { + $response = $this->buckaroo->method('multibanco')->refund([ + 'amountCredit' => 10, + 'invoice' => 'testinvoice 123', + 'description' => 'refund', + 'originalTransactionKey' => '2D04704995B74D679AACC59F87XXXXXX', + ]); + + $this->assertTrue($response->isFailed()); + } +}