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 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.
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 Gateway and format it as demonstrated below.
The below code snippets complete two critical functions to result in a correctly formatted transaction request body:
- Ensure no empty or blank fields are added to the transaction request body.
- Format the data to the requirements of each protocol (Name-value-pair for NVP or JSON for REST)
How to Convert Form Data to
(, ) ChangeSelect Protocol and Language to view Code Snippet.
From: Sample Code Download