Closed Geoffray-buhler closed 3 years ago
Hello @Geoffray-buhler,
I would suggest to use the following tests as an example :
Hi @Geoffray-buhler ,
You have a working example in the demos directory. Checkout out: https://github.com/Mangopay/mangopay2-php-sdk/blob/master/demos/paymentDirect/non_js.php https://github.com/Mangopay/mangopay2-php-sdk/blob/master/demos/paymentDirect/payment.php Cheers,
Thank you so much. That work now but i have a new error and i don't understand why but my card is register in mangopay Bdd ^^ 👍 👍 👍 But in my App
@Geoffray-buhler the error does not say much. What are you trying to do? Could you share your code?
So i just follow this docs
https://github.com/Mangopay/mangopay2-php-sdk/blob/master/demos/paymentDirect/non_js.php https://github.com/Mangopay/mangopay2-php-sdk/blob/master/demos/paymentDirect/payment.php
After the creation of card i get it and
Controller : ` $user = $this->getUser();
$cardRegister = $mangoservices->GetCardRegistrations($_SESSION['cardRegisterId']);
$cardRegister->RegistrationData = isset($_GET['data']) ? 'data=' . $_GET['data'] : 'errorCode=' . $_GET['errorCode'];
$updatedCardRegister = $mangoservices->UpdateCard($cardRegister);
`
ServiceMangopay :
public function UpdateCard($card) { $cardInfo = $this->mangoPayApi->CardRegistrations->Update($card); return $cardInfo; }
i just want to update my card without error ^^
@Geoffray-buhler,
So it look like there may be an issue with the SDK parsing the error, but that's not the problem here anyway, something must be wrong with the data you submitted.
Can you provide a dump of $cardInfo just before you return it. Maybe you can add a try / catch when you calling CardRegistrations->Update and provide a dump of the exception itself.
Also, I wouldn't use $_GET and $_SESSION as you are using Symfony, I would rather go by
$request->query->get('data')
and use the session interface to store / get the session info
Honestly thank you for your time ! i use $_GET and $_SESSION it's just for debug and understand ^^ so this is the data submitted
i can't dump $cardInfo because they is a error before that .
You need to dump the exception to really understand what is wrong ServiceMangopay :
public function UpdateCard($card) {
try {
$cardInfo = $this->mangoPayApi->CardRegistrations->Update($card);
} catch (Exception $e) {
$cardInfo = null;
dump($e);
}
return $cardInfo;
}
i replaced my code with yours but i have the same thing
result :
i don't catch any Exeptions
I never had this issue with the SDK, but same problem as here https://github.com/Mangopay/mangopay2-php-sdk/issues/500 I would probably dump $error inside the SDK and / or comment the foreach just to understand both why your ApiCall end up on a 400 instead of 200 code, and at the same time give feedback on what is wrong in the handling of the error at the SDK level.
Ok thank you i will try to get $error and dump it. So i'm beginner ^^
Ho i dump $error
Result:
So my card is already processed that is good so i must fix this possibility ^^
Thank you for your help and your time @H4wKs and @fredericdelordm
Best regards
You're welcome @Geoffray-buhler
What version of PHP are you running ?
I use PHP 7.4.2 actually.
I submitted a PR #508 to fix the warning issued in RestTools when the $error->Errors is null like in your case, that should help in the future :)
I saw your patch, i apply it but i have new error.
No it's ok i don't know why but it's ok ^^
Hi so i want to create a card for make a payin but i don't understande how i supposed to do
in first time i create a Cardregistration with this API like that
Controller :
if ($form->isSubmitted() && $form->isValid()) { $montant = $form->getData(); $montant = $montant['Montant']; $formdata = $form->getData(); $card = new CardRegistration; $card->UserId = $this->getUser()->getMangopayId(); $card->CardType = $formdata['Cardtype']; $card->Currency = $formdata['currency']; $result = $mangoservices->CreateCard($card); $PreregistrationData = $result->PreregistrationData; $CardRegistrationURL = $result->CardRegistrationURL; $CardNumber = $formdata['Number']; $CardCVV = $formdata['CVV']; $CardDate = '';
Services mangopay :
public function CreateCard($card) { $cardInfo = $this->mangoPayApi->CardRegistrations->Create($card); return $cardInfo; }
after i create a form to send my data to tokanisation's server like this
Twig : `