Skip to content

Commit

Permalink
Merge branch 'master' into fix/php-related-issues
Browse files Browse the repository at this point in the history
  • Loading branch information
mralaminahamed committed Sep 23, 2024
2 parents 586b770 + 21b90ee commit 0268830
Show file tree
Hide file tree
Showing 10 changed files with 119 additions and 1 deletion.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
## [3.31.0] - 2024-07-30
### Added

1. New endpoint: [Create a Bancontact PayIn](https://mangopay.com/docs/endpoints/bancontact#create-bancontact-payin)

2. New parameter `PaymentCategory` for the following endpoints :
- [Create a Card Validation](https://mangopay.com/docs/endpoints/card-validations#create-card-validation)
- [Create a Direct Card PayIn](https://mangopay.com/docs/endpoints/direct-card-payins#create-direct-card-payin)
- [Create a Preauthorization](https://mangopay.com/docs/endpoints/preauthorizations#create-preauthorization)

## [3.30.0] - 2024-05-31
### Added

Expand Down
8 changes: 8 additions & 0 deletions MangoPay/CardPreAuthorization.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,14 @@ class CardPreAuthorization extends Libraries\EntityBase
*/
public $CardInfo;

/**
* Allowed values: ECommerce (default), TelephoneOrder
*
* The channel through which the user provided their card details, used to indicate mail-order and telephone-order (MOTO) payments.
* @var string
*/
public $PaymentCategory;

/**
* Get array with mapping which property is object and what type of object
* @return array
Expand Down
9 changes: 9 additions & 0 deletions MangoPay/CardValidation.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,15 @@ class CardValidation extends Libraries\EntityBase
* Get array with mapping which property is object and what type of object
* @return array
*/

/**
* Allowed values: ECommerce (default), TelephoneOrder
*
* The channel through which the user provided their card details, used to indicate mail-order and telephone-order (MOTO) payments.
* @var string
*/
public $PaymentCategory;

public function GetSubObjects()
{
$subObjects = parent::GetSubObjects();
Expand Down
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
2 changes: 1 addition & 1 deletion MangoPay/Libraries/RestTool.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*/
class RestTool
{
const VERSION = '3.30.0';
const VERSION = '3.31.0';

/**
* Root/parent instance that holds the OAuthToken and Configuration instance
Expand Down
9 changes: 9 additions & 0 deletions MangoPay/PayIn.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,14 @@ class PayIn extends Transaction
*/
public $Shipping;

/**
* Allowed values: ECommerce (default), TelephoneOrder
*
* The channel through which the user provided their card details, used to indicate mail-order and telephone-order (MOTO) payments.
* @var string
*/
public $PaymentCategory;

/**
* Get array with mapping which property depends on other property
* @return array
Expand All @@ -112,6 +120,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';
}
33 changes: 33 additions & 0 deletions tests/Cases/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -655,6 +655,7 @@ protected function getNewPayInCardDirect($userId = null)
$payIn->ExecutionDetails = new \MangoPay\PayInExecutionDetailsDirect();
$payIn->ExecutionDetails->SecureModeReturnURL = 'http://test.com';
$payIn->ExecutionDetails->Culture = 'FR';
$payIn->PaymentCategory = 'TelephoneOrder';

$address = new Address();
$address->AddressLine1 = 'Main Street no 5';
Expand Down Expand Up @@ -1014,6 +1015,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
18 changes: 18 additions & 0 deletions tests/Cases/PayInsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ public function test_PayIns_Create_CardDirect()
$this->assertEquals($wallet->Balance->Amount, $beforeWallet->Balance->Amount + $payIn->CreditedFunds->Amount);
$this->assertEquals(PayInStatus::Succeeded, $payIn->Status);
$this->assertEquals('PAYIN', $payIn->Type);
$this->assertEquals('TelephoneOrder', $payIn->PaymentCategory);

$this->assertNotNull($payIn->PaymentDetails->CardInfo);
$this->assertNotNull($payIn->PaymentDetails->CardInfo->BIN);
Expand Down Expand Up @@ -898,6 +899,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 0268830

Please sign in to comment.