Skip to content

Commit

Permalink
Merge pull request #178 from buckaroo-it/BA-278
Browse files Browse the repository at this point in the history
BA-278 - Add payment method: Blik
  • Loading branch information
vildanbina authored May 16, 2024
2 parents bc04115 + 157f367 commit d13feab
Show file tree
Hide file tree
Showing 6 changed files with 132 additions and 13 deletions.
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' => 'test@buckar00.nl'
]);
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 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\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 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\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 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 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' => 'test@buckar00.nl'
]);

$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

0 comments on commit d13feab

Please sign in to comment.