Skip to content

Commit

Permalink
implemented Bancontact PayIn method
Browse files Browse the repository at this point in the history
  • Loading branch information
Iulian Masar committed Jul 30, 2024
1 parent 20c10a0 commit 04ba4bb
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 0 deletions.
1 change: 1 addition & 0 deletions MangoPay/Libraries/ApiBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ protected function getLogger()
'payins_klarna-web_create' => ['/payins/payment-methods/klarna', RequestType::POST],
'payins_ideal-web_create' => ['/payins/payment-methods/ideal', RequestType::POST],
'payins_giropay-web_create' => ['/payins/payment-methods/giropay', RequestType::POST],
'payins_bancontact-web_create' => ['/payins/payment-methods/bancontact', RequestType::POST],
'add_tracking_info' => ['/payins/%s/trackings', RequestType::PUT],

'payment_method-metadata' => ['/payment-methods/metadata', RequestType::POST],
Expand Down
1 change: 1 addition & 0 deletions MangoPay/PayIn.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ public function GetDependsObjects()
PayInPaymentType::Klarna => 'MangoPay\PayInPaymentDetailsKlarna',
PayInPaymentType::Ideal => 'MangoPay\PayInPaymentDetailsIdeal',
PayInPaymentType::Giropay => 'MangoPay\PayInPaymentDetailsGiropay',
PayInPaymentType::Bancontact => 'MangoPay\PayInPaymentDetailsBancontact',

// ...and more in future...
],
Expand Down
28 changes: 28 additions & 0 deletions MangoPay/PayInPaymentDetailsBancontact.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

namespace MangoPay;

/**
* Class represents Bancontact type for mean of payment in Bancontact entity
*/
class PayInPaymentDetailsBancontact extends Libraries\Dto implements PayInPaymentDetails
{
/**
* The URL where you should redirect your client in a mobile app experience
* @var string
*/
public $DeepLinkURL;

/**
* Custom description to show on the user's bank statement.
* It can be up to 10 char alphanumeric and space.
* @var string
*/
public $StatementDescriptor;

/**
* Whether the Bancontact pay-ins are being made to be re-used in a recurring payment flow
* @var boolean
*/
public $Recurring;
}
2 changes: 2 additions & 0 deletions MangoPay/PayInPaymentType.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,6 @@ class PayInPaymentType
const Klarna = 'KLARNA';
const Ideal = 'IDEAL';
const Giropay = 'GIROPAY';

const Bancontact = 'BCMC';
}
32 changes: 32 additions & 0 deletions tests/Cases/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -1014,6 +1014,38 @@ protected function getNewPayInGiropayWeb($userId = null)
return $this->_api->PayIns->Create($payIn);
}

protected function getNewPayInBancontactWeb($userId = null)
{
$wallet = $this->getJohnsWalletWithMoney();
if (is_null($userId)) {
$user = $this->getJohn();
$userId = $user->Id;
}

$payIn = new \MangoPay\PayIn();
$payIn->AuthorId = $userId;
$payIn->CreditedWalletId = $wallet->Id;
$payIn->Fees = new \MangoPay\Money();
$payIn->Fees->Amount = 10;
$payIn->Fees->Currency = 'EUR';
$payIn->DebitedFunds = new \MangoPay\Money();
$payIn->DebitedFunds->Amount = 1000;
$payIn->DebitedFunds->Currency = 'EUR';

$payIn->PaymentDetails = new \MangoPay\PayInPaymentDetailsBancontact();
$payIn->PaymentDetails->StatementDescriptor = 'test';
$payIn->PaymentDetails->Recurring = true;

// execution type as WEB
$payIn->ExecutionDetails = new \MangoPay\PayInExecutionDetailsWeb();
$payIn->ExecutionDetails->ReturnURL = "http://www.my-site.com/returnURL?transactionId=wt_71a08458-b0cc-468d-98f7-1302591fc238";
$payIn->ExecutionDetails->Culture = 'FR';

$payIn->Tag = "Bancontact tag";

return $this->_api->PayIns->Create($payIn);
}

/**
* Creates Pay-In Card Direct object
* @return \MangoPay\PayIn
Expand Down
17 changes: 17 additions & 0 deletions tests/Cases/PayInsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -898,6 +898,23 @@ public function test_PayIns_Create_Giropay_Web()
$this->assertEquals($payIn->Id, $fetchedPayIn->Id);
}

public function test_PayIns_Create_Bancontact_Web()
{
$payIn = $this->getNewPayInBancontactWeb();

$this->assertNotNull($payIn->Id > 0);
$this->assertEquals(\MangoPay\PayInPaymentType::Bancontact, $payIn->PaymentType);
$this->assertInstanceOf('\MangoPay\PayInPaymentDetailsBancontact', $payIn->PaymentDetails);
$this->assertEquals(\MangoPay\PayInExecutionType::Web, $payIn->ExecutionType);
$this->assertInstanceOf('\MangoPay\PayInExecutionDetailsWeb', $payIn->ExecutionDetails);
$this->assertEquals(PayInStatus::Created, $payIn->Status);
$this->assertEquals('PAYIN', $payIn->Type);
$this->assertEquals('REGULAR', $payIn->Nature);

$fetchedPayIn = $this->_api->PayIns->Get($payIn->Id);
$this->assertEquals($payIn->Id, $fetchedPayIn->Id);
}

public function test_CardDirect_getPaymentMethodMetadata()
{
$payin = $this->getNewPayInCardDirect();
Expand Down

0 comments on commit 04ba4bb

Please sign in to comment.