mercadopago / checkout-payment-sample

Using Checkout PRO to process payments
148 stars 135 forks source link

/feedback Route #1

Closed brunomrosa closed 3 years ago

brunomrosa commented 3 years ago

What is the purpose of the route on the nodejs server? It only returns what is send on the query params. I plan to use React on the frontend soo, can someone explain what does the line below does?

script.dataset.preferenceId = preference;

leandrobrunner commented 3 years ago

Hey @theoriginalkaiju, if you check on the /create_preference route, the /feedback endpoint is used as return url, and works as reference for the developer, to check what params are returning by MP depending of the payment status; you can set any other url or customize the current endpoint depending of your requirements.

https://github.com/mercadopago/checkout-payment-sample/blob/5a6bf354d59e0a7a42f213fa7f98c860e0baa837/server/node/server.js#L25

Regarding your second question, script.dataset.preferenceId = preference; allows to the embedded script to access to the linked data, in this case the preference Id.

Dataset api reference: https://developer.mozilla.org/en-US/docs/Web/API/HTMLOrForeignElement/dataset