From 0dee2bf8f78a13a0c556cc33df75b74bbb9dac00 Mon Sep 17 00:00:00 2001 From: Ivascu Madalin Date: Tue, 28 Nov 2023 16:02:30 +0200 Subject: [PATCH 1/2] BP-3179 Add support for "External Payments" --- example/transactions/externalPayment.php | 19 ++++++ .../ExternalPayment/ExternalPayment.php | 30 ++++++++ src/PaymentMethods/PaymentMethodFactory.php | 68 ++++++++++--------- .../Buckaroo/Payments/ExternalPaymentTest.php | 56 +++++++++++++++ 4 files changed, 140 insertions(+), 33 deletions(-) create mode 100644 example/transactions/externalPayment.php create mode 100644 src/PaymentMethods/ExternalPayment/ExternalPayment.php create mode 100644 tests/Buckaroo/Payments/ExternalPaymentTest.php diff --git a/example/transactions/externalPayment.php b/example/transactions/externalPayment.php new file mode 100644 index 0000000..85a881f --- /dev/null +++ b/example/transactions/externalPayment.php @@ -0,0 +1,19 @@ +method('externalPayment')->pay([ + 'invoice' => uniqid(), + 'amountDebit' => 10.10, + 'channel' => 'BackOffice' +]); + +$buckaroo->method('externalPayment')->refund([ + 'amountCredit' => 10, + 'invoice' => 'testinvoice 123', + 'originalTransactionKey' => $response->getTransactionKey(), +]); \ No newline at end of file diff --git a/src/PaymentMethods/ExternalPayment/ExternalPayment.php b/src/PaymentMethods/ExternalPayment/ExternalPayment.php new file mode 100644 index 0000000..f10e6d0 --- /dev/null +++ b/src/PaymentMethods/ExternalPayment/ExternalPayment.php @@ -0,0 +1,30 @@ + ['payperemail'], PaymentInitiation::class => ['paymentinitiation','paybybank'], EPS::class => ['eps'], + ExternalPayment::class => ['externalpayment'], Emandates::class => ['emandates'], Sofort::class => ['sofort', 'sofortueberweisung'], Tinka::class => ['tinka'], diff --git a/tests/Buckaroo/Payments/ExternalPaymentTest.php b/tests/Buckaroo/Payments/ExternalPaymentTest.php new file mode 100644 index 0000000..f2994fa --- /dev/null +++ b/tests/Buckaroo/Payments/ExternalPaymentTest.php @@ -0,0 +1,56 @@ +buckaroo->method('externalPayment')->pay([ + 'invoice' => uniqid(), + 'amountDebit' => 11.10, + 'channel' => 'BACKOFFICE' + ]); + + $this->assertTrue($response->isSuccess()); + } + + /** + * @test + */ + public function it_creates_a_external_payment_refund() + { + $response = $this->buckaroo->method('externalPayment')->refund([ + 'amountCredit' => 10, + 'invoice' => 'testinvoice 123', + 'description' => 'refund', + 'originalTransactionKey' => '2D04704995B74D679AACC59F87XXXXXX', + ]); + + $this->assertTrue($response->isFailed()); + } +} From 32688662aef282d2bb29a8b569a103f41359bd43 Mon Sep 17 00:00:00 2001 From: Ivascu Madalin Date: Tue, 5 Dec 2023 15:46:49 +0200 Subject: [PATCH 2/2] rename test function --- tests/Buckaroo/Payments/ExternalPaymentTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Buckaroo/Payments/ExternalPaymentTest.php b/tests/Buckaroo/Payments/ExternalPaymentTest.php index f2994fa..5b0338c 100644 --- a/tests/Buckaroo/Payments/ExternalPaymentTest.php +++ b/tests/Buckaroo/Payments/ExternalPaymentTest.php @@ -42,7 +42,7 @@ public function it_creates_a_external_payment() /** * @test */ - public function it_creates_a_external_payment_refund() + public function it_creates_a_external_refund() { $response = $this->buckaroo->method('externalPayment')->refund([ 'amountCredit' => 10,