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

BA-278 - Add payment method: Blik #178

Merged
merged 3 commits into from
May 16, 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
17 changes: 17 additions & 0 deletions example/transactions/blik.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

require_once '../bootstrap.php';

use Buckaroo\BuckarooClient;

$buckaroo = new BuckarooClient($_ENV['BPE_WEBSITE_KEY'], $_ENV['BPE_SECRET_KEY']);

//Also accepts json
//Pay
$response = $buckaroo->method('blik')->pay([
'currency' => 'PLN',
'amountDebit' => 10.00,
'invoice' => 'Blik Test Plugins Example',
'description' => 'Blik Test Plugins Example',
'email' => '[email protected]'
]);
43 changes: 43 additions & 0 deletions src/PaymentMethods/Blik/Blik.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?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 [email protected] 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 [email protected] for more information.
*
* @copyright Copyright (c) Buckaroo B.V.
* @license https://tldrlegal.com/license/mit-license
*/

namespace Buckaroo\PaymentMethods\Blik;

use Buckaroo\Models\Model;
use Buckaroo\PaymentMethods\Blik\Models\Pay;
use Buckaroo\PaymentMethods\PayablePaymentMethod;
use Buckaroo\Transaction\Response\TransactionResponse;

class Blik extends PayablePaymentMethod
{
/**
* @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));
}
}
28 changes: 28 additions & 0 deletions src/PaymentMethods/Blik/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 [email protected] 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 [email protected] for more information.
*
* @copyright Copyright (c) Buckaroo B.V.
* @license https://tldrlegal.com/license/mit-license
*/

namespace Buckaroo\PaymentMethods\Blik\Models;

use Buckaroo\Models\ServiceParameter;

class Pay extends ServiceParameter
{
protected string $email;
}
2 changes: 2 additions & 0 deletions src/PaymentMethods/PaymentMethodFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,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
Expand All @@ -79,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 =>
Expand Down
42 changes: 42 additions & 0 deletions tests/Buckaroo/Payments/BlikTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?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 [email protected] 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 [email protected] 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 BlikTest extends BuckarooTestCase
{
/**
* @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' => '[email protected]'
]);

$this->assertTrue($response->isPendingProcessing());
}
}
13 changes: 0 additions & 13 deletions tests/Buckaroo/Payments/IdealTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
Loading