From 46038bcd6de6c0f9c8ac9439b9b0569dac63eaa0 Mon Sep 17 00:00:00 2001 From: Shu Chen Date: Thu, 2 May 2024 15:25:56 +0800 Subject: [PATCH 1/2] Adding blik payment --- src/PaymentMethods/Blik/Blik.php | 87 ++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 src/PaymentMethods/Blik/Blik.php diff --git a/src/PaymentMethods/Blik/Blik.php b/src/PaymentMethods/Blik/Blik.php new file mode 100644 index 0000000..0a374f0 --- /dev/null +++ b/src/PaymentMethods/Blik/Blik.php @@ -0,0 +1,87 @@ +payload)); + } + + /** + * @return TransactionResponse + */ + public function authorize(): TransactionResponse + { + $pay = new Pay($this->payload); + + $this->setPayPayload(); + + $this->setServiceList('Authorize', $pay); + + return $this->postRequest(); + } + + /** + * @return TransactionResponse + */ + public function capture(): TransactionResponse + { + $capture = new Capture($this->payload); + + $this->setPayPayload(); + + $this->setServiceList('Capture', $capture); + + return $this->postRequest(); + } + + /** + * @return TransactionResponse + */ + public function cancelAuthorize(): TransactionResponse + { + $pay = new Refund($this->payload); + + $this->setPayPayload(); + + $this->setServiceList('CancelAuthorize', $pay); + + return $this->postRequest(); + } +} From 741dcafd730406bc30e7c67bcbc2bf54dc296dca Mon Sep 17 00:00:00 2001 From: Shu Chen Date: Fri, 3 May 2024 13:16:18 +0800 Subject: [PATCH 2/2] Adding Blik payment --- example/transactions/blik.php | 17 ++++++++ src/PaymentMethods/Blik/Blik.php | 48 +-------------------- src/PaymentMethods/Blik/Models/Pay.php | 28 ++++++++++++ src/PaymentMethods/PaymentMethodFactory.php | 2 + tests/Buckaroo/Payments/BlikTest.php | 42 ++++++++++++++++++ tests/Buckaroo/Payments/IdealTest.php | 13 ------ 6 files changed, 91 insertions(+), 59 deletions(-) create mode 100644 example/transactions/blik.php create mode 100644 src/PaymentMethods/Blik/Models/Pay.php create mode 100644 tests/Buckaroo/Payments/BlikTest.php diff --git a/example/transactions/blik.php b/example/transactions/blik.php new file mode 100644 index 0000000..d0b81a1 --- /dev/null +++ b/example/transactions/blik.php @@ -0,0 +1,17 @@ +method('blik')->pay([ + 'currency' => 'PLN', + 'amountDebit' => 10.00, + 'invoice' => 'Blik Test Plugins Example', + 'description' => 'Blik Test Plugins Example', + 'email' => 'test@buckar00.nl' +]); \ No newline at end of file diff --git a/src/PaymentMethods/Blik/Blik.php b/src/PaymentMethods/Blik/Blik.php index 0a374f0..878b4eb 100644 --- a/src/PaymentMethods/Blik/Blik.php +++ b/src/PaymentMethods/Blik/Blik.php @@ -21,9 +21,7 @@ namespace Buckaroo\PaymentMethods\Blik; use Buckaroo\Models\Model; -use Buckaroo\PaymentMethods\Billink\Models\Capture; -use Buckaroo\PaymentMethods\Billink\Models\Pay; -use Buckaroo\PaymentMethods\CreditClick\Models\Refund; +use Buckaroo\PaymentMethods\Blik\Models\Pay; use Buckaroo\PaymentMethods\PayablePaymentMethod; use Buckaroo\Transaction\Response\TransactionResponse; @@ -32,7 +30,7 @@ class Blik extends PayablePaymentMethod /** * @var string */ - protected string $paymentName = 'Billink'; + protected string $paymentName = 'Blik'; /** * @param Model|null $model @@ -42,46 +40,4 @@ public function pay(?Model $model = null): TransactionResponse { return parent::pay($model ?? new Pay($this->payload)); } - - /** - * @return TransactionResponse - */ - public function authorize(): TransactionResponse - { - $pay = new Pay($this->payload); - - $this->setPayPayload(); - - $this->setServiceList('Authorize', $pay); - - return $this->postRequest(); - } - - /** - * @return TransactionResponse - */ - public function capture(): TransactionResponse - { - $capture = new Capture($this->payload); - - $this->setPayPayload(); - - $this->setServiceList('Capture', $capture); - - return $this->postRequest(); - } - - /** - * @return TransactionResponse - */ - public function cancelAuthorize(): TransactionResponse - { - $pay = new Refund($this->payload); - - $this->setPayPayload(); - - $this->setServiceList('CancelAuthorize', $pay); - - return $this->postRequest(); - } } diff --git a/src/PaymentMethods/Blik/Models/Pay.php b/src/PaymentMethods/Blik/Models/Pay.php new file mode 100644 index 0000000..9e511a0 --- /dev/null +++ b/src/PaymentMethods/Blik/Models/Pay.php @@ -0,0 +1,28 @@ + ['afterpaydigiaccept'], Bancontact::class => ['bancontact', 'bancontactmrcash'], Billink::class => ['billink'], + Blik::class => ['blik'], Belfius::class => ['belfius'], BuckarooWallet::class => ['buckaroo_wallet'], CreditCard::class => diff --git a/tests/Buckaroo/Payments/BlikTest.php b/tests/Buckaroo/Payments/BlikTest.php new file mode 100644 index 0000000..8b3df74 --- /dev/null +++ b/tests/Buckaroo/Payments/BlikTest.php @@ -0,0 +1,42 @@ +buckaroo->method('blik')->pay([ + 'currency' => 'PLN', + 'amountDebit' => 10.00, + 'invoice' => 'Blik Test Plugins Example', + 'description' => 'Blik Test Plugins Example', + 'email' => 'test@buckar00.nl' + ]); + + $this->assertTrue($response->isPendingProcessing()); + } +} diff --git a/tests/Buckaroo/Payments/IdealTest.php b/tests/Buckaroo/Payments/IdealTest.php index c7cb886..8ce4ae4 100644 --- a/tests/Buckaroo/Payments/IdealTest.php +++ b/tests/Buckaroo/Payments/IdealTest.php @@ -21,19 +21,6 @@ namespace Tests\Buckaroo\Payments; use Tests\Buckaroo\BuckarooTestCase; -use Buckaroo\Config\Config; - - -class CustomConfig extends Config -{ - public function __construct() - { - $websiteKey = 'Set Key'; - $secretKey = 'From other resources like DB/ENV/Platform Config'; - - parent::__construct($websiteKey, $secretKey); - } -} class IdealTest extends BuckarooTestCase {