Introduction

Any time a request must be made to Merchant Warrior, a POST request will be made to the URL that you have set as your middleware option. Your middleware needs to support the following Merchant Warrior methods by taking the input, inserting any appropriate missing information (such as hashes) and making a request to the Merchant Warrior API.

Methods

Each method displayed below shows a sample of the data that is submitted via POST to your middleware, and a sample of the output that is returned back to the Web SDK.

getMerchantSession

Input

{
    "method": "getMerchantSession",
    "endpoint": " https://base.merchantwarrior.com/",
    "accessToken": " c82f7e5988fff6a439d0f43e6",
    "validationURL": "https://apple-pay-gateway-cert.apple.com/paymentservices/startSession",
    "domainName": "your.domain.com"
}

Output

{
    "responseCode": "0",
    "responseMessage": "Operation successful",
    "merchantSession": "{\"epochTimestamp\":1640236968964,\"expiresAt\":1640240568964,\"merchantSessionIdentifier\":\"SSHAE01E8377CFE46F2939FC7455BC491BF_916523AAED1343F5BC5815E12BEE9250AFFDC1A17C46B0DE5A943F0F94927C24\",\"nonce\":\"42635849\",\"merchantIdentifier\":\"2E93A3CD36CF5AF27A2A686C3AFE2EADCB0F74FBC3F1787D50CE51B40331C74F\",\"domainName\":\"your.domain.com\",\"displayName\":\"Widgets Pty Ltd\",\"signature\":\"<a very long string goes here>\",\"retries\":0}"
}

processCard

Input

{
    "method": "processCard",
    "endpoint": "https://base.merchantwarrior.com/",
    "accessToken": "c82f7e5988fff6a439d0f43e6",
    "transactionAmount": "13.00",
    "transactionCurrency": "AUD",
    "transactionProduct": "Basic Charge",
    "digitalWalletToken": "{\"data\":\"<a very long string goes here>\"},\"version\":\"EC_v1\"}",
    "customerName": "Jim Bob",
    "customerCountry": "US",
    "customerState": "QLD",
    "customerCity": "Brisbane",
    "customerAddress": "345 Ann Street",
    "customerPostCode": "4000",
    "customerPhone": "61412345678"
}

Output

{
    "responseCode": "0",
    "responseMessage": "Transaction approved",
    "transactionID": "1842-6ad84688-63b0-11ec-a43d-005056b2764e",
    "authCode": "7022993835",
    "receiptNo": "007022993835",
    "authMessage": "Honour with identification",
    "authResponseCode": "08",
    "authSettledDate": "2021-12-23",
    "transactionReferenceID": {},
    "custom1": {},
    "custom2": {},
    "custom3": {},
    "customHash": "1a3c3572c764e3f4b212e90a94419ea5",
    "paymentCardNumber": "520424XXXXXX6937",
    "transactionAmount": "13.00",
    "feeAmount": "0.00",
    "cardType": "mc",
    "cardExpiryMonth": "09",
    "cardExpiryYear": "22"
}
Promise

Alternatively, this value can be set to a Javascript function. This function accepts a single parameter, a JSON object containing a valid API request, and should return a promise containing a JSON object of the Merchant Warrior server response.

const options = {
    middleware: function(request) {
        return new Promise((resolve, reject) => {
            // Handle request
        });
    }
}