Mangopay / mangopay2-php-sdk

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

Problem recurring payment #553

Closed Maximus697 closed 2 years ago

Maximus697 commented 2 years ago

Hi,

I'm trying to set up recurring payment on my site except I have the SDK returning to me: Bad request. One or several required parameters are missing or incorrect. An incorrect resource ID also raises this kind of error.

$PayIn = new \MangoPay\PayInRecurringRegistration(); $PayIn->CreditedWalletId = $mp_wallet_id; $PayIn->AuthorId = $mp_client_id; $PayIn->FirstTransactionDebitedFunds = new \MangoPay\Money(); $PayIn->FirstTransactionDebitedFunds->Currency = $currency; $PayIn->FirstTransactionDebitedFunds->Amount = $amount; $PayIn->FirstTransactionFees = new \MangoPay\Money(); $PayIn->FirstTransactionFees->Currency = $currency; $PayIn->FirstTransactionFees->Amount = $fees; $PayIn->EndDate = $endDate; $PayIn->Frequency = $frequency; $PayIn->CardId = $card_id;

$result = $this->mangoPayApi->PayIns->CreateRecurringRegistration($PayIn);

What is bad?

Thank you

H4wKs commented 2 years ago

Hi @Maximus697,

It's hard to say without knowing the value set in your PayIn object. Can you provide a dump of $PayIn just before calling the MangoPayApi ?

Also, getting the API detailed error message would help you understand the exact problem.

I would suggest you to do the following :

try {
   $result = $this->mangoPayApi->PayIns->CreateRecurringRegistration($PayIn);
} catch (Exception $e) {
   //dump or log the value of 
   // $e->GetErrorDetails()->Message and get_object_vars($e->GetErrorDetails()->Errors)
}