Skip to content

Commit

Permalink
BP-3034 Add payment method "MB WAY"
Browse files Browse the repository at this point in the history
  • Loading branch information
Ivascu Madalin committed Oct 17, 2023
1 parent 3755554 commit 8ce79fc
Show file tree
Hide file tree
Showing 4 changed files with 108 additions and 0 deletions.
21 changes: 21 additions & 0 deletions example/transactions/mbway.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

require('../bootstrap.php');

use Buckaroo\BuckarooClient;

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

//Also accepts json
//Pay
$response = $buckaroo->method('mbway')->pay([
'invoice' => uniqid(),
'amountDebit' => 10.10,
]);

//Refund
$response = $buckaroo->method('mbway')->refund([
'invoice' => '', //Set invoice number of the transaction to refund
'originalTransactionKey' => '', //Set transaction key of the transaction to refund
'amountCredit' => 10.10,
]);
30 changes: 30 additions & 0 deletions src/PaymentMethods/MBPay/MBWay.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\EPS;

use Buckaroo\PaymentMethods\PayablePaymentMethod;

class MBWay extends PayablePaymentMethod
{
protected string $paymentName = 'MBWay';
}
2 changes: 2 additions & 0 deletions src/PaymentMethods/PaymentMethodFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
use Buckaroo\PaymentMethods\CreditManagement\CreditManagement;
use Buckaroo\PaymentMethods\Emandates\Emandates;
use Buckaroo\PaymentMethods\EPS\EPS;
use Buckaroo\PaymentMethods\EPS\MBWay;
use Buckaroo\PaymentMethods\GiftCard\GiftCard;
use Buckaroo\PaymentMethods\Giropay\Giropay;
use Buckaroo\PaymentMethods\iDeal\iDeal;
Expand Down Expand Up @@ -95,6 +96,7 @@ class PaymentMethodFactory
In3Old::class => ['in3old'],
KlarnaPay::class => ['klarna', 'klarnain'],
KlarnaKP::class => ['klarnakp'],
MBWay::class => ['mbway'],
Surepay::class => ['surepay'],
Subscriptions::class => ['subscriptions'],
SEPA::class => ['sepadirectdebit', 'sepa'],
Expand Down
55 changes: 55 additions & 0 deletions tests/Buckaroo/Payments/MBWayTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?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 MBWayTest extends BuckarooTestCase
{
/**
* @return void
* @test
*/
public function it_creates_a_mbway_payment()
{
$response = $this->buckaroo->method('mbway')->pay([
'invoice' => uniqid(),
'amountDebit' => 10.10,
]);

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

/**
* @test
*/
public function it_creates_a_mbway_refund()
{
$response = $this->buckaroo->method('mbway')->refund([
'amountCredit' => 10,
'invoice' => 'testinvoice 123',
'description' => 'refund',
'originalTransactionKey' => '2D04704995B74D679AACC59F87XXXXXX',
]);

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

0 comments on commit 8ce79fc

Please sign in to comment.