Skip to content

Commit

Permalink
BP-3179 Add support for "External Payments"
Browse files Browse the repository at this point in the history
  • Loading branch information
Ivascu Madalin committed Nov 28, 2023
1 parent f8271d3 commit 0dee2bf
Show file tree
Hide file tree
Showing 4 changed files with 140 additions and 33 deletions.
19 changes: 19 additions & 0 deletions example/transactions/externalPayment.php
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(),
]);
30 changes: 30 additions & 0 deletions src/PaymentMethods/ExternalPayment/ExternalPayment.php
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';
}
68 changes: 35 additions & 33 deletions src/PaymentMethods/PaymentMethodFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,51 +20,52 @@

namespace Buckaroo\PaymentMethods;

use Buckaroo\Transaction\Client;
use Buckaroo\PaymentMethods\EPS\EPS;
use Buckaroo\PaymentMethods\In3\In3;
use Buckaroo\PaymentMethods\KBC\KBC;
use Buckaroo\PaymentMethods\iDin\iDin;
use Buckaroo\PaymentMethods\SEPA\SEPA;
use Buckaroo\PaymentMethods\iDeal\iDeal;
use Buckaroo\PaymentMethods\MBWay\MBWay;
use Buckaroo\PaymentMethods\Tinka\Tinka;
use Buckaroo\Exceptions\BuckarooException;
use Buckaroo\PaymentMethods\Afterpay\Afterpay;
use Buckaroo\PaymentMethods\AfterpayDigiAccept\AfterpayDigiAccept;
use Buckaroo\PaymentMethods\Alipay\Alipay;
use Buckaroo\PaymentMethods\ApplePay\ApplePay;
use Buckaroo\PaymentMethods\Bancontact\Bancontact;
use Buckaroo\PaymentMethods\BankTransfer\BankTransfer;
use Buckaroo\PaymentMethods\In3Old\In3Old;
use Buckaroo\PaymentMethods\Paypal\Paypal;
use Buckaroo\PaymentMethods\Sofort\Sofort;
use Buckaroo\PaymentMethods\Thunes\Thunes;
use Buckaroo\PaymentMethods\Belfius\Belfius;
use Buckaroo\PaymentMethods\Billink\Billink;
use Buckaroo\PaymentMethods\BuckarooVoucher\BuckarooVoucher;
use Buckaroo\PaymentMethods\BuckarooWallet\BuckarooWallet;
use Buckaroo\PaymentMethods\CreditCard\CreditCard;
use Buckaroo\PaymentMethods\CreditClick\CreditClick;
use Buckaroo\PaymentMethods\CreditManagement\CreditManagement;
use Buckaroo\PaymentMethods\Emandates\Emandates;
use Buckaroo\PaymentMethods\EPS\EPS;
use Buckaroo\PaymentMethods\MBWay\MBWay;
use Buckaroo\PaymentMethods\GiftCard\GiftCard;
use Buckaroo\PaymentMethods\Giropay\Giropay;
use Buckaroo\PaymentMethods\iDeal\iDeal;
use Buckaroo\PaymentMethods\iDealQR\iDealQR;
use Buckaroo\PaymentMethods\iDin\iDin;
use Buckaroo\PaymentMethods\In3\In3;
use Buckaroo\PaymentMethods\In3Old\In3Old;
use Buckaroo\PaymentMethods\KBC\KBC;
use Buckaroo\PaymentMethods\Surepay\Surepay;
use Buckaroo\PaymentMethods\Trustly\Trustly;
use Buckaroo\PaymentMethods\Afterpay\Afterpay;
use Buckaroo\PaymentMethods\ApplePay\ApplePay;
use Buckaroo\PaymentMethods\GiftCard\GiftCard;
use Buckaroo\PaymentMethods\KlarnaKP\KlarnaKP;
use Buckaroo\PaymentMethods\Payconiq\Payconiq;
use Buckaroo\PaymentMethods\Emandates\Emandates;
use Buckaroo\PaymentMethods\KlarnaPay\KlarnaPay;
use Buckaroo\PaymentMethods\Marketplaces\Marketplaces;
use Buckaroo\PaymentMethods\WeChatPay\WeChatPay;
use Buckaroo\PaymentMethods\Bancontact\Bancontact;
use Buckaroo\PaymentMethods\CreditCard\CreditCard;
use Buckaroo\PaymentMethods\Multibanco\Multibanco;
use Buckaroo\PaymentMethods\NoServiceSpecifiedPayment\NoServiceSpecifiedPayment;
use Buckaroo\PaymentMethods\Payconiq\Payconiq;
use Buckaroo\PaymentMethods\PaymentInitiation\PaymentInitiation;
use Buckaroo\PaymentMethods\Paypal\Paypal;
use Buckaroo\PaymentMethods\Przelewy24\Przelewy24;
use Buckaroo\PaymentMethods\CreditClick\CreditClick;
use Buckaroo\PaymentMethods\PayPerEmail\PayPerEmail;
use Buckaroo\PaymentMethods\PointOfSale\PointOfSale;
use Buckaroo\PaymentMethods\Przelewy24\Przelewy24;
use Buckaroo\PaymentMethods\SEPA\SEPA;
use Buckaroo\PaymentMethods\Sofort\Sofort;
use Buckaroo\PaymentMethods\BankTransfer\BankTransfer;
use Buckaroo\PaymentMethods\Marketplaces\Marketplaces;
use Buckaroo\PaymentMethods\Subscriptions\Subscriptions;
use Buckaroo\PaymentMethods\Surepay\Surepay;
use Buckaroo\PaymentMethods\Thunes\Thunes;
use Buckaroo\PaymentMethods\Tinka\Tinka;
use Buckaroo\PaymentMethods\Trustly\Trustly;
use Buckaroo\PaymentMethods\WeChatPay\WeChatPay;
use Buckaroo\Transaction\Client;
use Buckaroo\PaymentMethods\BuckarooWallet\BuckarooWallet;
use Buckaroo\PaymentMethods\BuckarooVoucher\BuckarooVoucher;
use Buckaroo\PaymentMethods\ExternalPayment\ExternalPayment;
use Buckaroo\PaymentMethods\CreditManagement\CreditManagement;
use Buckaroo\PaymentMethods\PaymentInitiation\PaymentInitiation;
use Buckaroo\PaymentMethods\AfterpayDigiAccept\AfterpayDigiAccept;
use Buckaroo\PaymentMethods\NoServiceSpecifiedPayment\NoServiceSpecifiedPayment;

class PaymentMethodFactory
{
Expand Down Expand Up @@ -107,6 +108,7 @@ class PaymentMethodFactory
PayPerEmail::class => ['payperemail'],
PaymentInitiation::class => ['paymentinitiation','paybybank'],
EPS::class => ['eps'],
ExternalPayment::class => ['externalpayment'],
Emandates::class => ['emandates'],
Sofort::class => ['sofort', 'sofortueberweisung'],
Tinka::class => ['tinka'],
Expand Down
56 changes: 56 additions & 0 deletions tests/Buckaroo/Payments/ExternalPaymentTest.php
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());
}
}

0 comments on commit 0dee2bf

Please sign in to comment.