MPGS Hosted Checkout frame not loading

145 views Asked by At

I'm facing a problem making MPGS Hosted Checkout work.

I followed their simple guide in this link: https://eu-gateway.mastercard.com/api/documentation/integrationGuidelines/hostedCheckout/integrationModelHostedCheckout.html

I Created a Session using a POST request to: https://cibpaynow.gateway.mastercard.com/api/rest/version/71/merchant/TESTCIB70****/session With this body:

{
    "apiOperation": "INITIATE_CHECKOUT",
    "interaction": {
        "operation": "PURCHASE",
        "returnUrl": "localhost:3000/good.html",
        "cancelUrl": "localhost:3000/bad.html",
        "merchant": {

                        "name": "NOTFOUND",
                        "address": {
                            "line1": "200 Sample St",
                            "line2": "1234 Example Town"            
                        }    
                    }
    },
    "order": 
    {
        "amount": 1.5,
        "currency": "EGP",
        "id": "28"
    }
}

And then took the session id and added to my try.html page:

<html>
    <head>
        <script src="https://cibpaynow.gateway.mastercard.com/static/checkout/checkout.js" data-error="errorCallback" data-cancel="cancelCallback"></script>
        <script>
            setTimeout(() =>{
                Checkout.configure({
                    session: { 
                        id: 'SESSION0002471324664N3861280I36'
                    },
            });
            Checkout.showEmbeddedPage('#embed-target');
            }, 1000);
        </script>
    </head>
    <body>
       ...
      <div id="embed-target"> </div> 
      <input type="button" value="Pay with Embedded Page" onclick="Checkout.showEmbeddedPage('#embed-target');" />
      <input type="button" value="Pay with Payment Page" onclick="Checkout.showLightBox();" />
       ...
    </body>
</html>

When I run the page, the window shows up as loading, but never appears.

reference: try.html

and in the console I get this error when opening the html from my pc:

tps://cibpaynow.gateway.mastercard.com/api/page/version/71/pay 400
u @ landing.js:2
a @ landing.js:2
await in a (async)
(anonymous) @ landing.js:2
(anonymous) @ landing.js:2
ch

And this error when running the file from a vercel server: https://cib-gateway.vercel.app/try.html

checkout.min.js:2 Uncaught TypeError: Failed to construct 'URL': Invalid URL
    at Ny.value (checkout.min.js:2:273435)
    at Ny.redirect (checkout.min.js:2:272637)
    at Ny.value (checkout.min.js:2:273337)
    at Ny.errorHandler (checkout.min.js:2:271657)
    at Object.callback (checkout.min.js:2:281517)
    at checkout.min.js:2:260249
    at Array.forEach (<anonymous>)
    at checkout.min.js:2:260217
0

There are 0 answers