Closed jeromebsr closed 2 years ago
Hi @jeromebsr ,
Without seing more code, I am afraid this is going to be hard to help you. What does your form look like ? What is your payment.php page look like ? Are you using the demo version page or did you write it yourself ? What is $MangoPay here ? An instance of the API ? A private function you made ? If you inspect the form before posting, what values does it contain ?
Hi, thanks for helping !
$MangoPay is an instance of the API yes
Below the form :
<form action="https://homologation-webpayment.payline.com/webpayment/getToken" method="post">
<input type="hidden" name="data" value="HBalUf7sKsj1NiktfVS7-9RiveAa4JGn2indtKf-VbObgqcZn45OEIucSV1B8d5R2ddFLVXdicolcUIkv_kKEA">
<input type="hidden" name="accessKeyRef" value="1X0m87dmM2LiwFgxPLBJ">
<input type="hidden" name="returnURL" value="https:/mywebsite.com/payment">
<label for="cardNumber">Card Number</label>
<input type="text" name="cardNumber" value="4972485830400056">
<div class="clear"></div>
<label for="cardExpirationDate">Expiration Date</label>
<input type="text" name="cardExpirationDate" value="1124">
<div class="clear"></div>
<label for="cardCvx">CVV</label>
<input type="text" name="cardCvx" value="245">
<div class="clear"></div>
<input type="submit" value="Pay">
</form>
payment.php is the same page as in the demo : https://github.com/Mangopay/mangopay2-php-sdk/blob/master/demos/paymentDirect/payment.php
the problem appears when I want to do the update (line 4)
// update register card with registration data from Payline service
$cardRegister = $mangoPayApi->CardRegistrations->Get($_SESSION['cardRegisterId']);
$cardRegister->RegistrationData = isset($_GET['data']) ? 'data=' . $_GET['data'] : 'errorCode=' . $_GET['errorCode'];
$updatedCardRegister = $mangoPayApi->CardRegistrations->Update($cardRegister);
dump($cardRegister);
dump($updatedCardRegister);
if ($updatedCardRegister->Status != \MangoPay\CardRegistrationStatus::Validated || !isset($updatedCardRegister->CardId)) {
die('<div style="color:red;">Cannot create card. Payment has not been created.<div>');
}
[...]
The first dump of $cardRegister (line 5) :
The second dump of $updatedCardRegister (line 6) :
As you can see the Status change from "CREATED" to "ERROR" with ResultMessage : "Token input Error" (code 105299) and I need it to be " VALIDATED" to not to fall into the "die" case.
I hope I brought enough informations :)
@jeromebsr,
From what you show me, I don't see anything wrong. My best guess here is that $_SESSION['cardRegisterId'] may not holding the correct value. The page holding the form, is a custom page you made or are you doing this test with the demo file (non_js.php) ?
@H4wKs,
What I pass in the $_SESSION seems correct, I made a dump of :
$createdCardRegister->Id;
The value of $createdCardRegister->Id is the same as $_SESSION['cardRegisterId'];
The page holding the form, is a custom page you made or are you doing this test with the demo file (non_js.php) ?
The same as demo file
UPDATE : I solve the problem, I had moved a piece of code in an object to return the values of the form (the prints) and this is apparently the problem... I don't really understand why
Hello @jeromebsr, could you share the update code please :).
Thank you @H4wKs for your great help as usual.
Hello @fredericdelordm
The code is exactly the same as in the demo :) I tried with a custom object and the error came from there, so I restored as in the demo.
Thanks @H4wKs for the help !
Hello,
I am using PHP and on the payment.php page I get a "Token input error" (105299) in the "CardRegistration" object when updating. I do not understand why, I use the code as provided with the dynamic form
<form action="<?php print $MangoPay->createCardRegistration()->CardRegistrationURL; ?>" method="post">
If anyone can help me that would be great! :)