Mangopay / mangopay2-php-sdk

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

3DS2 - Can't pass IpAddress and BrowserInfo #499

Closed johann-arias closed 3 years ago

johann-arias commented 3 years ago

Hello,

I'm having an issue passing the IpAddress and BrowserInfo when creating a Direct Pay In

Here's what I'm doing for the IpAddress (full code below) :

$payIn->PaymentDetails = new \MangoPay\PayInPaymentDetailsCard();

$payIn->PaymentDetails->IpAddress = $ipAddress;

$createdPayIn = $this->mangoPayApi->PayIns->Create($payIn);

And I'm getting :

[2021-06-15T07:48:53.172531+00:00] app.ERROR: "stdClass":1:{s:9:"IpAddress";s:32:"The IpAddress field is mandatory";}Bad request. One or several required parameters are missing or incorrect. An incorrect resource ID also raises this kind of error. [] []

Thanks for your help, Johann @ Kudurace

$payIn = new \MangoPay\PayIn();
$payIn->CreditedWalletId = $orgWalletId;
$payIn->AuthorId = $userId;
$payIn->DebitedFunds = new \MangoPay\Money();
$payIn->DebitedFunds->Amount = $amount;
$payIn->DebitedFunds->Currency = "EUR";
$payIn->Fees = new \MangoPay\Money();
$payIn->Fees->Amount = max(0.04 * $amount, 9);
$payIn->Fees->Currency = "EUR";
$payIn->PaymentDetails = new \MangoPay\PayInPaymentDetailsCard();
$payIn->PaymentDetails->CardId = $cardId;
$payIn->ExecutionDetails = new \MangoPay\PayInExecutionDetailsDirect();
$payIn->ExecutionDetails->SecureModeReturnURL = $returnUrl;

$payIn->Requested3DSVersion = 'V2_1';

$payIn->PaymentDetails->IpAddress = $ipAddress;

$payIn->PaymentDetails->BrowserInfo = new \MangoPay\BrowserInfo();
$payIn->PaymentDetails->BrowserInfo->AcceptHeader = $acceptHeader;
$payIn->PaymentDetails->BrowserInfo->JavaEnabled = $javaEnabled;
$payIn->PaymentDetails->BrowserInfo->Language = $language;
$payIn->PaymentDetails->BrowserInfo->ColorDepth = $colorDepth;
$payIn->PaymentDetails->BrowserInfo->ScreenHeight = $screenHeight;
$payIn->PaymentDetails->BrowserInfo->ScreenWidth = $screenWidth;
$payIn->PaymentDetails->BrowserInfo->TimeZoneOffset = $timeZoneOffset;
$payIn->PaymentDetails->BrowserInfo->UserAgent = $userAgent;
$payIn->PaymentDetails->BrowserInfo->JavascriptEnabled = true;

$createdPayIn = $this->mangoPayApi->PayIns->Create($payIn);

return $createdPayIn;
H4wKs commented 3 years ago

Hi, It looks good so far, and my best guess at this point is that your $ipAddress value is empty at this point, but without more information that's hard to say for sure. You can either do a dump of the $payIn value just before you do the $this->mangoPayApi->PayIns->Create($payIn); You can also try to replace in your code : $payIn->PaymentDetails->IpAddress = $ipAddress; by a hardcoded value: $payIn->PaymentDetails->IpAddress = '192.168.0.1'; and see if that work. If it work, that would also confirm what I initially said.

johann-arias commented 3 years ago

Thanks, my format was indeed wrong !