Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding Knaken payment #164

Merged
merged 6 commits into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "buckaroo/sdk",
"description": "Buckaroo payment SDK",
"license": "MIT",
"version": "1.9.1",
"version": "1.10.0",
"type": "library",
"require": {
"php": ">=7.4|^8.0",
Expand Down
47 changes: 47 additions & 0 deletions src/PaymentMethods/KnakenPay/KnakenPay.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php
/*
* NOTICE OF LICENSE
*
* This source file is subject to the MIT License
* It is available through the world-wide-web at this URL:
* https://tldrlegal.com/license/mit-license
* If you are unable to obtain it through the world-wide-web, please send an email
* to support@buckaroo.nl so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this module to newer
* versions in the future. If you wish to customize this module for your
* needs please contact support@buckaroo.nl for more information.
*
* @copyright Copyright (c) Buckaroo B.V.
* @license https://tldrlegal.com/license/mit-license
*/

declare(strict_types=1);

namespace Buckaroo\PaymentMethods\KnakenPay;

use Buckaroo\Models\Model;
use Buckaroo\PaymentMethods\PayablePaymentMethod;
use Buckaroo\Transaction\Response\TransactionResponse;
use Buckaroo\Models\ServiceParameter;

class KnakenPay extends PayablePaymentMethod
{
/**
* @var string
*/
protected string $paymentName = 'knaken';

protected int $serviceVersion = 1;

/**
* @param Model|null $model
* @return TransactionResponse
*/
public function pay(?Model $model = null)
{
return parent::pay($model ?? new ServiceParameter($this->payload));
}
}
28 changes: 28 additions & 0 deletions src/PaymentMethods/KnakenPay/Models/Pay.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php
/*
* NOTICE OF LICENSE
*
* This source file is subject to the MIT License
* It is available through the world-wide-web at this URL:
* https://tldrlegal.com/license/mit-license
* If you are unable to obtain it through the world-wide-web, please send an email
* to support@buckaroo.nl so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this module to newer
* versions in the future. If you wish to customize this module for your
* needs please contact support@buckaroo.nl for more information.
*
* @copyright Copyright (c) Buckaroo B.V.
* @license https://tldrlegal.com/license/mit-license
*/

namespace Buckaroo\PaymentMethods\KnakenPay\Models;

use Buckaroo\Models\ServiceParameter;

class Pay extends ServiceParameter
{
protected string $issuer;
}
2 changes: 2 additions & 0 deletions src/PaymentMethods/PaymentMethodFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
use Buckaroo\PaymentMethods\ApplePay\ApplePay;
use Buckaroo\PaymentMethods\GiftCard\GiftCard;
use Buckaroo\PaymentMethods\KlarnaKP\KlarnaKP;
use Buckaroo\PaymentMethods\KnakenPay\KnakenPay;
use Buckaroo\PaymentMethods\Payconiq\Payconiq;
use Buckaroo\PaymentMethods\Emandates\Emandates;
use Buckaroo\PaymentMethods\KlarnaPay\KlarnaPay;
Expand Down Expand Up @@ -98,6 +99,7 @@ class PaymentMethodFactory
In3Old::class => ['in3old'],
KlarnaPay::class => ['klarna', 'klarnain'],
KlarnaKP::class => ['klarnakp'],
KnakenPay::class => ['knaken', 'knakenpay'],
Multibanco::class => ['multibanco'],
MBWay::class => ['mbway'],
Surepay::class => ['surepay'],
Expand Down
61 changes: 61 additions & 0 deletions tests/Buckaroo/Payments/KnakenPayTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<?php
/*
* NOTICE OF LICENSE
*
* This source file is subject to the MIT License
* It is available through the world-wide-web at this URL:
* https://tldrlegal.com/license/mit-license
* If you are unable to obtain it through the world-wide-web, please send an email
* to support@buckaroo.nl so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this module to newer
* versions in the future. If you wish to customize this module for your
* needs please contact support@buckaroo.nl for more information.
*
* @copyright Copyright (c) Buckaroo B.V.
* @license https://tldrlegal.com/license/mit-license
*/

namespace Tests\Buckaroo\Payments;

use Tests\Buckaroo\BuckarooTestCase;

class KnakenPayTest extends BuckarooTestCase
{
/**
* @return void
* @test
*/
public function it_creates_a_knaken_payment()
{
$response = $this->buckaroo->method('knaken')->pay([
'invoice' => uniqid(),
'amountDebit' => 10.99,
'returnURL' => 'https://buckaroo.dev./return',
'returnURLCancel' => 'https://buckaroo.dev/cancel',
'returnURLError' => 'https://buckaroo.dev/error',
'returnURLReject' => 'https://buckaroo.dev/reject',
'pushURL' => 'https://buckaroo.dev/push',
'pushURLFailure' => 'https://buckaroo.dev/push-failure',
]);

$this->assertTrue($response->isPendingProcessing());
}

/**
* @test
*/
public function it_creates_a_knaken_refund()
{
$response = $this->buckaroo->method('knaken')->refund([
'invoice' => '2024020209061234', //Set invoice number of the transaction to refund
'originalTransactionKey' => '2FBB9F43A0AF4AC8B49F9073C0EC828B',
//Set transaction key of the transaction to refund
'amountCredit' => 0.01
]);

$this->assertTrue($response->isFailed());
}
}
Loading