Search code examples
paymentmastercard

Mastercard Hosted Checkout Integration


I am trying to integrate the hosted checkout with MasterCard. I would like to provide a complete callback URL to the payment request. According to the documentation, for your callback to be notified on payment success/failure, you should create a session and provide the session id in the checkout.configure object. I have been able to generate the session but when i pass the session id, i get the following error when i try to pay.

{
    "cause": "INVALID_REQUEST",
    "explanation": "Value '46' is invalid. The version used for this request must match the version previously used to update the session using the UPDATE_SESSION operation or OPEN_WALLET operation.",
    "field": "version",
    "validationType": "INVALID"
}

Kindly assist if you can.


Solution

  • You've created a session using Create Checkout Session operation. For this operation, the API URL would be: https://na-gateway.mastercard.com/api/nvp/version/<version-number>.

    The version number in the above URL must match the version number in the checkout.js file:

     <script src="https://na-gateway.mastercard.com/checkout/version/<version-number>/checkout.js"
                data-error="errorCallback"
                data-cancel="cancelCallback">
     </script>