Skip to content

Commit

Permalink
BP-3020 Add payment method "Multibanco" (#148)
Browse files Browse the repository at this point in the history
* BP-3020 Add payment method "Multibanco"

* fix tests

---------

Co-authored-by: Ivascu Madalin <[email protected]>
  • Loading branch information
harli91 and Ivascu Madalin authored Oct 20, 2023
1 parent eefdf3e commit 568ff22
Show file tree
Hide file tree
Showing 4 changed files with 108 additions and 0 deletions.
21 changes: 21 additions & 0 deletions example/transactions/multibanco.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('multibanco')->pay([
'invoice' => uniqid(),
'amountDebit' => 10.10,
]);

//Refund
$response = $buckaroo->method('multibanco')->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/Multibanco/Multibanco.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 [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
*/

declare(strict_types=1);

namespace Buckaroo\PaymentMethods\Multibanco;

use Buckaroo\PaymentMethods\PayablePaymentMethod;

class Multibanco extends PayablePaymentMethod
{
protected string $paymentName = 'Multibanco';
}
2 changes: 2 additions & 0 deletions src/PaymentMethods/PaymentMethodFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
use Buckaroo\PaymentMethods\KlarnaKP\KlarnaKP;
use Buckaroo\PaymentMethods\KlarnaPay\KlarnaPay;
use Buckaroo\PaymentMethods\Marketplaces\Marketplaces;
use Buckaroo\PaymentMethods\Multibanco\Multibanco;
use Buckaroo\PaymentMethods\NoServiceSpecifiedPayment\NoServiceSpecifiedPayment;
use Buckaroo\PaymentMethods\Payconiq\Payconiq;
use Buckaroo\PaymentMethods\PaymentInitiation\PaymentInitiation;
Expand Down Expand Up @@ -96,6 +97,7 @@ class PaymentMethodFactory
In3Old::class => ['in3old'],
KlarnaPay::class => ['klarna', 'klarnain'],
KlarnaKP::class => ['klarnakp'],
Multibanco::class => ['multibanco'],
MBWay::class => ['mbway'],
Surepay::class => ['surepay'],
Subscriptions::class => ['subscriptions'],
Expand Down
55 changes: 55 additions & 0 deletions tests/Buckaroo/Payments/MultibancoTest.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 [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 MultibancoTest extends BuckarooTestCase
{
/**
* @return void
* @test
*/
public function it_creates_a_multibanco_payment()
{
$response = $this->buckaroo->method('multibanco')->pay([
'invoice' => uniqid(),
'amountDebit' => 10.10,
]);

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

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

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

0 comments on commit 568ff22

Please sign in to comment.