diff --git a/composer.json b/composer.json index d4712ec4..16fd1d9c 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "buckaroo/sdk", "description": "Buckaroo payment SDK", "license": "MIT", - "version": "1.11.0", + "version": "1.12.0", "type": "library", "require": { "php": ">=7.4|^8.0", diff --git a/example/transactions/blik.php b/example/transactions/blik.php new file mode 100644 index 00000000..d0b81a11 --- /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/example/transactions/credit_click.php b/example/transactions/credit_click.php deleted file mode 100644 index 63a3c9fe..00000000 --- a/example/transactions/credit_click.php +++ /dev/null @@ -1,30 +0,0 @@ -method('creditclick')->pay([ - 'amountDebit' => 10, - 'invoice' => uniqid(), - 'email' => 'billingcustomer@buckaroo.nl', - 'customer' => [ - 'firstName' => 'Test', - 'lastName' => 'Aflever', - ], -]); - -//Refund -$response = $buckaroo->method('creditclick')->refund([ - 'amountCredit' => 10, - 'invoice' => 'testinvoice 123', - 'description' => 'refund', - 'originalTransactionKey' => '2D04704995B74D679AACC59F87XXXXXX', - 'serviceParameters' => [ - 'reason' => 'RequestedByCustomer', - ], -]); diff --git a/example/transactions/tinka.php b/example/transactions/tinka.php deleted file mode 100644 index deb26f2a..00000000 --- a/example/transactions/tinka.php +++ /dev/null @@ -1,81 +0,0 @@ -method('tinka')->pay([ - 'amountDebit' => 3.5, - 'order' => uniqid(), - 'invoice' => uniqid(), - 'description' => 'This is a test order', - 'paymentMethod' => 'Credit', - 'deliveryMethod' => 'Locker', - 'deliveryDate' => '2030-01-01', - 'articles' => [ - [ - 'type' => 1, - 'description' => 'Blue Toy Car', - 'brand' => 'Ford Focus', - 'manufacturer' => 'Ford', - 'color' => 'Red', - 'size' => 'Small', - 'quantity' => '1', - 'price' => '3.5', - 'unitCode' => 'test', - ], - ], - 'customer' => [ - 'gender' => Gender::MALE, - 'firstName' => 'Buck', - 'lastName' => 'Aroo', - 'initials' => 'BA', - 'birthDate' => '1990-01-01', - ], - 'billing' => [ - 'recipient' => [ - 'lastNamePrefix' => 'the', - ], - 'email' => 'billingcustomer@buckaroo.nl', - 'phone' => [ - 'mobile' => '0109876543', - ], - 'address' => [ - 'street' => 'Hoofdstraat', - 'houseNumber' => '80', - 'houseNumberAdditional' => 'A', - 'zipcode' => '8441EE', - 'city' => 'Heerenveen', - 'country' => 'NL', - ], - ], - 'shipping' => [ - 'recipient' => [ - 'lastNamePrefix' => 'the', - ], - 'email' => 'billingcustomer@buckaroo.nl', - 'phone' => [ - 'mobile' => '0109876543', - ], - 'address' => [ - 'street' => 'Hoofdstraat', - 'houseNumber' => '80', - 'houseNumberAdditional' => 'A', - 'zipcode' => '8441EE', - 'city' => 'Heerenveen', - 'country' => 'NL', - ], - ], -]); - -//Refund -$response = $buckaroo->method('tinka')->refund([ - 'amountCredit' => 10, - 'invoice' => 'testinvoice 123', - 'originalTransactionKey' => '2D04704995B74D679AACC59F87XXXXXX', -]); diff --git a/phpcs.xml b/phpcs.xml index e60e272d..e3e1b7c2 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -16,6 +16,7 @@ src/PaymentMethods/iDeal/iDeal.php src/PaymentMethods/iDealQR/iDealQR.php src/PaymentMethods/iDin/iDin.php + src/PaymentMethods/iDealProcessing/iDealProcessing.php diff --git a/src/PaymentMethods/Billink/Billink.php b/src/PaymentMethods/Billink/Billink.php index 338b970d..2de8138f 100644 --- a/src/PaymentMethods/Billink/Billink.php +++ b/src/PaymentMethods/Billink/Billink.php @@ -23,7 +23,7 @@ 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\Billink\Models\Refund; use Buckaroo\PaymentMethods\PayablePaymentMethod; use Buckaroo\Transaction\Response\TransactionResponse; @@ -76,11 +76,11 @@ public function capture(): TransactionResponse */ public function cancelAuthorize(): TransactionResponse { - $pay = new Refund($this->payload); + $cancel = new Refund($this->payload); $this->setPayPayload(); - $this->setServiceList('CancelAuthorize', $pay); + $this->setServiceList('CancelAuthorize', $cancel); return $this->postRequest(); } diff --git a/src/PaymentMethods/CreditClick/Models/Refund.php b/src/PaymentMethods/Billink/Models/Refund.php similarity index 93% rename from src/PaymentMethods/CreditClick/Models/Refund.php rename to src/PaymentMethods/Billink/Models/Refund.php index 881cfd99..2d858487 100644 --- a/src/PaymentMethods/CreditClick/Models/Refund.php +++ b/src/PaymentMethods/Billink/Models/Refund.php @@ -18,7 +18,7 @@ * @license https://tldrlegal.com/license/mit-license */ -namespace Buckaroo\PaymentMethods\CreditClick\Models; +namespace Buckaroo\PaymentMethods\Billink\Models; use Buckaroo\Models\ServiceParameter; diff --git a/src/PaymentMethods/Tinka/Tinka.php b/src/PaymentMethods/Blik/Blik.php similarity index 76% rename from src/PaymentMethods/Tinka/Tinka.php rename to src/PaymentMethods/Blik/Blik.php index 0363ae78..878b4ebb 100644 --- a/src/PaymentMethods/Tinka/Tinka.php +++ b/src/PaymentMethods/Blik/Blik.php @@ -18,18 +18,24 @@ * @license https://tldrlegal.com/license/mit-license */ -namespace Buckaroo\PaymentMethods\Tinka; +namespace Buckaroo\PaymentMethods\Blik; use Buckaroo\Models\Model; - +use Buckaroo\PaymentMethods\Blik\Models\Pay; use Buckaroo\PaymentMethods\PayablePaymentMethod; -use Buckaroo\PaymentMethods\Tinka\Models\Pay; use Buckaroo\Transaction\Response\TransactionResponse; -class Tinka extends PayablePaymentMethod +class Blik extends PayablePaymentMethod { - protected string $paymentName = 'Tinka'; + /** + * @var string + */ + protected string $paymentName = 'Blik'; + /** + * @param Model|null $model + * @return TransactionResponse + */ public function pay(?Model $model = null): TransactionResponse { return parent::pay($model ?? new Pay($this->payload)); diff --git a/src/PaymentMethods/Tinka/Models/Article.php b/src/PaymentMethods/Blik/Models/Pay.php similarity index 82% rename from src/PaymentMethods/Tinka/Models/Article.php rename to src/PaymentMethods/Blik/Models/Pay.php index 1ad39f07..9e511a08 100644 --- a/src/PaymentMethods/Tinka/Models/Article.php +++ b/src/PaymentMethods/Blik/Models/Pay.php @@ -18,9 +18,11 @@ * @license https://tldrlegal.com/license/mit-license */ -namespace Buckaroo\PaymentMethods\Tinka\Models; +namespace Buckaroo\PaymentMethods\Blik\Models; -class Article extends \Buckaroo\Models\Article +use Buckaroo\Models\ServiceParameter; + +class Pay extends ServiceParameter { - protected string $color; + protected string $email; } diff --git a/src/PaymentMethods/CreditClick/Models/Pay.php b/src/PaymentMethods/CreditClick/Models/Pay.php deleted file mode 100644 index f5cb5f49..00000000 --- a/src/PaymentMethods/CreditClick/Models/Pay.php +++ /dev/null @@ -1,65 +0,0 @@ -customer = new Person($customer); - } - - return $this->customer; - } - - /** - * @param $email - * @return Email - */ - public function email($email = null) - { - if (is_string($email)) - { - $this->email = new Email($email); - } - - return $this->email; - } -} diff --git a/src/PaymentMethods/PaymentFacade.php b/src/PaymentMethods/PaymentFacade.php index 584472ac..76d65d68 100644 --- a/src/PaymentMethods/PaymentFacade.php +++ b/src/PaymentMethods/PaymentFacade.php @@ -166,8 +166,13 @@ public function paymentMethod(): PaymentMethod */ public function __call(?string $name, array $arguments) { - if (method_exists($this->paymentMethod, $name)) - { + if (method_exists($this->paymentMethod, $name)) { + if($name === 'setServiceVersion') { + $this->paymentMethod->setServiceVersion($arguments[0]); + + return $this; + } + $this->paymentMethod->setPayload((new PayloadService($arguments[0] ?? []))->toArray()); return $this->paymentMethod->$name(); diff --git a/src/PaymentMethods/PaymentMethod.php b/src/PaymentMethods/PaymentMethod.php index 3041656c..0a1cf3a8 100644 --- a/src/PaymentMethods/PaymentMethod.php +++ b/src/PaymentMethods/PaymentMethod.php @@ -171,6 +171,16 @@ public function serviceVersion(): int return $this->serviceVersion; } + /** + * @return PaymentInterface + */ + public function setServiceVersion(int $serviceVersion): PaymentInterface + { + $this->serviceVersion = $serviceVersion; + + return $this; + } + /** * @param bool|null $isManually * @return $this diff --git a/src/PaymentMethods/PaymentMethodFactory.php b/src/PaymentMethods/PaymentMethodFactory.php index 2840b750..28b9d557 100644 --- a/src/PaymentMethods/PaymentMethodFactory.php +++ b/src/PaymentMethods/PaymentMethodFactory.php @@ -27,8 +27,8 @@ use Buckaroo\PaymentMethods\iDin\iDin; use Buckaroo\PaymentMethods\SEPA\SEPA; use Buckaroo\PaymentMethods\iDeal\iDeal; +use Buckaroo\PaymentMethods\iDealProcessing\iDealProcessing; use Buckaroo\PaymentMethods\MBWay\MBWay; -use Buckaroo\PaymentMethods\Tinka\Tinka; use Buckaroo\Exceptions\BuckarooException; use Buckaroo\PaymentMethods\Alipay\Alipay; use Buckaroo\PaymentMethods\In3Old\In3Old; @@ -54,7 +54,6 @@ use Buckaroo\PaymentMethods\CreditCard\CreditCard; use Buckaroo\PaymentMethods\Multibanco\Multibanco; use Buckaroo\PaymentMethods\Przelewy24\Przelewy24; -use Buckaroo\PaymentMethods\CreditClick\CreditClick; use Buckaroo\PaymentMethods\PayPerEmail\PayPerEmail; use Buckaroo\PaymentMethods\PointOfSale\PointOfSale; use Buckaroo\PaymentMethods\BankTransfer\BankTransfer; @@ -66,6 +65,7 @@ use Buckaroo\PaymentMethods\CreditManagement\CreditManagement; use Buckaroo\PaymentMethods\PaymentInitiation\PaymentInitiation; use Buckaroo\PaymentMethods\AfterpayDigiAccept\AfterpayDigiAccept; +use Buckaroo\PaymentMethods\Blik\Blik; use Buckaroo\PaymentMethods\NoServiceSpecifiedPayment\NoServiceSpecifiedPayment; class PaymentMethodFactory @@ -80,6 +80,7 @@ class PaymentMethodFactory AfterpayDigiAccept::class => ['afterpaydigiaccept'], Bancontact::class => ['bancontact', 'bancontactmrcash'], Billink::class => ['billink'], + Blik::class => ['blik'], Belfius::class => ['belfius'], BuckarooWallet::class => ['buckaroo_wallet'], CreditCard::class => @@ -90,9 +91,9 @@ class PaymentMethodFactory 'cartebancaire', 'dankort', 'nexi', 'postepay', ], - CreditClick::class => ['creditclick'], CreditManagement::class => ['credit_management'], - iDeal::class => ['ideal', 'idealprocessing'], + iDeal::class => ['ideal'], + iDealProcessing::class => ['idealprocessing'], iDealQR::class => ['ideal_qr'], iDin::class => ['idin'], In3::class => ['in3'], @@ -113,14 +114,12 @@ class PaymentMethodFactory ExternalPayment::class => ['externalpayment'], Emandates::class => ['emandates'], Sofort::class => ['sofort', 'sofortueberweisung'], - Tinka::class => ['tinka'], Marketplaces::class => ['marketplaces'], NoServiceSpecifiedPayment::class => ['noservice'], Payconiq::class => ['payconiq'], Przelewy24::class => ['przelewy24'], PointOfSale::class => ['pospayment'], Giropay::class => ['giropay'], - NoServiceSpecifiedPayment::class => ['noservice'], GiftCard::class => [ 'giftcard', 'westlandbon', 'babygiftcard', 'babyparkgiftcard', 'beautywellness', 'boekenbon', 'boekenvoordeel', diff --git a/src/PaymentMethods/Tinka/Models/Pay.php b/src/PaymentMethods/Tinka/Models/Pay.php deleted file mode 100644 index 7991be1b..00000000 --- a/src/PaymentMethods/Tinka/Models/Pay.php +++ /dev/null @@ -1,137 +0,0 @@ - [ - 'groupType' => 'Article', - ], - ]; - - /** - * @param $billing - * @return Recipient - */ - public function billing($billing = null) - { - if (is_array($billing)) - { - $this->billingRecipient = new Recipient('Billing', $billing); - $this->shippingRecipient = new Recipient('Billing', $billing); - } - - return $this->billingRecipient; - } - - /** - * @param $shipping - * @return Recipient - */ - public function shipping($shipping = null) - { - if (is_array($shipping)) - { - $this->shippingRecipient = new Recipient('Shipping', $shipping); - } - - return $this->shippingRecipient; - } - - /** - * @param $customer - * @return CustomerAdapter - */ - public function customer($customer = null) - { - if (is_array($customer)) - { - $this->customer = new CustomerAdapter(new Person($customer)); - } - - return $this->customer; - } - - /** - * @param array|null $articles - * @return array - */ - public function articles(?array $articles = null) - { - if (is_array($articles)) - { - foreach ($articles as $article) - { - $this->articles[] = new ArticleAdapter(new Article($article)); - } - } - - return $this->articles; - } -} diff --git a/src/PaymentMethods/Tinka/Models/Recipient.php b/src/PaymentMethods/Tinka/Models/Recipient.php deleted file mode 100644 index b266423a..00000000 --- a/src/PaymentMethods/Tinka/Models/Recipient.php +++ /dev/null @@ -1,132 +0,0 @@ -type = $type; - - parent::__construct($values); - } - - /** - * @param $recipient - * @return CustomerAdapter - */ - public function recipient($recipient = null) - { - if (is_array($recipient)) - { - $this->recipient = new CustomerAdapter(new Person($recipient)); - } - - return $this->recipient; - } - - /** - * @param $address - * @return AddressAdapter - */ - public function address($address = null) - { - if (is_array($address)) - { - $this->address = new AddressAdapter(new Address($address)); - } - - return $this->address; - } - - /** - * @param $phone - * @return PhoneAdapter - */ - public function phone($phone = null) - { - if (is_array($phone)) - { - $this->phone = new PhoneAdapter(new Phone($phone)); - } - - return $this->phone; - } - - /** - * @param $email - * @return Email - */ - public function email($email = null) - { - if (is_string($email)) - { - $this->email = new Email($email); - } - - return $this->email; - } - - /** - * @param string $key - * @return string|null - */ - public function getGroupType(string $key): ?string - { - return $this->type . 'Customer'; - } -} diff --git a/src/PaymentMethods/Tinka/Service/ParameterKeys/AddressAdapter.php b/src/PaymentMethods/Tinka/Service/ParameterKeys/AddressAdapter.php deleted file mode 100644 index bd316ace..00000000 --- a/src/PaymentMethods/Tinka/Service/ParameterKeys/AddressAdapter.php +++ /dev/null @@ -1,32 +0,0 @@ - 'StreetNumber', - 'houseNumberAdditional' => 'StreetNumberAdditional', - 'zipcode' => 'PostalCode', - ]; -} diff --git a/src/PaymentMethods/Tinka/Service/ParameterKeys/ArticleAdapter.php b/src/PaymentMethods/Tinka/Service/ParameterKeys/ArticleAdapter.php deleted file mode 100644 index 79f51acc..00000000 --- a/src/PaymentMethods/Tinka/Service/ParameterKeys/ArticleAdapter.php +++ /dev/null @@ -1,30 +0,0 @@ - 'UnitGrossPrice', - ]; -} diff --git a/src/PaymentMethods/Tinka/Service/ParameterKeys/CustomerAdapter.php b/src/PaymentMethods/Tinka/Service/ParameterKeys/CustomerAdapter.php deleted file mode 100644 index f868f4e8..00000000 --- a/src/PaymentMethods/Tinka/Service/ParameterKeys/CustomerAdapter.php +++ /dev/null @@ -1,31 +0,0 @@ - 'PrefixLastName', - 'birthDate' => 'DateOfBirth', - ]; -} diff --git a/src/PaymentMethods/iDeal/iDeal.php b/src/PaymentMethods/iDeal/iDeal.php index dbd07614..4a19fac9 100644 --- a/src/PaymentMethods/iDeal/iDeal.php +++ b/src/PaymentMethods/iDeal/iDeal.php @@ -53,6 +53,21 @@ public function pay(?Model $model = null) return parent::pay($model ?? new Pay($this->payload)); } + /** + * @param Model|null $model + * @return TransactionResponse + */ + public function payFastCheckout(?Model $model = null) + { + $this->setPayPayload(); + + $this->request->setData('order', ''); + + $this->setServiceList('PayFastCheckout', $model ?? new Pay($this->payload)); + + return $this->postRequest(); + } + /** * @param Model|null $model * @return TransactionResponse diff --git a/src/PaymentMethods/Tinka/Service/ParameterKeys/PhoneAdapter.php b/src/PaymentMethods/iDealProcessing/Models/Pay.php similarity index 73% rename from src/PaymentMethods/Tinka/Service/ParameterKeys/PhoneAdapter.php rename to src/PaymentMethods/iDealProcessing/Models/Pay.php index e9638788..5e10d05c 100644 --- a/src/PaymentMethods/Tinka/Service/ParameterKeys/PhoneAdapter.php +++ b/src/PaymentMethods/iDealProcessing/Models/Pay.php @@ -18,13 +18,11 @@ * @license https://tldrlegal.com/license/mit-license */ -namespace Buckaroo\PaymentMethods\Tinka\Service\ParameterKeys; +namespace Buckaroo\PaymentMethods\iDealProcessing\Models; -use Buckaroo\Models\Adapters\ServiceParametersKeysAdapter; +use Buckaroo\Models\ServiceParameter; -class PhoneAdapter extends ServiceParametersKeysAdapter +class Pay extends ServiceParameter { - protected array $keys = [ - 'mobile' => 'Phone' - ]; + protected string $issuer; } diff --git a/src/PaymentMethods/CreditClick/CreditClick.php b/src/PaymentMethods/iDealProcessing/iDealProcessing.php similarity index 54% rename from src/PaymentMethods/CreditClick/CreditClick.php rename to src/PaymentMethods/iDealProcessing/iDealProcessing.php index e1f535dc..1dbe949c 100644 --- a/src/PaymentMethods/CreditClick/CreditClick.php +++ b/src/PaymentMethods/iDealProcessing/iDealProcessing.php @@ -18,26 +18,37 @@ * @license https://tldrlegal.com/license/mit-license */ -namespace Buckaroo\PaymentMethods\CreditClick; +declare(strict_types=1); +namespace Buckaroo\PaymentMethods\iDealProcessing; + +use Buckaroo\Exceptions\BuckarooException; use Buckaroo\Models\Model; -use Buckaroo\PaymentMethods\CreditClick\Models\Pay; -use Buckaroo\PaymentMethods\CreditClick\Models\Refund; +use Buckaroo\PaymentMethods\iDealProcessing\Models\Pay; use Buckaroo\PaymentMethods\PayablePaymentMethod; +use Buckaroo\Services\TraitHelpers\HasIssuers; use Buckaroo\Transaction\Response\TransactionResponse; -class CreditClick extends PayablePaymentMethod +class iDealProcessing extends PayablePaymentMethod { + use HasIssuers { + issuers as traitIssuers; + } + /** * @var string */ - protected string $paymentName = 'creditclick'; + protected string $paymentName = 'idealprocessing'; + /** + * @var array|string[] + */ + protected array $requiredConfigFields = ['currency', 'returnURL', 'returnURLCancel', 'pushURL']; /** * @param Model|null $model * @return TransactionResponse */ - public function pay(?Model $model = null): TransactionResponse + public function pay(?Model $model = null) { return parent::pay($model ?? new Pay($this->payload)); } @@ -46,8 +57,19 @@ public function pay(?Model $model = null): TransactionResponse * @param Model|null $model * @return TransactionResponse */ - public function refund(?Model $model = null): TransactionResponse + public function payRemainder(?Model $model = null): TransactionResponse { - return parent::refund($model ?? new Refund($this->payload)); + return parent::payRemainder($model ?? new Pay($this->payload)); + } + + /** + * @return array + * @throws BuckarooException + */ + public function issuers(): array + { + $this->serviceVersion = 2; + + return $this->traitIssuers(); } } diff --git a/src/Resources/Constants/ResponseStatus.php b/src/Resources/Constants/ResponseStatus.php index f4f5414a..cb59462d 100644 --- a/src/Resources/Constants/ResponseStatus.php +++ b/src/Resources/Constants/ResponseStatus.php @@ -33,6 +33,7 @@ class ResponseStatus public const BUCKAROO_STATUSCODE_PENDING_PROCESSING = '791'; public const BUCKAROO_STATUSCODE_WAITING_ON_CONSUMER = '792'; public const BUCKAROO_STATUSCODE_PAYMENT_ON_HOLD = '793'; + public const BUCKAROO_STATUSCODE_PENDING_APPROVAL = '794'; public const BUCKAROO_STATUSCODE_CANCELLED_BY_USER = '890'; public const BUCKAROO_STATUSCODE_CANCELLED_BY_MERCHANT = '891'; diff --git a/src/Transaction/Response/TransactionResponse.php b/src/Transaction/Response/TransactionResponse.php index e4e3085d..c6b9bbf4 100644 --- a/src/Transaction/Response/TransactionResponse.php +++ b/src/Transaction/Response/TransactionResponse.php @@ -83,6 +83,14 @@ public function isRejected(): bool return $this->getStatusCode() == ResponseStatus::BUCKAROO_STATUSCODE_REJECTED; } + /** + * @return bool + */ + public function isPendingApproval(): bool + { + return $this->getStatusCode() == ResponseStatus::BUCKAROO_STATUSCODE_PENDING_APPROVAL; + } + /** * @return bool */ diff --git a/tests/Buckaroo/Payments/AfterpayTest.php b/tests/Buckaroo/Payments/AfterpayTest.php index a92d30d0..bec23abd 100644 --- a/tests/Buckaroo/Payments/AfterpayTest.php +++ b/tests/Buckaroo/Payments/AfterpayTest.php @@ -31,7 +31,7 @@ class AfterpayTest extends BuckarooTestCase */ public function it_creates_a_afterpay_payment() { - $response = $this->buckaroo->method('afterpay')->pay($this->getPaymentPayload()); + $response = $this->buckaroo->method('afterpay')->setServiceVersion(3)->pay($this->getPaymentPayload()); $this->assertTrue($response->isSuccess()); } diff --git a/src/PaymentMethods/CreditClick/Service/ParameterKeys/CustomerAdapter.php b/tests/Buckaroo/Payments/BlikTest.php similarity index 54% rename from src/PaymentMethods/CreditClick/Service/ParameterKeys/CustomerAdapter.php rename to tests/Buckaroo/Payments/BlikTest.php index 6f21cb87..8b3df74a 100644 --- a/src/PaymentMethods/CreditClick/Service/ParameterKeys/CustomerAdapter.php +++ b/tests/Buckaroo/Payments/BlikTest.php @@ -18,15 +18,25 @@ * @license https://tldrlegal.com/license/mit-license */ -namespace Buckaroo\PaymentMethods\CreditClick\Service\ParameterKeys; +namespace Tests\Buckaroo\Payments; -use Buckaroo\Models\Adapters\ServiceParametersKeysAdapter; +use Tests\Buckaroo\BuckarooTestCase; -class CustomerAdapter extends ServiceParametersKeysAdapter +class BlikTest extends BuckarooTestCase { - protected array $keys = [ - 'firstName' => 'firstname', - 'lastName' => 'lastname', - 'email' => 'email', - ]; + /** + * @test + */ + public function it_creates_a_blik_payment() + { + $response = $this->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/CreditClickTest.php b/tests/Buckaroo/Payments/CreditClickTest.php deleted file mode 100644 index ab4db2d7..00000000 --- a/tests/Buckaroo/Payments/CreditClickTest.php +++ /dev/null @@ -1,61 +0,0 @@ -buckaroo->method('creditclick')->pay([ - 'amountDebit' => 10, - 'invoice' => uniqid(), - 'customer' => [ - 'firstName' => 'Test', - 'lastName' => 'Aflever', - ], - 'email' => 't.tester@test.nl', - ]); - - $this->assertTrue($response->isPendingProcessing()); - } - - /** - * @test - */ - public function it_creates_a_creditclick_refund() - { - $response = $this->buckaroo->method('creditclick')->refund([ - 'amountCredit' => 10, - 'invoice' => 'testinvoice 123', - 'description' => 'refund', - 'originalTransactionKey' => '2D04704995B74D679AACC59F87XXXXXX', - 'refundreason' => 'RequestedByCustomer', - ]); - - $this->assertTrue($response->isFailed()); - } -} diff --git a/tests/Buckaroo/Payments/IdealProcessingTest.php b/tests/Buckaroo/Payments/IdealProcessingTest.php new file mode 100644 index 00000000..cb4b3845 --- /dev/null +++ b/tests/Buckaroo/Payments/IdealProcessingTest.php @@ -0,0 +1,90 @@ +paymentPayload = [ + 'invoice' => uniqid(), + 'amountDebit' => 10.10, + 'issuer' => 'ABNANL2A', + 'pushURL' => 'https://buckaroo.dev/push', + 'returnURL' => 'https://buckaroo.dev/return', + 'clientIP' => [ + 'address' => '123.456.789.123', + 'type' => 0, + ], + 'customParameters' => [ + 'CustomerBillingFirstName' => 'test' + ], + 'additionalParameters' => [ + 'initiated_by_magento' => 1, + 'service_action' => 'something', + ], + ]; + } + + /** + * @return void + * @test + */ + public function it_get_idealprocessing_issuers() + { + $response = $this->buckaroo->method('idealprocessing')->issuers(); + + $this->assertIsArray($response); + foreach ($response as $item) + { + $this->assertIsArray($item); + $this->assertArrayHasKey('id', $item); + $this->assertArrayHasKey('name', $item); + } + } + + /** + * @return void + * @test + */ + public function it_creates_a_idealprocessing_payment() + { + $response = $this->buckaroo->method('idealprocessing')->pay($this->paymentPayload); + + $this->assertTrue($response->isPendingProcessing()); + } +} diff --git a/tests/Buckaroo/Payments/IdealTest.php b/tests/Buckaroo/Payments/IdealTest.php index 6b402c10..c0d3508c 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 { @@ -100,11 +87,25 @@ public function it_get_ideal_issuers() */ public function it_creates_a_ideal_payment() { - $response = $this->buckaroo->method('idealprocessing')->pay($this->paymentPayload); + $response = $this->buckaroo->method('ideal')->pay($this->paymentPayload); $this->assertTrue($response->isPendingProcessing()); } + /** + * @return void + * @test + */ + public function it_creates_a_ideal_fast_checkout_payment() + { + $response = $this->buckaroo->method('ideal')->payFastCheckout([ + 'amountDebit' => 10.10, + 'invoice' => uniqid(), + ]); + + $this->assertTrue($response->isWaitingOnUserInput()); + } + /** * @test */ diff --git a/tests/Buckaroo/Payments/TinkaTest.php b/tests/Buckaroo/Payments/TinkaTest.php deleted file mode 100644 index e4689423..00000000 --- a/tests/Buckaroo/Payments/TinkaTest.php +++ /dev/null @@ -1,118 +0,0 @@ -buckaroo->method('tinka')->pay($this->getPaymentPayload()); - - $this->assertTrue($response->isPendingProcessing()); - } - - /** - * @test - */ - public function it_creates_a_tinka_refund() - { - $response = $this->buckaroo->method('tinka')->refund([ - 'amountCredit' => 10, - 'invoice' => 'testinvoice 123', - 'originalTransactionKey' => '2D04704995B74D679AACC59F87XXXXXX', - ]); - - $this->assertTrue($response->isFailed()); - } - - private function getPaymentPayload(): array - { - return [ - 'amountDebit' => 3.5, - 'order' => uniqid(), - 'invoice' => uniqid(), - 'description' => 'This is a test order', - 'paymentMethod' => 'Credit', - 'deliveryMethod' => 'Locker', - 'deliveryDate' => '2030-01-01', - 'articles' => [ - [ - 'type' => 1, - 'description' => 'Blue Toy Car', - 'brand' => 'Ford Focus', - 'manufacturer' => 'Ford', - 'color' => 'Red', - 'size' => 'Small', - 'quantity' => '1', - 'price' => '3.5', - 'unitCode' => 'test', - ], - ], - 'customer' => [ - 'gender' => Gender::MALE, - 'firstName' => 'Buck', - 'lastName' => 'Aroo', - 'initials' => 'BA', - 'birthDate' => '1990-01-01', - ], - 'billing' => [ - 'recipient' => [ - 'lastNamePrefix' => 'the', - ], - 'email' => 'billingcustomer@buckaroo.nl', - 'phone' => [ - 'mobile' => '0109876543', - ], - 'address' => [ - 'street' => 'Hoofdstraat', - 'houseNumber' => '80', - 'houseNumberAdditional' => 'A', - 'zipcode' => '8441EE', - 'city' => 'Heerenveen', - 'country' => 'NL', - ], - ], - 'shipping' => [ - 'recipient' => [ - 'lastNamePrefix' => 'the', - ], - 'email' => 'billingcustomer@buckaroo.nl', - 'phone' => [ - 'mobile' => '0109876543', - ], - 'address' => [ - 'street' => 'Hoofdstraat', - 'houseNumber' => '80', - 'houseNumberAdditional' => 'A', - 'zipcode' => '8441EE', - 'city' => 'Heerenveen', - 'country' => 'NL', - ], - ], - ]; - } -}