Establishing a Session
The first step of a Hosted Checkout transaction is to send an API request to the Mastercard Gateway using the INITIATE CHECKOUT operation. The request creates a checkout session in the gateway, and must include:
- Details related to the PAY, AUTHORIZE, or VERIFY transaction you want to create.
- Information about how the Hosted Payment Page must interact with the payer.
- Instructions for completing the Hosted Payment Page process.
- For all parameters and request body fields supported for the request, see Initiate Checkout.
- For API v62 and earlier, use the CREATE CHECKOUT SESSION operation instead of Initiate Checkout.
The following example shows a cURL code snippet for the INITIATE CHECKOUT request.
URL | curl --location https://test-nbkpayment.mtf.gateway.mastercard.com/api/rest/version/72/merchant/<merchant_ID>/session'\ |
--header 'Content-Type: text/plain' \ --header 'Authorization: Basic <base64-encoded string of "merchant.<merchant ID>:<password>"' \ --data ' { "apiOperation": "INITIATE_CHECKOUT", "interaction":{ "operation" :"AUTHORIZE", "merchant": { "name": "<merchant_name>" } }, "order": { "currency":"USD", "amount": "100.00", "id" : "<order_ID>", "description": "<description_of_order>" } } '
A successful INITIATE CHECKOUT response contains the session.id and successIndicator fields. Check the successIndicator field value to verify the success or failure of the payment. For details, see Obtaining the Payment Result.