Create Batch Request

Creating the batch request is a critical step in the merchant integration. A batch request consists of a batch file in Native Format, which the Batch service accepts and submits to the Mastercard Payment GatewayBatch URL using HTTPS PUT.

The Native Format is defined as follows:

  • The HTTP header must specify basic authentication and include your integration password base64 encoded.
  • The character encoding of your request must include only ISO-8859-1(Latin1), or UTF-8 formats. See Ensure Character Encoding.
  • Batch files must be supplied in the comma delimited CSV format and take into account the following processing restrictions:
    • Comments should not be included as they are not supported.
    • Values are not trimmed of leading or trailing spaces.
    • Embedded commas should be handled by enclosing the value in quotes.
    • Embedded double quotes should be handled by enclosing the value in quotes, and then representing it by a pair of double quotes.
    • There is a maximum value length of 100,000 characters per line.
    • Each batch file should contain a single header row with values that correspond to the API NVP protocol field names. See NVP Reference.
    • Fields within the data file must obey the API validation rules (field length and format, mandatory, unique value, etc).
    • Records for all transaction types (authorizations, purchases, captures, refunds, voids) may be provided within a file. However, ensure that the transaction types are NOT related to the same order, i.e., they do not contain the same order identifier. For more information, see Best Practices and Tips.

    The sample below shows a test batch input file for a merchant using password as the authentication mechanism to connect to Mastercard Payment Gateway.


  • Both the request and response fields must be defined in the batch request. When preparing your integration, you should spend some time examining the response parameters for each relevant operation in the API Reference to decide which fields to include in the request. All of these fields provide valuable information, and many of which you may wish to store locally for accounting, reconciliation, troubleshooting and traceability reason.

Sample code for a basic Batch integration has been included in the example code. See Downloads.

Copyright © 2023 Mastercard