Mangopay / mangopay2-php-sdk

PHP SDK for MANGOPAY
https://packagist.org/packages/mangopay/php-sdk-v2
MIT License
122 stars 133 forks source link

International bank transfer example code #368

Closed amitpachauri87 closed 4 years ago

amitpachauri87 commented 4 years ago

We are integrating International Bank Transfer into my website but I didn't find any example code like how we need to integrate using PHP SDK. Can you please help us or provide some example code https://docs.mangopay.com/endpoints/v2.01/payins#e287_the-bankwire-direct-payin-object

Riwak commented 4 years ago

Hello @amitpachauri87

Sure 🙂 ! Here is a sample :

// Get user+wallet info
$wallet = $this->getJohnsWallet();
$user = $this->getJohn();

// create pay-in BANKWIRE DIRECT
$payIn = new \MangoPay\PayIn();
$payIn->CreditedWalletId = $wallet->Id;
$payIn->AuthorId = $user->Id;

// PaymentType as card
$payIn->PaymentDetails = new \MangoPay\PayInPaymentDetailsBankWire();
$payIn->PaymentDetails->DeclaredDebitedFunds = new \MangoPay\Money();
$payIn->PaymentDetails->DeclaredDebitedFunds->Amount = 10000;
$payIn->PaymentDetails->DeclaredDebitedFunds->Currency = 'EUR';
$payIn->PaymentDetails->DeclaredFees = new \MangoPay\Money();
$payIn->PaymentDetails->DeclaredFees->Amount = 0;
$payIn->PaymentDetails->DeclaredFees->Currency = 'EUR';
$payIn->ExecutionDetails = new \MangoPay\PayInExecutionDetailsDirect();
$payIn->ExecutionDetails->Culture = "FR";

// Executing the PayIn.
$createPayIn = $this->_api->PayIns->Create($payIn);

By the way, you can find useful code samples in the test folder of the SDK (https://github.com/Mangopay/mangopay2-php-sdk/tree/master/tests/cases). Don't hesitate if you have any question,

Best regards,