Mangopay / mangopay2-php-sdk

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

Error registration data but it's a good format #513

Closed Geoffray-buhler closed 3 years ago

Geoffray-buhler commented 3 years ago

When i send my registration data to update Registration data on mangopay server i have this response : image

so i see my format of Registration data is not good but in mangopay documentations : https://docs.mangopay.com/endpoints/v2.01/cards#e1042_post-card-info

there is a exemple of format : image

and i send this : image

So i don't understand where is the problem with my registration data format

H4wKs commented 3 years ago

Hi @Geoffray-buhler, I am not 100% sure of the problem, but I believe you submit for the RegistrationData a Json array object that look like this:

{
"RegistrationData" : "data=EFOIJZfzeOfjzeR3ZIEFJdsFIEJFEOIFJzeFIJZEFZ....",
}

While you should submit a string that look like this "data=EFOIJZfzeOfjzeR3ZIEFJdsFIEJFEOIFJzeFIJZEFZ...." So you want to have this:

$cardRegister->RegistrationData = "data=EFOIJZfzeOfjzeR3ZIEFJdsFIEJFEOIFJzeFIJZEFZ...."

instead of

$cardRegister->RegistrationData = "{
"RegistrationData" : "data=EFOIJZfzeOfjzeR3ZIEFJdsFIEJFEOIFJzeFIJZEFZ....",
}"

If you want / can share the code, that would be more easy to spot the problem unless this message help you catch / fix the issue.

Geoffray-buhler commented 3 years ago

You are right it will be necessary to change the format of the string, I put the code if it can help someone ^^

if (isset($_GET['data'])) {
            $CardRegistration = $session->get('CardRegistration');
            $CardRegistration->Id = $session->get('PreRegistrationId');
            $CardRegistration->RegistrationData = 'data='.$_GET['data'];

and the result : succes

thank you once again ^^

H4wKs commented 3 years ago

My pleasure @Geoffray-buhler