Create the Transaction Request

Creating the body of the request is a critical step in the merchant integration. The form fields from the payer-facing form together with your configuration fields are submitted to the Mastercard Payment GatewayAPI URL using HTTPS POST/PUT/GET depending on the chosen protocol (REST-JSON/NVP) and the transaction operation.

The payer-facing form must only ever expose those fields that require input from the payer.

Your integration must not expose all the fields provided in the example HTML forms. Values for fields such as Order ID, Transaction ID, Version, and Merchant ID must be calculated within your code.

Sample HTML forms for basic operations such as authorize, capture, refund, and pay have been included in the example code. See Downloads.

Formatting Data for the Transaction Request

Regardless of your language or protocol, it is important that your integration formats the transaction request data or body correctly. In many languages it is common to receive the data entered by a payer in a Form as an array. In most cases, it is then suitable to use an array to store the field names and values for each field you intend to pass to the Mastercard Payment Gateway and format it as demonstrated below.

The below code snippets complete two critical functions to result in a correctly formatted transaction request body:

  1. Ensure no empty or blank fields are added to the transaction request body.
  2. Format the data to the requirements of each protocol (Name-value-pair for NVP or JSON for REST)
This page includes sample code snippets. Choose an interface and language, then click Update Code Snippets.

How to Convert Form Data to , Change Download

This code snippet shows how to convert form data to .
         Select Protocol and Language to view Code Snippet.

From: Sample Code Download  

Copyright © 2023 Mastercard