Skip to content

Commit

Permalink
Merge pull request #619 from Mangopay/improvement/add_parameter_to_id…
Browse files Browse the repository at this point in the history
…eal_endpoint

improvement/ Added new parameters to legacy IDEAL payin
  • Loading branch information
iulian03 committed Dec 7, 2023
2 parents db8110b + 4f29586 commit 5c5e468
Show file tree
Hide file tree
Showing 9 changed files with 77 additions and 12 deletions.
15 changes: 9 additions & 6 deletions MangoPay/ApiInstantConversion.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,18 @@ class ApiInstantConversion extends Libraries\ApiBase
* @param string $creditedCurrency The buy currency – the currency of the wallet to be credited.
* @return \MangoPay\ConversionRate object returned from API
*/
public function GetConversionRate($debitedCurrency, $creditedCurrency){
return $this->GetObject('get_conversion_rate', '\MangoPay\ConversionRate', $debitedCurrency, $creditedCurrency);
}
public function GetConversionRate($debitedCurrency, $creditedCurrency)
{
return $this->GetObject('get_conversion_rate', '\MangoPay\ConversionRate', $debitedCurrency, $creditedCurrency);
}

/**
* This endpoint allows the platform to move funds between two
* wallets of different currencies instantaneously.
* @return \MangoPay\InstantConversion object returned from API
*/
public function CreateInstantConversion($instantConversion){
public function CreateInstantConversion($instantConversion)
{
return $this->CreateObject('create_instant_conversion', $instantConversion, '\MangoPay\InstantConversion');
}

Expand All @@ -34,7 +36,8 @@ public function CreateInstantConversion($instantConversion){
* @param string $id The unique identifier of the conversion.
* @return \MangoPay\InstantConversion object returned from API
*/
public function GetInstantConversion($id){
public function GetInstantConversion($id)
{
return $this->GetObject('get_instant_conversion', '\MangoPay\InstantConversion', $id);
}
}
}
2 changes: 1 addition & 1 deletion MangoPay/ConversionRate.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ class ConversionRate extends Libraries\EntityBase
* @var string
*/
public $MarketRate;
}
}
2 changes: 1 addition & 1 deletion MangoPay/InstantConversion.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,4 @@ class InstantConversion extends Libraries\EntityBase
* @var int
*/
public $ExecutionDate;
}
}
10 changes: 10 additions & 0 deletions MangoPay/PayInPaymentDetailsCard.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,14 @@ class PayInPaymentDetailsCard extends Libraries\Dto implements PayInPaymentDetai
* @var string
*/
public $Reference;

/**
* @var string
*/
public $Bic;

/**
* @var string
*/
public $BankName;
}
2 changes: 1 addition & 1 deletion MangoPay/PayInPaymentDetailsGiropay.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ class PayInPaymentDetailsGiropay extends Libraries\Dto implements PayInPaymentDe
* @var string
*/
public $StatementDescriptor;
}
}
2 changes: 1 addition & 1 deletion MangoPay/PayInPaymentDetailsIdeal.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ class PayInPaymentDetailsIdeal extends Libraries\Dto implements PayInPaymentDeta
* @var string
*/
public $StatementDescriptor;
}
}
35 changes: 35 additions & 0 deletions tests/Cases/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -968,6 +968,41 @@ protected function getNewPayInKlarnaWeb($userId = null)
return $this->_api->PayIns->Create($payIn);
}

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

$payIn = new \MangoPay\PayIn();
$payIn->PaymentType = "CARD";
$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\PayInPaymentDetailsCard();
$payIn->PaymentDetails->Bic = 'REVOLT21';
$payIn->PaymentDetails->CardType = 'IDEAL';
$payIn->PaymentDetails->StatementDescriptor = 'test';

$payIn->ExecutionType = \MangoPay\PayInExecutionType::Web;
// 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 = "EN";

$payIn->Tag = "Ideal tag";

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

protected function getNewPayInIdealWeb($userId = null)
{
$wallet = $this->getJohnsWalletWithMoney();
Expand Down
5 changes: 3 additions & 2 deletions tests/Cases/InstantConversionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ public function test_getInstantConversion()
$this->assertSame(TransactionType::Conversion, $returnedInstantConversion->Type);
}

private function createInstantConversion() {
private function createInstantConversion()
{
$john = $this->getJohn();
$creditedWallet = new \MangoPay\Wallet();
$creditedWallet->Owners = [$john->Id];
Expand Down Expand Up @@ -69,4 +70,4 @@ private function createInstantConversion() {

return $this->_api->InstantConversion->CreateInstantConversion($instantConversion);
}
}
}
16 changes: 16 additions & 0 deletions tests/Cases/PayInsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use MangoPay\PayInExecutionType;
use MangoPay\PayInPaymentDetails;
use MangoPay\PayInPaymentDetailsBankWire;
use MangoPay\PayInPaymentDetailsCard;
use MangoPay\PayInPaymentType;
use MangoPay\PayInRecurringRegistrationUpdate;
use MangoPay\PayInStatus;
Expand Down Expand Up @@ -832,6 +833,21 @@ public function test_PayIns_Create_KlarnaWeb()
$this->assertEquals($payIn->Id, $fetchedPayIn->Id);
}

public function test_PayIns_Create_Legacy_IdealWeb()
{
$payIn = $this->getLegacyPayInIdealWeb();

$this->assertNotNull($payIn->Id > 0);
$this->assertEquals(\MangoPay\PayInPaymentType::Card, $payIn->PaymentType);
$this->assertInstanceOf('\MangoPay\PayInPaymentDetailsCard', $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);
$this->assertNotNull($payIn->PaymentDetails->BankName);
}

public function test_PayIns_Create_IdealWeb()
{
$payIn = $this->getNewPayInIdealWeb();
Expand Down

0 comments on commit 5c5e468

Please sign in to comment.