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 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.
- 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.
The sample below shows a test batch input file for a merchant using password as the authentication mechanism to connect to Mastercard Gateway.
apiOperation,order.id,order.currency,transaction.id,transaction.amount,transaction.currency,sourceOfFunds.type,sourceOfFunds.provided.card.number,sourceOfFunds.provided.card.expiry.month,sourceOfFunds.provided.card.expiry.year,response.gatewayCode,result,error.cause,error.explanation,error.field,error.supportCode,error.validationType PAY,921830104177,TXID1,30,AUD,CARD,5123456789012346,05,17,,,,, PAY,921830104178,TXID1,100,AUD,CARD,5123456789012346,05,17,,,,, PAY,921830104179,TXID1,50,AUD,CARD,4987654321098769,05,17,,,,, PAY,921830104180,TXID1,90,AUD,CARD,4987654321098769,05,17,,,,, PAY,921830104181,TXID1,45,AUD,CARD,345678xxxxx4564,05,17,,,,, PAY,921830104182,TXID1,75,AUD,CARD,345678xxxxx4564,05,17,,,,, PAY,936742085167,AUD,TX1,30.00,AUD,CARD,5123456xxxxxx346,05,21,,,, PAY,936742085168,AUD,TX1,35.00,AUD,CARD,5123456xxxxxx346,05,21,,,,
Sample code for a basic Batch integration has been included in the example code. See Downloads.
The next step is sending the batch request.