API Mercadopago: How to generate a new Payment Token, after a "payment" rejected


Testing in Sandbox environment, I have an app that generates a "payment token", which I then send to the server to generate the "payment".
The scenario is during the test of error messages:

  • I try insufficient funds, I add FUND in front of the name
  • I receive the corresponding error, until here everything is correct.
  • change to test expiration, add EXPI before the name.
  • gives me error 400, bad_request, complete error message: "could not update the Card with the following id: b67f82b44375001c136081b3b392f1f7 because it has been used or expired"
  • I understand that the token can only be used once and apparently the API wants to update it, when in fact it should generate a new one.

    Any ideas that I should be doing wrong?

    asked by guillefd 19.02.2017 в 07:01

    1 answer


    Mercadopago's documentation is incomplete and not very clear.

    But by reviewing the Mercadopago class of the JavaScript SDK, you can see a prototype called clearSession (), which effectively does what is expected.

    // limpiar sesion, luego de "payment" rechazado
    // validar que el usuario no utilice los mismos datos rechazados.
    // generar nuevo token luego de pago rechazado
    Mercadopago.createToken(form, callback);
    // procesar nuevamente el pago
    answered by 19.02.2017 в 15:07