Skip to content

Commit

Permalink
Merge pull request #611 from Mangopay/feature/ideal-and-giropay-mops
Browse files Browse the repository at this point in the history
feature /Added Ideal and Giropay mops
  • Loading branch information
iulian03 authored Nov 2, 2023
2 parents c45b0cb + c0e4264 commit 8e62d87
Show file tree
Hide file tree
Showing 7 changed files with 146 additions and 0 deletions.
2 changes: 2 additions & 0 deletions MangoPay/Libraries/ApiBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ protected function getLogger()
'payins_satispay-web_create' => ['/payins/payment-methods/satispay', RequestType::POST],
'payins_blik-web_create' => ['/payins/payment-methods/blik', RequestType::POST],
'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_recurring_registration' => ['/recurringpayinregistrations', RequestType::POST],
'payins_recurring_registration_get' => ['/recurringpayinregistrations/%s', RequestType::GET],
Expand Down
2 changes: 2 additions & 0 deletions MangoPay/PayIn.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ public function GetDependsObjects()
PayInPaymentType::Satispay => 'MangoPay\PayInPaymentDetailsSatispay',
PayInPaymentType::Blik => 'MangoPay\PayInPaymentDetailsBlik',
PayInPaymentType::Klarna => 'MangoPay\PayInPaymentDetailsKlarna',
PayInPaymentType::Ideal => 'MangoPay\PayInPaymentDetailsIdeal',
PayInPaymentType::Giropay => 'MangoPay\PayInPaymentDetailsGiropay',

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

namespace MangoPay;

/**
* Class represents Giropay type for mean of payment in Giropay entity
*/
class PayInPaymentDetailsGiropay extends Libraries\Dto implements PayInPaymentDetails
{
/**
* Custom description to show on the user's bank statement.
* It can be up to 10 char alphanumeric and space.
* @var string
*/
public $StatementDescriptor;
}
29 changes: 29 additions & 0 deletions MangoPay/PayInPaymentDetailsIdeal.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

namespace MangoPay;

/**
* Class represents IDEAL type for mean of payment in IDEAL entity
*/
class PayInPaymentDetailsIdeal extends Libraries\Dto implements PayInPaymentDetails
{
/**
* The BIC identifier of the end-user’s bank
* @var string
*/
public $Bic;

/**
* Name of the end-user’s bank
* @var string
*/
public $BankName;


/**
* Custom description to show on the user's bank statement.
* It can be up to 10 char alphanumeric and space.
* @var string
*/
public $StatementDescriptor;
}
2 changes: 2 additions & 0 deletions MangoPay/PayInPaymentType.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,6 @@ class PayInPaymentType
const Satispay = 'SATISPAY';
const Blik = 'BLIK';
const Klarna = 'KLARNA';
const Ideal = 'IDEAL';
const Giropay = 'GIROPAY';
}
61 changes: 61 additions & 0 deletions tests/Cases/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -968,6 +968,67 @@ protected function getNewPayInKlarnaWeb($userId = null)
return $this->_api->PayIns->Create($payIn);
}

protected function getNewPayInIdealWeb($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\PayInPaymentDetailsIdeal();
$payIn->PaymentDetails->Bic = 'REVOLT21';
$payIn->PaymentDetails->StatementDescriptor = 'test';

// 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->Tag = "Ideal tag";

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

protected function getNewPayInGiropayWeb($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\PayInPaymentDetailsGiropay();
$payIn->PaymentDetails->StatementDescriptor = 'test';

// 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->Tag = "Giropay tag";

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

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

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

$this->assertNotNull($payIn->Id > 0);
$this->assertEquals(\MangoPay\PayInPaymentType::Ideal, $payIn->PaymentType);
$this->assertInstanceOf('\MangoPay\PayInPaymentDetailsIdeal', $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_PayIns_Create_Giropay_Web()
{
$payIn = $this->getNewPayInGiropayWeb();

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

// /**
// * @throws \Exception
// */
Expand Down

0 comments on commit 8e62d87

Please sign in to comment.