-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BP-3179 Add support for "External Payments"
- Loading branch information
Ivascu Madalin
committed
Nov 28, 2023
1 parent
f8271d3
commit 0dee2bf
Showing
4 changed files
with
140 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
require_once __DIR__.'/../bootstrap.php'; | ||
|
||
use Buckaroo\BuckarooClient; | ||
|
||
$buckaroo = new BuckarooClient($_ENV['BPE_WEBSITE_KEY'], $_ENV['BPE_SECRET_KEY']); | ||
|
||
$response = $buckaroo->method('externalPayment')->pay([ | ||
'invoice' => uniqid(), | ||
'amountDebit' => 10.10, | ||
'channel' => 'BackOffice' | ||
]); | ||
|
||
$buckaroo->method('externalPayment')->refund([ | ||
'amountCredit' => 10, | ||
'invoice' => 'testinvoice 123', | ||
'originalTransactionKey' => $response->getTransactionKey(), | ||
]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?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\ExternalPayment; | ||
|
||
use Buckaroo\PaymentMethods\PayablePaymentMethod; | ||
|
||
class ExternalPayment extends PayablePaymentMethod | ||
{ | ||
protected string $paymentName = 'ExternalPayment'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?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 ExternalPaymentTest extends BuckarooTestCase | ||
{ | ||
/** | ||
* @return void | ||
* @test | ||
*/ | ||
public function it_creates_a_external_payment() | ||
{ | ||
$response = $this->buckaroo->method('externalPayment')->pay([ | ||
'invoice' => uniqid(), | ||
'amountDebit' => 11.10, | ||
'channel' => 'BACKOFFICE' | ||
]); | ||
|
||
$this->assertTrue($response->isSuccess()); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function it_creates_a_external_payment_refund() | ||
{ | ||
$response = $this->buckaroo->method('externalPayment')->refund([ | ||
'amountCredit' => 10, | ||
'invoice' => 'testinvoice 123', | ||
'description' => 'refund', | ||
'originalTransactionKey' => '2D04704995B74D679AACC59F87XXXXXX', | ||
]); | ||
|
||
$this->assertTrue($response->isFailed()); | ||
} | ||
} |