Payment Agreements

A payment agreement can be created utilising an allowed payment instrument type (currently only debit cards, credit cards and PayPal are supported instrument types for payment agreements) when saved in the customer's wallet. When one of these allowed payment instrument types has been tokenized in your customer's wallet you are able to create a payment agreement.

Create a Payment Agreement

Utilising a saved payment instrument you can create a payment agreement which will allow you to charge the agreement when required based on your billing cycle.

Payment agreements can only be created with instruments that are saved to the customer's wallet and cannot be created using single-use instruments.

📘

Scheduled Payments

Note that metadata captured as part of the payment agreement such as the charge frequency and amounts do not result in charges automatically being processed by Wpay. As the merchant you will need invoke the charge at the desired date to process the payment.

curl --location --request POST 'https://{{environment}}.wpay.com.au/wow/v1/pay/instore/customer/payments/agreements' \
--header 'Content-Type: application/json' \
--header 'X-Api-Key: {{yourApiKey}}' \
--header 'Authorization: Bearer {{yourBearerToken}}' \
--data-raw '{
    "data": {
    		"clientReference": "UNIQUE_CLIENT_REFERENCE",
    		"orderNumber": "UNIQUE_ORDER_NO",
        "customerRef": "12345",
        "description": "Description for Recurring Payment",
        "billingAddress": {
            "firstName": "John",
            "lastName": "Doe",
            "email": "[email protected]",
            "company": "Wpay",
            "extendedAddress": "4th Floor",
            "streetAddress": "407 Elizabeth Street",
            "suburb": "Surry Hills",
            "stateOrTerritory": "NSW",
            "postalCode": "2010",
            "countryCode": "AU"
        },
        "paymentAgreement": {
            "paymentInstrumentId": "215726",
            "type": "RECURRING",
            "startDate": "2022-09-01T00:00:00.000+1100",
            "endDate": "2023-12-31T23:59:59.999+1100",
            "chargeFrequency": "WEEKLY",
            "chargeAmount": 25.99,
            "immediateCharge": true
        }
    },
    "meta": {
        "fraud": {
            "provider": "cybersource",
            "version": "CyberSourceTransaction_1.101",
            "format": "XML",
            "responseFormat": "XML",
            "message": "<?xml version=\"1.0\" encoding=\"Windows-1252\"?>\r\n<RequestMessage xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\r\n  <merchantID>woolworths_online</merchantID>\r\n  <merchantReferenceCode>1234-26IO8JUN</merchantReferenceCode>\r\n  <billTo>\r\n    <firstName>Raja</firstName>\r\n    <lastName>Saravanan</lastName>\r\n    <street1>210</street1>\r\n    <city>MINTO</city>\r\n    <state>NSW</state>\r\n    <postalCode>2566</postalCode>\r\n    <country>AU</country>\r\n    <phoneNumber>0469813438</phoneNumber>\r\n    <email>[email protected]</email>\r\n    <ipAddress>202.39.218.236</ipAddress>\r\n    <dateOfBirth>1987-02-14</dateOfBirth>\r\n    <customerID>3732442</customerID>\r\n  </billTo>\r\n  <shipTo>\r\n    <firstName>Raja</firstName>\r\n    <lastName>Saravanan</lastName>\r\n    <phoneNumber>0442911234</phoneNumber>\r\n    <email>[email protected]</email>\r\n  </shipTo>\r\n  <item id=\"0\">\r\n    <unitPrice>7.59</unitPrice>\r\n    <quantity>2</quantity>\r\n    <productName>Mccain Protein Plus Frozen Meal Satay Chicken</productName>\r\n    <productSKU>483660</productSKU>\r\n  </item>\r\n  <item id=\"1\">\r\n    <unitPrice>2.00</unitPrice>\r\n    <quantity>2</quantity>\r\n    <productName>Habee Savers Needles Household Repair</productName>\r\n    <productSKU>159489</productSKU>\r\n  </item>\r\n  <item id=\"2\">\r\n    <unitPrice>6.60</unitPrice>\r\n    <quantity>5</quantity>\r\n    <productName>Chicken Breast Fillet Skinless Small</productName>\r\n    <productSKU>118963</productSKU>\r\n  </item>\r\n  <item id=\"3\">\r\n    <unitPrice>5.43</unitPrice>\r\n    <quantity>5</quantity>\r\n    <productName>Chicken Drumsticks </productName>\r\n    <productSKU>169014</productSKU>\r\n  </item>\r\n  <item id=\"4\">\r\n    <unitPrice>3.50</unitPrice>\r\n    <quantity>4</quantity>\r\n    <productName>Chicken Thigh Cutlets Skinless</productName>\r\n    <productSKU>166830</productSKU>\r\n  </item>\r\n  <item id=\"5\">\r\n    <unitPrice>10.80</unitPrice>\r\n    <quantity>4</quantity>\r\n    <productName>Lamb Diced Heart Smart</productName>\r\n    <productSKU>208970</productSKU>\r\n  </item>\r\n  <item id=\"6\">\r\n    <unitPrice>4.94</unitPrice>\r\n    <quantity>2</quantity>\r\n    <productName>Macro Chicken Lovely Legs Free Range</productName>\r\n    <productSKU>700257</productSKU>\r\n  </item>\r\n  <item id=\"7\">\r\n    <unitPrice>19.64</unitPrice>\r\n    <quantity>2</quantity>\r\n    <productName>Macro Organic Whole Chicken</productName>\r\n    <productSKU>229320</productSKU>\r\n  </item>\r\n  <item id=\"8\">\r\n    <unitPrice>9.60</unitPrice>\r\n    <quantity>2</quantity>\r\n    <productName>Msa Australian Beef Steak Porterhouse</productName>\r\n    <productSKU>208988</productSKU>\r\n  </item>\r\n  <item id=\"9\">\r\n    <unitPrice>15.20</unitPrice>\r\n    <quantity>3</quantity>\r\n    <productName>Roast Pork Shoulder Boneless Small</productName>\r\n    <productSKU>203420</productSKU>\r\n  </item>\r\n  <item id=\"10\">\r\n    <unitPrice>10.80</unitPrice>\r\n    <quantity>2</quantity>\r\n    <productName>Select Corned Beef Silverside </productName>\r\n    <productSKU>148345</productSKU>\r\n  </item>\r\n  <item id=\"11\">\r\n    <unitPrice>13.00</unitPrice>\r\n    <quantity>2</quantity>\r\n    <productName>Clairol Nice N Easy 114a Natural Lightest Golden Brown</productName>\r\n    <productSKU>226536</productSKU>\r\n  </item>\r\n  <purchaseTotals>\r\n    <currency>AUD</currency>\r\n    <grandTotalAmount>298.09</grandTotalAmount>\r\n  </purchaseTotals>\r\n  <merchantDefinedData>\r\n    <mddField id=\"19\">Pickup</mddField>\r\n    <mddField id=\"10\">NO</mddField>\r\n    <mddField id=\"3\">Woolworths WOLLI CREEK, WOLLI CREEK</mddField>\r\n    <mddField id=\"1\">2017-09-22 16:00</mddField>\r\n    <mddField id=\"2\">NSW</mddField>\r\n    <mddField id=\"12\">NO</mddField>\r\n    <mddField id=\"16\">103</mddField>\r\n    <mddField id=\"23\"></mddField>\r\n    <mddField id=\"17\">2017-09-18 12:40</mddField>\r\n    <mddField id=\"18\">2017-09-18 12:40</mddField>\r\n    <mddField id=\"25\">2017-09-22 16:00</mddField>\r\n    <mddField id=\"20\">WEB</mddField>\r\n    <mddField id=\"57\">Normal</mddField>\r\n    <mddField id=\"58\"></mddField>\r\n    <mddField id=\"59\" />\r\n    <mddField id=\"60\">298.09</mddField>\r\n  </merchantDefinedData>\r\n  <afsService run=\"true\" />\r\n  <deviceFingerprintID>18SJBB-26IO8JUN</deviceFingerprintID>\r\n</RequestMessage>"
        },
        "challengeResponses": [
            {
                "instrumentId": "215726",
                "type": "STEP_UP",
                "token": "tokenise-stepup-token"
            }
        ]
    }
}'
var myHeaders = new Headers();
var environment = "substitute environment-value here"
var yourAPIkey = "YOUR-API-KEY";
var accessToken = "ACCESS-TOKEN";
myHeaders.append("Content-Type", "application/json");
myHeaders.append("X-Api-Key", yourAPIkey);
myHeaders.append("Authorization", `Bearer ${accessToken}`);

var raw = JSON.stringify({
    "data": {
    		"clientReference": "UNIQUE_CLIENT_REFERENCE",
    		"orderNumber": "UNIQUE_ORDER_NO",
        "customerRef": "12345",
        "billingAddress": {
            "firstName": "John",
            "lastName": "Doe",
            "email": "[email protected]",
            "company": "Wpay",
            "extendedAddress": "4th Floor",
            "streetAddress": "407 Elizabeth Street",
            "suburb": "Surry Hills",
            "stateOrTerritory": "NSW",
            "postalCode": "2010",
            "countryCode": "AU"
        },
        "paymentAgreement": {
            "paymentInstrumentId": "215726",
            "type": "RECURRING",
            "startDate": "2022-09-01T00:00:00.000+1100",
            "endDate": "2023-12-31T23:59:59.999+1100",
            "chargeFrequency": "WEEKLY",
            "chargeAmount": 25.99,
            "description": "Description for Recurring Payment"
        }
    },
    "meta": {
        "fraud": {
            "provider": "cybersource",
            "version": "CyberSourceTransaction_1.101",
            "format": "XML",
            "responseFormat": "XML",
            "message": "<?xml version=\"1.0\" encoding=\"Windows-1252\"?>\r\n<RequestMessage xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\r\n  <merchantID>woolworths_online</merchantID>\r\n  <merchantReferenceCode>1234-26IO8JUN</merchantReferenceCode>\r\n  <billTo>\r\n    <firstName>Raja</firstName>\r\n    <lastName>Saravanan</lastName>\r\n    <street1>210</street1>\r\n    <city>MINTO</city>\r\n    <state>NSW</state>\r\n    <postalCode>2566</postalCode>\r\n    <country>AU</country>\r\n    <phoneNumber>0469813438</phoneNumber>\r\n    <email>[email protected]</email>\r\n    <ipAddress>202.39.218.236</ipAddress>\r\n    <dateOfBirth>1987-02-14</dateOfBirth>\r\n    <customerID>3732442</customerID>\r\n  </billTo>\r\n  <shipTo>\r\n    <firstName>Raja</firstName>\r\n    <lastName>Saravanan</lastName>\r\n    <phoneNumber>0442911234</phoneNumber>\r\n    <email>[email protected]</email>\r\n  </shipTo>\r\n  <item id=\"0\">\r\n    <unitPrice>7.59</unitPrice>\r\n    <quantity>2</quantity>\r\n    <productName>Mccain Protein Plus Frozen Meal Satay Chicken</productName>\r\n    <productSKU>483660</productSKU>\r\n  </item>\r\n  <item id=\"1\">\r\n    <unitPrice>2.00</unitPrice>\r\n    <quantity>2</quantity>\r\n    <productName>Habee Savers Needles Household Repair</productName>\r\n    <productSKU>159489</productSKU>\r\n  </item>\r\n  <item id=\"2\">\r\n    <unitPrice>6.60</unitPrice>\r\n    <quantity>5</quantity>\r\n    <productName>Chicken Breast Fillet Skinless Small</productName>\r\n    <productSKU>118963</productSKU>\r\n  </item>\r\n  <item id=\"3\">\r\n    <unitPrice>5.43</unitPrice>\r\n    <quantity>5</quantity>\r\n    <productName>Chicken Drumsticks </productName>\r\n    <productSKU>169014</productSKU>\r\n  </item>\r\n  <item id=\"4\">\r\n    <unitPrice>3.50</unitPrice>\r\n    <quantity>4</quantity>\r\n    <productName>Chicken Thigh Cutlets Skinless</productName>\r\n    <productSKU>166830</productSKU>\r\n  </item>\r\n  <item id=\"5\">\r\n    <unitPrice>10.80</unitPrice>\r\n    <quantity>4</quantity>\r\n    <productName>Lamb Diced Heart Smart</productName>\r\n    <productSKU>208970</productSKU>\r\n  </item>\r\n  <item id=\"6\">\r\n    <unitPrice>4.94</unitPrice>\r\n    <quantity>2</quantity>\r\n    <productName>Macro Chicken Lovely Legs Free Range</productName>\r\n    <productSKU>700257</productSKU>\r\n  </item>\r\n  <item id=\"7\">\r\n    <unitPrice>19.64</unitPrice>\r\n    <quantity>2</quantity>\r\n    <productName>Macro Organic Whole Chicken</productName>\r\n    <productSKU>229320</productSKU>\r\n  </item>\r\n  <item id=\"8\">\r\n    <unitPrice>9.60</unitPrice>\r\n    <quantity>2</quantity>\r\n    <productName>Msa Australian Beef Steak Porterhouse</productName>\r\n    <productSKU>208988</productSKU>\r\n  </item>\r\n  <item id=\"9\">\r\n    <unitPrice>15.20</unitPrice>\r\n    <quantity>3</quantity>\r\n    <productName>Roast Pork Shoulder Boneless Small</productName>\r\n    <productSKU>203420</productSKU>\r\n  </item>\r\n  <item id=\"10\">\r\n    <unitPrice>10.80</unitPrice>\r\n    <quantity>2</quantity>\r\n    <productName>Select Corned Beef Silverside </productName>\r\n    <productSKU>148345</productSKU>\r\n  </item>\r\n  <item id=\"11\">\r\n    <unitPrice>13.00</unitPrice>\r\n    <quantity>2</quantity>\r\n    <productName>Clairol Nice N Easy 114a Natural Lightest Golden Brown</productName>\r\n    <productSKU>226536</productSKU>\r\n  </item>\r\n  <purchaseTotals>\r\n    <currency>AUD</currency>\r\n    <grandTotalAmount>298.09</grandTotalAmount>\r\n  </purchaseTotals>\r\n  <merchantDefinedData>\r\n    <mddField id=\"19\">Pickup</mddField>\r\n    <mddField id=\"10\">NO</mddField>\r\n    <mddField id=\"3\">Woolworths WOLLI CREEK, WOLLI CREEK</mddField>\r\n    <mddField id=\"1\">2017-09-22 16:00</mddField>\r\n    <mddField id=\"2\">NSW</mddField>\r\n    <mddField id=\"12\">NO</mddField>\r\n    <mddField id=\"16\">103</mddField>\r\n    <mddField id=\"23\"></mddField>\r\n    <mddField id=\"17\">2017-09-18 12:40</mddField>\r\n    <mddField id=\"18\">2017-09-18 12:40</mddField>\r\n    <mddField id=\"25\">2017-09-22 16:00</mddField>\r\n    <mddField id=\"20\">WEB</mddField>\r\n    <mddField id=\"57\">Normal</mddField>\r\n    <mddField id=\"58\"></mddField>\r\n    <mddField id=\"59\" />\r\n    <mddField id=\"60\">298.09</mddField>\r\n  </merchantDefinedData>\r\n  <afsService run=\"true\" />\r\n  <deviceFingerprintID>18SJBB-26IO8JUN</deviceFingerprintID>\r\n</RequestMessage>"
        },
        "challengeResponses": [
            {
                "instrumentId": "215726",
                "type": "STEP_UP",
                "token": "tokenise-stepup-token"
            }
        ]
    }
});

var requestOptions = {
  method: 'POST',
  headers: myHeaders,
  body: raw,
  redirect: 'follow'
};

fetch(`https://${environment}.wpay.com.au/wow/v1/pay/instore/customer/payments/agreements`, requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));
import Foundation
#if canImport(FoundationNetworking)
import FoundationNetworking
#endif

var semaphore = DispatchSemaphore (value: 0)

let yourAPIkey = "YOUR-API-KEY";
let environment = "substitute environment-value here"
let accessToken = "ACCESS-TOKEN";
let parameters = """
{\
  \"data\": {\
      \"clientReference\": \"UNIQUE_CLIENT_REFERENCE\",\
      \"orderNumber\": \"UNIQUE_ORDER_NO\",\
      \"customerRef\": \"12345\",\
      \"billingAddress\": {\
          \"firstName\": \"John\",\
          \"lastName\": \"Doe\",\
          \"email\": \"[email protected]\",\
          \"company\": \"Wpay\",\
          \"extendedAddress\": \"4th Floor\",\
          \"streetAddress\": \"407 Elizabeth Street\",\
          \"suburb\": \"Surry Hills\",\
          \"stateOrTerritory\": \"NSW\",\
          \"postalCode\": \"2010\",\
          \"countryCode\": \"AU\"\
      },\
      \"paymentAgreement\": {\
          \"paymentInstrumentId\": \"215726\",\
          \"type\": \"RECURRING\",\
          \"startDate\": \"2022-09-01T00:00:00.000+1100\",\
          \"endDate\": \"2023-12-31T23:59:59.999+1100\",\
          \"chargeFrequency\": \"WEEKLY\",\
          \"chargeAmount\": 25.99,\
          \"description\": \"Description for Recurring Payment\"\
      }\
  },\
  \"meta\": {\
      \"fraud\": {\
          \"provider\": \"cybersource\",\
          \"version\": \"CyberSourceTransaction_1.101\",\
          \"format\": \"XML\",\
          \"responseFormat\": \"XML\",\
          \"message\": \"<?xml version=\\"1.0\\" encoding=\\"Windows-1252\\"?>\r\n<RequestMessage xmlns:xsd=\\"http://www.w3.org/2001/XMLSchema\\" xmlns:xsi=\\"http://www.w3.org/2001/XMLSchema-instance\\">\r\n  <merchantID>woolworths_online</merchantID>\r\n  <merchantReferenceCode>1234-26IO8JUN</merchantReferenceCode>\r\n  <billTo>\r\n    <firstName>Raja</firstName>\r\n    <lastName>Saravanan</lastName>\r\n    <street1>210</street1>\r\n    <city>MINTO</city>\r\n    <state>NSW</state>\r\n    <postalCode>2566</postalCode>\r\n    <country>AU</country>\r\n    <phoneNumber>0469813438</phoneNumber>\r\n    <email>[email protected]</email>\r\n    <ipAddress>202.39.218.236</ipAddress>\r\n    <dateOfBirth>1987-02-14</dateOfBirth>\r\n    <customerID>3732442</customerID>\r\n  </billTo>\r\n  <shipTo>\r\n    <firstName>Raja</firstName>\r\n    <lastName>Saravanan</lastName>\r\n    <phoneNumber>0442911234</phoneNumber>\r\n    <email>[email protected]</email>\r\n  </shipTo>\r\n  <item id=\\"0\\">\r\n    <unitPrice>7.59</unitPrice>\r\n    <quantity>2</quantity>\r\n    <productName>Mccain Protein Plus Frozen Meal Satay Chicken</productName>\r\n    <productSKU>483660</productSKU>\r\n  </item>\r\n  <item id=\\"1\\">\r\n    <unitPrice>2.00</unitPrice>\r\n    <quantity>2</quantity>\r\n    <productName>Habee Savers Needles Household Repair</productName>\r\n    <productSKU>159489</productSKU>\r\n  </item>\r\n  <item id=\\"2\\">\r\n    <unitPrice>6.60</unitPrice>\r\n    <quantity>5</quantity>\r\n    <productName>Chicken Breast Fillet Skinless Small</productName>\r\n    <productSKU>118963</productSKU>\r\n  </item>\r\n  <item id=\\"3\\">\r\n    <unitPrice>5.43</unitPrice>\r\n    <quantity>5</quantity>\r\n    <productName>Chicken Drumsticks </productName>\r\n    <productSKU>169014</productSKU>\r\n  </item>\r\n  <item id=\\"4\\">\r\n    <unitPrice>3.50</unitPrice>\r\n    <quantity>4</quantity>\r\n    <productName>Chicken Thigh Cutlets Skinless</productName>\r\n    <productSKU>166830</productSKU>\r\n  </item>\r\n  <item id=\\"5\\">\r\n    <unitPrice>10.80</unitPrice>\r\n    <quantity>4</quantity>\r\n    <productName>Lamb Diced Heart Smart</productName>\r\n    <productSKU>208970</productSKU>\r\n  </item>\r\n  <item id=\\"6\\">\r\n    <unitPrice>4.94</unitPrice>\r\n    <quantity>2</quantity>\r\n    <productName>Macro Chicken Lovely Legs Free Range</productName>\r\n    <productSKU>700257</productSKU>\r\n  </item>\r\n  <item id=\\"7\\">\r\n    <unitPrice>19.64</unitPrice>\r\n    <quantity>2</quantity>\r\n    <productName>Macro Organic Whole Chicken</productName>\r\n    <productSKU>229320</productSKU>\r\n  </item>\r\n  <item id=\\"8\\">\r\n    <unitPrice>9.60</unitPrice>\r\n    <quantity>2</quantity>\r\n    <productName>Msa Australian Beef Steak Porterhouse</productName>\r\n    <productSKU>208988</productSKU>\r\n  </item>\r\n  <item id=\\"9\\">\r\n    <unitPrice>15.20</unitPrice>\r\n    <quantity>3</quantity>\r\n    <productName>Roast Pork Shoulder Boneless Small</productName>\r\n    <productSKU>203420</productSKU>\r\n  </item>\r\n  <item id=\\"10\\">\r\n    <unitPrice>10.80</unitPrice>\r\n    <quantity>2</quantity>\r\n    <productName>Select Corned Beef Silverside </productName>\r\n    <productSKU>148345</productSKU>\r\n  </item>\r\n  <item id=\\"11\\">\r\n    <unitPrice>13.00</unitPrice>\r\n    <quantity>2</quantity>\r\n    <productName>Clairol Nice N Easy 114a Natural Lightest Golden Brown</productName>\r\n    <productSKU>226536</productSKU>\r\n  </item>\r\n  <purchaseTotals>\r\n    <currency>AUD</currency>\r\n    <grandTotalAmount>298.09</grandTotalAmount>\r\n  </purchaseTotals>\r\n  <merchantDefinedData>\r\n    <mddField id=\\"19\\">Pickup</mddField>\r\n    <mddField id=\\"10\\">NO</mddField>\r\n    <mddField id=\\"3\\">Woolworths WOLLI CREEK, WOLLI CREEK</mddField>\r\n    <mddField id=\\"1\\">2017-09-22 16:00</mddField>\r\n    <mddField id=\\"2\\">NSW</mddField>\r\n    <mddField id=\\"12\\">NO</mddField>\r\n    <mddField id=\\"16\\">103</mddField>\r\n    <mddField id=\\"23\\"></mddField>\r\n    <mddField id=\\"17\\">2017-09-18 12:40</mddField>\r\n    <mddField id=\\"18\\">2017-09-18 12:40</mddField>\r\n    <mddField id=\\"25\\">2017-09-22 16:00</mddField>\r\n    <mddField id=\\"20\\">WEB</mddField>\r\n    <mddField id=\\"57\\">Normal</mddField>\r\n    <mddField id=\\"58\\"></mddField>\r\n    <mddField id=\\"59\\" />\r\n    <mddField id=\\"60\\">298.09</mddField>\r\n  </merchantDefinedData>\r\n  <afsService run=\\"true\\" />\r\n  <deviceFingerprintID>18SJBB-26IO8JUN</deviceFingerprintID>\r\n</RequestMessage>\"\
      },\
      \"challengeResponses\": [\
          {\
              \"instrumentId\": \"215726\",\
              \"type\": \"STEP_UP\",\
              \"token\": \"tokenise-stepup-token\"\
          }\
      ]\
  }\
}\
"""
let postData = parameters.data(using: .utf8)

var request = URLRequest(
  url: URL(string: "https://\(environment).wpay.com.au/wow/v1/pay/instore/customer/payments/agreements")!,
  timeoutInterval: Double.infinity
)
request.addValue("application/json", forHTTPHeaderField: "Content-Type")
request.addValue(yourAPIkey, forHTTPHeaderField: "X-Api-Key")
request.addValue("Bearer \(accessToken)", forHTTPHeaderField: "Authorization")

request.httpMethod = "POST"
request.httpBody = postData

let task = URLSession.shared.dataTask(with: request) { data, response, error in 
  guard let data = data else {
    print(String(describing: error))
    semaphore.signal()
    return
  }
  print(String(data: data, encoding: .utf8)!)
  semaphore.signal()
}

task.resume()
semaphore.wait()
var environment = "substitute environment-value here"
var yourAPIkey = "YOUR-API-KEY";
var accessToken = "ACCESS-TOKEN";
      
val response = khttp.post(
  url = "https://$environment" + 
        ".wpay.com.au/wow/v1/pay/instore/customer/payments/agreements",
  headers = mapOf("Content-Type" to "application/json",
                  "X-Api-Key" to yourAPIkey,
                  "Authorization" to "Bearer $accessToken"),
  json = mapOf(
    "data" to mapOf(
    		"clientReference" to "UNIQUE_CLIENT_REFERENCE",
    		"orderNumber" to "UNIQUE_ORDER_NO",
        "customerRef" to "12345",
        "billingAddress" to mapOf(
            "firstName" to "John",
            "lastName" to "Doe",
            "email" to "[email protected]",
            "company" to "Wpay",
            "extendedAddress" to "4th Floor",
            "streetAddress" to "407 Elizabeth Street",
            "suburb" to "Surry Hills",
            "stateOrTerritory" to "NSW",
            "postalCode" to "2010",
            "countryCode" to "AU"
        ),
        "paymentAgreement" to mapOf(
            "paymentInstrumentId" to "215726",
            "type" to "RECURRING",
            "startDate" to "2022-09-01T00 to00 to00.000+1100",
            "endDate" to "2023-12-31T23 to59 to59.999+1100",
            "chargeFrequency" to "WEEKLY",
            "chargeAmount" to 25.99,
            "description" to "Description for Recurring Payment"
        )
    ),
    "meta" to mapOf(
        "fraud" to mapOf(
            "provider" to "cybersource",
            "version" to "CyberSourceTransaction_1.101",
            "format" to "XML",
            "responseFormat" to "XML",
            "message" to "<?xml version=\"1.0\" encoding=\"Windows-1252\"?>\r\n<RequestMessage xmlns toxsd=\"http to//www.w3.org/2001/XMLSchema\" xmlns toxsi=\"http to//www.w3.org/2001/XMLSchema-instance\">\r\n  <merchantID>woolworths_online</merchantID>\r\n  <merchantReferenceCode>1234-26IO8JUN</merchantReferenceCode>\r\n  <billTo>\r\n    <firstName>Raja</firstName>\r\n    <lastName>Saravanan</lastName>\r\n    <street1>210</street1>\r\n    <city>MINTO</city>\r\n    <state>NSW</state>\r\n    <postalCode>2566</postalCode>\r\n    <country>AU</country>\r\n    <phoneNumber>0469813438</phoneNumber>\r\n    <email>[email protected]</email>\r\n    <ipAddress>202.39.218.236</ipAddress>\r\n    <dateOfBirth>1987-02-14</dateOfBirth>\r\n    <customerID>3732442</customerID>\r\n  </billTo>\r\n  <shipTo>\r\n    <firstName>Raja</firstName>\r\n    <lastName>Saravanan</lastName>\r\n    <phoneNumber>0442911234</phoneNumber>\r\n    <email>[email protected]</email>\r\n  </shipTo>\r\n  <item id=\"0\">\r\n    <unitPrice>7.59</unitPrice>\r\n    <quantity>2</quantity>\r\n    <productName>Mccain Protein Plus Frozen Meal Satay Chicken</productName>\r\n    <productSKU>483660</productSKU>\r\n  </item>\r\n  <item id=\"1\">\r\n    <unitPrice>2.00</unitPrice>\r\n    <quantity>2</quantity>\r\n    <productName>Habee Savers Needles Household Repair</productName>\r\n    <productSKU>159489</productSKU>\r\n  </item>\r\n  <item id=\"2\">\r\n    <unitPrice>6.60</unitPrice>\r\n    <quantity>5</quantity>\r\n    <productName>Chicken Breast Fillet Skinless Small</productName>\r\n    <productSKU>118963</productSKU>\r\n  </item>\r\n  <item id=\"3\">\r\n    <unitPrice>5.43</unitPrice>\r\n    <quantity>5</quantity>\r\n    <productName>Chicken Drumsticks </productName>\r\n    <productSKU>169014</productSKU>\r\n  </item>\r\n  <item id=\"4\">\r\n    <unitPrice>3.50</unitPrice>\r\n    <quantity>4</quantity>\r\n    <productName>Chicken Thigh Cutlets Skinless</productName>\r\n    <productSKU>166830</productSKU>\r\n  </item>\r\n  <item id=\"5\">\r\n    <unitPrice>10.80</unitPrice>\r\n    <quantity>4</quantity>\r\n    <productName>Lamb Diced Heart Smart</productName>\r\n    <productSKU>208970</productSKU>\r\n  </item>\r\n  <item id=\"6\">\r\n    <unitPrice>4.94</unitPrice>\r\n    <quantity>2</quantity>\r\n    <productName>Macro Chicken Lovely Legs Free Range</productName>\r\n    <productSKU>700257</productSKU>\r\n  </item>\r\n  <item id=\"7\">\r\n    <unitPrice>19.64</unitPrice>\r\n    <quantity>2</quantity>\r\n    <productName>Macro Organic Whole Chicken</productName>\r\n    <productSKU>229320</productSKU>\r\n  </item>\r\n  <item id=\"8\">\r\n    <unitPrice>9.60</unitPrice>\r\n    <quantity>2</quantity>\r\n    <productName>Msa Australian Beef Steak Porterhouse</productName>\r\n    <productSKU>208988</productSKU>\r\n  </item>\r\n  <item id=\"9\">\r\n    <unitPrice>15.20</unitPrice>\r\n    <quantity>3</quantity>\r\n    <productName>Roast Pork Shoulder Boneless Small</productName>\r\n    <productSKU>203420</productSKU>\r\n  </item>\r\n  <item id=\"10\">\r\n    <unitPrice>10.80</unitPrice>\r\n    <quantity>2</quantity>\r\n    <productName>Select Corned Beef Silverside </productName>\r\n    <productSKU>148345</productSKU>\r\n  </item>\r\n  <item id=\"11\">\r\n    <unitPrice>13.00</unitPrice>\r\n    <quantity>2</quantity>\r\n    <productName>Clairol Nice N Easy 114a Natural Lightest Golden Brown</productName>\r\n    <productSKU>226536</productSKU>\r\n  </item>\r\n  <purchaseTotals>\r\n    <currency>AUD</currency>\r\n    <grandTotalAmount>298.09</grandTotalAmount>\r\n  </purchaseTotals>\r\n  <merchantDefinedData>\r\n    <mddField id=\"19\">Pickup</mddField>\r\n    <mddField id=\"10\">NO</mddField>\r\n    <mddField id=\"3\">Woolworths WOLLI CREEK, WOLLI CREEK</mddField>\r\n    <mddField id=\"1\">2017-09-22 16 to00</mddField>\r\n    <mddField id=\"2\">NSW</mddField>\r\n    <mddField id=\"12\">NO</mddField>\r\n    <mddField id=\"16\">103</mddField>\r\n    <mddField id=\"23\"></mddField>\r\n    <mddField id=\"17\">2017-09-18 12 to40</mddField>\r\n    <mddField id=\"18\">2017-09-18 12 to40</mddField>\r\n    <mddField id=\"25\">2017-09-22 16 to00</mddField>\r\n    <mddField id=\"20\">WEB</mddField>\r\n    <mddField id=\"57\">Normal</mddField>\r\n    <mddField id=\"58\"></mddField>\r\n    <mddField id=\"59\" />\r\n    <mddField id=\"60\">298.09</mddField>\r\n  </merchantDefinedData>\r\n  <afsService run=\"true\" />\r\n  <deviceFingerprintID>18SJBB-26IO8JUN</deviceFingerprintID>\r\n</RequestMessage>"
        ),
        "challengeResponses" to arrayOf(
            mapOf(
                "instrumentId" to "215726",
                "type" to "STEP_UP",
                "token" to "tokenise-stepup-token"
            )
        )
    )
  )
)

if(response.statusCode == 200) {
  val obj : JSONObject = response.jsonObject
    print(obj["data"])
} else {
  handleError(response)
}

Where:

  • clientReference is your application-specific reference number. This number should uniquely identify the transaction in your system
  • orderNumber is your order number of the transaction as generated during the order creation.
  • paymentInstrumentId is the tokenized payment instrument which you want to link the payment agreement to. This is either from the frames SDK response or the list payment instruments response.
  • type can be set to one of the following: ADHOC, INSTALLMENT or RECURRING. Depending on the value you specify, Wpay will ensure the correct data element values are then passed to the Issuers as per the latest scheme credential on file mandates.
    • ADHOC: payments can be charged at any time between the effective startDate and endDate (once or multiple times).
    • INSTALLMENT: payments processed in multiple installments during the valid period of the agreement.
    • RECURRING: recurring charges (e.g. weekly, monthly, etc) - normally used in subscription-based services.
  • startDate is the date from which you want the payment agreement to be effective. This field cannot be set to a date in the past and if you would like the start date to be from NOW then you may leave this field out of the request and we will set the start date as a default to NOW.
  • endDate is the last date to which you want the payment agreement to be effective. This date cannot be set to a date before the startDate. If your recurring payment has no end date then this field can be omitted or set to null.
  • chargeFrequency can be captured as additional information when capturing a payment agreement, this will be returned when viewing a payment agreement so you can display details of the payment agreement back to your customers. Valid values are: ADHOC or WEEKLY, MONTHLY and ANNUALLY.
  • chargeAmount is the amount for which the payment agreement is being set up, this will be returned when viewing a payment agreement so you can display details of the payment agreement back to your customers.
  • immediateCharge is set to true where you wish to process a change on the payment agreement as part of the creation process. When this is set to true a charge request will be made on the payment agreement and the outcome of the charge returned in the response. This will default to false.
  • fraud is the CyberSource fraud payload for the transaction. Please see the Fraud Detection page for more information on the fraud process and fraud payload.
  • challengeResponses contains the payment challenge data such as the step-up token for CVV capture.

Payment Agreement Outcome

When a payment agreement has been successfully setup we will provide back the relevant information on your newly created payment agreement.

📘

Payment Agreement Payment Token

The paymentToken is important as this will be required when editing, deleting or charging the payment agreement. This can be saved in your scheduling system for charging or retrieved from the customers saved payment agreements utilizing the view payment agreement functionality.

{
    "data": {
        "type": "RECURRING",
        "paymentInstrumentId": "215726",
        "paymentInstrumentType": "CREDIT_CARD",
        "startDate": "2022-08-31T23:00:00.000+10:00",
        "endDate": "2023-12-31T23:59:59.999+11:00",
        "chargeFrequency": "WEEKLY",
        "chargeAmount": 25.99,
        "scheme": "MASTERCARD",
        "expiryMonth": "01",
        "expiryYear": "23",
        "cardSuffix": "0407",
        "paymentToken": "e8605265-d983-4b3d-8a48-1204eb43ea6e",
        "description": "Description for Recurring Payment",
        "fraudResponse": {
            "clientId": "6474024752216768604008",
            "reasonCode": "480",
            "decision": "REVIEW",
            "riskInformation": [
                {
                    "name": "Review rule1",
                    "decision": "REVIEW"
                }
            ]
        }
    },
    "meta": {}
}
{
    "data": {
        "type": "RECURRING",
        "paymentInstrumentId": "2235317",
        "paymentInstrumentType": "CREDIT_CARD",
        "startDate": "2022-03-16T14:45:45.667+11:00",
        "endDate": "2023-12-31T23:59:59.999+11:00",
        "chargeFrequency": "WEEKLY",
        "chargeAmount": 25.99,
        "expiryYear": "22",
        "cardSuffix": "0001",
        "expiryMonth": "11",
        "scheme": "AMEX",
        "paymentToken": "e9f62416-85ee-4a75-9ef8-2a8437f1e8d6",
        "description": "Description for Recurring Payment",
        "fraudResponse": {
            "clientId": "6474023475986711704012",
            "reasonCode": "480",
            "decision": "REVIEW",
            "riskInformation": [
                {
                    "name": "Review rule1",
                    "decision": "REVIEW"
                }
            ]
        },
        "transaction": {
            "transactionId": "c7760985-1023-444c-a135-a4c73c2f614a",
            "merchantReferenceId": "78107057",
            "merchantId": "10001",
            "paymentRequestId": "3055c967-dd54-4685-8abd-357aba2f4302",
            "grossAmount": 25.99,
            "clientReference": "06919848",
            "executionTime": "2022-03-16T03:45:48.966Z",
            "type": "PAYMENT",
            "status": "APPROVED",
            "instruments": [
                {
                    "paymentInstrumentId": "2235317",
                    "instrumentType": "CREDIT_CARD",
                    "transactions": [
                        {
                            "paymentTransactionRef": "1000000024495502",
                            "type": "PAYMENT",
                            "executionTime": "2022-03-16T03:45:48.966Z",
                            "amount": 25.99,
                            "status": "APPROVED"
                        }
                    ]
                }
            ],
            "subTransactions": [
                {
                    "transactionReceipt": "1000000024495502",
                    "paymentToken": "e9f62416-85ee-4a75-9ef8-2a8437f1e8d6",
                    "paymentAgreement": {
                        "type": "RECURRING",
                        "paymentInstrumentId": "2235317",
                        "paymentInstrumentType": "CREDIT_CARD",
                        "startDate": "2022-03-16T14:45:45.667+11:00",
                        "endDate": "2023-12-31T23:59:59.999+11:00",
                        "chargeFrequency": "WEEKLY",
                        "chargeAmount": 25.99,
                        "expiryYear": "22",
                        "cardSuffix": "0001",
                        "expiryMonth": "11",
                        "scheme": "AMEX"
                    },
                    "fraudResponse": {
                        "clientId": "6474023475986711704012",
                        "reasonCode": "480",
                        "decision": "REVIEW",
                        "riskInformation": [
                            {
                                "name": "Review rule1",
                                "decision": "REVIEW"
                            }
                        ]
                    },
                    "extendedTransactionData": [
                        {
                            "field": "bin",
                            "value": "374245"
                        },
                        {
                            "field": "stan",
                            "value": "114117"
                        },
                        {
                            "field": "rrn",
                            "value": "000000114117"
                        },
                        {
                            "field": "mid",
                            "value": "611000602008843"
                        },
                        {
                            "field": "terminalId",
                            "value": "W8843100"
                        }
                    ],
                    "externalServiceCode": "00",
                    "externalServiceMessage": "APPROVED"
                }
            ]
        }
    },
    "meta": {}
}

View a Payment Agreement

Utilising our get payment agreements functionality you are able to retrieve all payment agreements which you have setup for your customer or a single payment agreement. This can be used to display the payment agreements your customer has setup with you or to retrieve the paymentToken linked to the payment agreement.

View all payment agreements for a customer

curl --location --request GET 'https://dev-api.wpay.com.au/wow/v1/pay/instore/customer/payments/agreements' \
--header 'Content-Type: application/json' \
--header 'X-Api-Key: {{yourApiKey}}' \
--header 'Authorization: Bearer {{yourBearerToken}}' \
--data-raw ''
var myHeaders = new Headers();
var environment = "substitute environment-value here"
var yourAPIkey = "YOUR-API-KEY";
var accessToken = "ACCESS-TOKEN";
myHeaders.append("accept", "application/json");
myHeaders.append("X-Api-Key", yourAPIkey);
myHeaders.append("Authorization", `Bearer ${accessToken}`);

var raw = "";

var requestOptions = {
  method: 'GET',
  headers: myHeaders,
  body: raw,
  redirect: 'follow'
};

fetch(`https://${environment}.wpay.com.au/wow/v1/pay/instore/customer/payments/agreements`, requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));
import Foundation
#if canImport(FoundationNetworking)
import FoundationNetworking
#endif

var semaphore = DispatchSemaphore (value: 0)

let yourAPIkey = "YOUR-API-KEY";
let environment = "substitute environment-value here"
let accessToken = "ACCESS-TOKEN";
var request = URLRequest(url: URL(string: "https://\(environment).wpay.com.au/wow/v1/pay/instore/customer/payments/agreements")!,timeoutInterval: Double.infinity)
request.addValue(yourAPIkey, forHTTPHeaderField: "X-Api-Key")
request.addValue("Bearer \(accessToken)", forHTTPHeaderField: "Authorization")

request.httpMethod = "GET"

let task = URLSession.shared.dataTask(with: request) { data, response, error in 
  guard let data = data else {
    print(String(describing: error))
    semaphore.signal()
    return
  }
  print(String(data: data, encoding: .utf8)!)
  semaphore.signal()
}

task.resume()
semaphore.wait()
var yourAPIkey = "YOUR-API-KEY";
var environment = "substitute environment-value here"
var accessToken = "ACCESS-TOKEN";

val response = khttp.get(
  url = "https://$environment" + 
        ".wpay.com.au/wow/v1/pay/instore/customer/payments/agreements",
  headers = mapOf("Content-Type" to "application/json",
                  "X-Api-Key" to yourAPIkey,
                 "Authorization", "Bearer $accessToken")
)

if(response.statusCode == 200) {
  val obj : JSONObject = response.jsonObject
    print(obj["data"])
} else {
  handleError(response)
}

This will return all the configured payment agreements for the customer

{
    "data": {
        "paymentAgreements": [
            {
                "paymentInstrumentId": "215726",
                "paymentToken": "e8605265-d983-4b3d-8a48-1204eb43ea6e",
                "status": "VERIFIED",
                "createdOn": "2021-10-01T11:31:49.574+10:00",
                "lastUpdated": "2021-10-01T11:31:49.574+10:00",
                "primary": false,
                "allowed": true,
                "endDate": "2023-12-31T23:59:59.999",
                "startDate": "2022-08-31T23:00",
                "chargeAmount": 25.99,
                "chargeCycle": "0",
                "type": "RECURRING",
                "chargeFrequency": "WEEKLY",
                "cardSuffix": "0407",
                "expiryMonth": "01",
                "expiryYear": "23",
                "scheme": "MASTERCARD",
                "expired": false,
                "updateURL": "https://dev-api.wpay.com.au/wow/v1/pay/paymentagreements/e8605265-d983-4b3d-8a48-1204eb43ea6e",
                "stepUp": {
                    "type": "CAPTURE_CVV",
                    "mandatory": true,
                    "url": "https://iframe.dev1.payments.woolworths.com.au/container-ws/getCaptureFrame/cvv/a1e23906-8889-47ef-a086-7b81bbc6c294/215726",
                    "sessionId": "a1e23906-8889-47ef-a086-7b81bbc6c294"
                }
            },
            {
                "paymentInstrumentId": "215728",
                "paymentToken": "2e6f5c64-02fd-40b5-82af-27974093025e",
                "status": "VERIFIED",
                "createdOn": "2021-10-01T12:01:40.945+10:00",
                "lastUpdated": "2021-10-01T12:01:40.945+10:00",
                "primary": false,
                "allowed": true,
                "chargeAmount": 149.99,
                "type": "RECURRING",
                "endDate": "2023-12-31T23:59:59.999",
                "chargeFrequency": "MONTHLY",
                "startDate": "2022-08-31T23:00",
                "chargeCycle": "0",
                "cardSuffix": "0608",
                "expiryMonth": "02",
                "expiryYear": "23",
                "scheme": "VISA",
                "expired": false,
                "updateURL": "https://dev-api.wpay.com.au/wow/v1/pay/paymentagreements/2e6f5c64-02fd-40b5-82af-27974093025e",
                "stepUp": {
                    "type": "CAPTURE_CVV",
                    "mandatory": true,
                    "url": "https://iframe.dev1.payments.woolworths.com.au/container-ws/getCaptureFrame/cvv/a1e23906-8889-47ef-a086-7b81bbc6c294/215728",
                    "sessionId": "a1e23906-8889-47ef-a086-7b81bbc6c294"
                }
            }
        ]
    },
    "meta": {}
}

View a specific payment agreement

By specifying the paymentToken as part of the request URL you are able to retrieve the details for a specific payment agreement.

curl --location --request GET 'https://{{environment}}.wpay.com.au/wow/v1/pay/instore/customer/payments/agreements/:paymentToken' \
--header 'Content-Type: application/json' \
--header 'X-Api-Key: {{yourApiKey}}' \
--header 'Authorization: Bearer {{yourBearerToken}}' \
--data-raw ''
var myHeaders = new Headers();
var environment = "substitute environment-value here"
var yourAPIkey = "YOUR-API-KEY";
var accessToken = "ACCESS-TOKEN";
var payToken = "2e6f5c64-02fd-40b5-82af-27974093025e";
myHeaders.append("accept", "application/json");
myHeaders.append("X-Api-Key", yourAPIkey);
myHeaders.append("Authorization", `Bearer ${accessToken}`);

var raw = "";

var requestOptions = {
  method: 'GET',
  headers: myHeaders,
  body: raw,
  redirect: 'follow'
};

fetch(`https://${environment}.wpay.com.au/wow/v1/pay/instore/customer/payments/agreements/${paymentToken}`, requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));
import Foundation
#if canImport(FoundationNetworking)
import FoundationNetworking
#endif

var semaphore = DispatchSemaphore (value: 0)

let yourAPIkey = "YOUR-API-KEY";
let environment = "substitute environment-value here"
let accessToken = "ACCESS-TOKEN";
let payToken = "2e6f5c64-02fd-40b5-82af-27974093025e";
var request = URLRequest(url: URL(string: "https://\(environment).wpay.com.au/wow/v1/pay/instore/customer/payments/agreements/\(paymentToken)")!,timeoutInterval: Double.infinity)
request.addValue(yourAPIkey, forHTTPHeaderField: "X-Api-Key")
request.addValue("Bearer \(accessToken)", forHTTPHeaderField: "Authorization")

request.httpMethod = "GET"

let task = URLSession.shared.dataTask(with: request) { data, response, error in 
  guard let data = data else {
    print(String(describing: error))
    semaphore.signal()
    return
  }
  print(String(data: data, encoding: .utf8)!)
  semaphore.signal()
}

task.resume()
semaphore.wait()
var yourAPIkey = "YOUR-API-KEY";
var environment = "substitute environment-value here"
var accessToken = "ACCESS-TOKEN";
var payToken = "2e6f5c64-02fd-40b5-82af-27974093025e";

val response = khttp.get(
  url = "https://$environment" + 
        ".wpay.com.au/wow/v1/pay/instore/customer/payments/agreements/$paymentToken",
  headers = mapOf("Content-Type" to "application/json",
                  "X-Api-Key" to yourAPIkey,
                 "Authorization", "Bearer $accessToken")
)

if(response.statusCode == 200) {
  val obj : JSONObject = response.jsonObject
    print(obj["data"])
} else {
  handleError(response)
}

This will return the specified payment agreements details

{
    "data": {
        "paymentInstrumentId": "215728",
        "paymentToken": "2e6f5c64-02fd-40b5-82af-27974093025e",
        "status": "VERIFIED",
        "createdOn": "2021-10-01T12:01:40.945+10:00",
        "lastUpdated": "2021-10-01T12:01:40.945+10:00",
        "primary": false,
        "allowed": true,
        "chargeAmount": 149.99,
        "type": "RECURRING",
        "endDate": "2023-12-31T23:59:59.999",
        "chargeFrequency": "MONTHLY",
        "startDate": "2022-08-31T23:00",
        "chargeCycle": "0",
        "cardSuffix": "0608",
        "expiryMonth": "02",
        "expiryYear": "23",
        "scheme": "VISA",
        "expired": false,
        "updateURL": "https://dev-api.wpay.com.au/wow/v1/pay/paymentagreements/2e6f5c64-02fd-40b5-82af-27974093025e",
        "stepUp": {
            "type": "CAPTURE_CVV",
            "mandatory": true,
            "url": "https://iframe.dev1.payments.woolworths.com.au/container-ws/getCaptureFrame/cvv/a36977a6-d9b9-43c7-a13d-7855c0e9658b/215728",
            "sessionId": "a36977a6-d9b9-43c7-a13d-7855c0e9658b"
        }
    },
    "meta": {}
}

Update a Payment Agreement

Existing payment agreements can be updated to utilise a different instrument in the customer's wallet as well as other information such as the charge frequency, amount, start and end date.

curl --location --request POST 'https://{{environment}}.wpay.com.au/wow/v1/pay/instore/customer/payments/agreements/:paymentToken' \
--header 'Content-Type: application/json' \
--header 'X-Api-Key: {{yourApiKey}}' \
--header 'Authorization: Bearer {{yourBearerToken}}' \
--data-raw '{
    "data": {
        "clientReference": "00815690",
        "customerRef": "29332770",
        "orderNumber": "36915651",
        "billingAddress": {
            "firstName": "John",
            "lastName": "Doe",
            "email": "[email protected]",
            "company": "Wpay",
            "extendedAddress": "4th Floor",
            "streetAddress": "407 Elizabeth Street",
            "suburb": "Surry Hills",
            "stateOrTerritory": "NSW",
            "postalCode": "2010",
            "countryCode": "AU"
        },
        "paymentAgreement": {
            "paymentInstrumentId": "1600183",
            "type": "RECURRING",
            "startDate": "2022-09-01T00:00:00.000+1100",
            "endDate": "2023-12-31T23:59:59.999+1100",
            "chargeFrequency": "MONTHLY",
            "chargeAmount": 149.99,
            "description": "Description for Recurring Payment"
        }
    },
    "meta": {
        "fraud": {
            "provider": "cybersource",
            "version": "CyberSourceTransaction_1.101",
            "format": "XML",
            "responseFormat": "XML",
            "message": "<?xml version=\"1.0\" encoding=\"Windows-1252\"?>\r\n<RequestMessage xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\r\n  <merchantID>woolworths_online</merchantID>\r\n  <merchantReferenceCode>1234-26IO8JUN</merchantReferenceCode>\r\n  <billTo>\r\n    <firstName>Raja</firstName>\r\n    <lastName>Saravanan</lastName>\r\n    <street1>210</street1>\r\n    <city>MINTO</city>\r\n    <state>NSW</state>\r\n    <postalCode>2566</postalCode>\r\n    <country>AU</country>\r\n    <phoneNumber>0469813438</phoneNumber>\r\n    <email>[email protected]</email>\r\n    <ipAddress>202.39.218.236</ipAddress>\r\n    <dateOfBirth>1987-02-14</dateOfBirth>\r\n    <customerID>3732442</customerID>\r\n  </billTo>\r\n  <shipTo>\r\n    <firstName>Raja</firstName>\r\n    <lastName>Saravanan</lastName>\r\n    <phoneNumber>0442911234</phoneNumber>\r\n    <email>[email protected]</email>\r\n  </shipTo>\r\n  <item id=\"0\">\r\n    <unitPrice>7.59</unitPrice>\r\n    <quantity>2</quantity>\r\n    <productName>Mccain Protein Plus Frozen Meal Satay Chicken</productName>\r\n    <productSKU>483660</productSKU>\r\n  </item>\r\n  <item id=\"1\">\r\n    <unitPrice>2.00</unitPrice>\r\n    <quantity>2</quantity>\r\n    <productName>Habee Savers Needles Household Repair</productName>\r\n    <productSKU>159489</productSKU>\r\n  </item>\r\n  <item id=\"2\">\r\n    <unitPrice>6.60</unitPrice>\r\n    <quantity>5</quantity>\r\n    <productName>Chicken Breast Fillet Skinless Small</productName>\r\n    <productSKU>118963</productSKU>\r\n  </item>\r\n  <item id=\"3\">\r\n    <unitPrice>5.43</unitPrice>\r\n    <quantity>5</quantity>\r\n    <productName>Chicken Drumsticks </productName>\r\n    <productSKU>169014</productSKU>\r\n  </item>\r\n  <item id=\"4\">\r\n    <unitPrice>3.50</unitPrice>\r\n    <quantity>4</quantity>\r\n    <productName>Chicken Thigh Cutlets Skinless</productName>\r\n    <productSKU>166830</productSKU>\r\n  </item>\r\n  <item id=\"5\">\r\n    <unitPrice>10.80</unitPrice>\r\n    <quantity>4</quantity>\r\n    <productName>Lamb Diced Heart Smart</productName>\r\n    <productSKU>208970</productSKU>\r\n  </item>\r\n  <item id=\"6\">\r\n    <unitPrice>4.94</unitPrice>\r\n    <quantity>2</quantity>\r\n    <productName>Macro Chicken Lovely Legs Free Range</productName>\r\n    <productSKU>700257</productSKU>\r\n  </item>\r\n  <item id=\"7\">\r\n    <unitPrice>19.64</unitPrice>\r\n    <quantity>2</quantity>\r\n    <productName>Macro Organic Whole Chicken</productName>\r\n    <productSKU>229320</productSKU>\r\n  </item>\r\n  <item id=\"8\">\r\n    <unitPrice>9.60</unitPrice>\r\n    <quantity>2</quantity>\r\n    <productName>Msa Australian Beef Steak Porterhouse</productName>\r\n    <productSKU>208988</productSKU>\r\n  </item>\r\n  <item id=\"9\">\r\n    <unitPrice>15.20</unitPrice>\r\n    <quantity>3</quantity>\r\n    <productName>Roast Pork Shoulder Boneless Small</productName>\r\n    <productSKU>203420</productSKU>\r\n  </item>\r\n  <item id=\"10\">\r\n    <unitPrice>10.80</unitPrice>\r\n    <quantity>2</quantity>\r\n    <productName>Select Corned Beef Silverside </productName>\r\n    <productSKU>148345</productSKU>\r\n  </item>\r\n  <item id=\"11\">\r\n    <unitPrice>13.00</unitPrice>\r\n    <quantity>2</quantity>\r\n    <productName>Clairol Nice N Easy 114a Natural Lightest Golden Brown</productName>\r\n    <productSKU>226536</productSKU>\r\n  </item>\r\n  <purchaseTotals>\r\n    <currency>AUD</currency>\r\n    <grandTotalAmount>298.09</grandTotalAmount>\r\n  </purchaseTotals>\r\n  <merchantDefinedData>\r\n    <mddField id=\"19\">Pickup</mddField>\r\n    <mddField id=\"10\">NO</mddField>\r\n    <mddField id=\"3\">Woolworths WOLLI CREEK, WOLLI CREEK</mddField>\r\n    <mddField id=\"1\">2017-09-22 16:00</mddField>\r\n    <mddField id=\"2\">NSW</mddField>\r\n    <mddField id=\"12\">NO</mddField>\r\n    <mddField id=\"16\">103</mddField>\r\n    <mddField id=\"23\"></mddField>\r\n    <mddField id=\"17\">2017-09-18 12:40</mddField>\r\n    <mddField id=\"18\">2017-09-18 12:40</mddField>\r\n    <mddField id=\"25\">2017-09-22 16:00</mddField>\r\n    <mddField id=\"20\">WEB</mddField>\r\n    <mddField id=\"57\">Normal</mddField>\r\n    <mddField id=\"58\"></mddField>\r\n    <mddField id=\"59\" />\r\n    <mddField id=\"60\">298.09</mddField>\r\n  </merchantDefinedData>\r\n  <afsService run=\"true\" />\r\n  <deviceFingerprintID>18SJBB-26IO8JUN</deviceFingerprintID>\r\n</RequestMessage>"
        },
        "challengeResponses": [
            {
                "instrumentId": "1600183",
                "type": "STEP_UP",
                "token": "tokenise-stepup-token"
            }
        ]
    }
}'
var myHeaders = new Headers();
var environment = "substitute environment-value here"
var yourAPIkey = "YOUR-API-KEY";
var accessToken = "ACCESS-TOKEN";
var payToken = "2e6f5c64-02fd-40b5-82af-27974093025e";
myHeaders.append("Content-Type", "application/json");
myHeaders.append("X-Api-Key", yourAPIkey);
myHeaders.append("Authorization", `Bearer ${accessToken}`);

var raw = JSON.stringify({
    "data": {
        "clientReference": "00815690",
        "customerRef": "29332770",
        "orderNumber": "36915651",
        "billingAddress": {
            "firstName": "John",
            "lastName": "Doe",
            "email": "[email protected]",
            "company": "Wpay",
            "extendedAddress": "4th Floor",
            "streetAddress": "407 Elizabeth Street",
            "suburb": "Surry Hills",
            "stateOrTerritory": "NSW",
            "postalCode": "2010",
            "countryCode": "AU"
        },
        "paymentAgreement": {
            "paymentInstrumentId": "1600183",
            "type": "RECURRING",
            "startDate": "2022-09-01T00:00:00.000+1100",
            "endDate": "2023-12-31T23:59:59.999+1100",
            "chargeFrequency": "MONTHLY",
            "chargeAmount": 149.99,
            "description": "Description for Recurring Payment"
        }
    },
    "meta": {
        "fraud": {
            "provider": "cybersource",
            "version": "CyberSourceTransaction_1.101",
            "format": "XML",
            "responseFormat": "XML",
            "message": "<?xml version=\"1.0\" encoding=\"Windows-1252\"?>\r\n<RequestMessage xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\r\n  <merchantID>woolworths_online</merchantID>\r\n  <merchantReferenceCode>1234-26IO8JUN</merchantReferenceCode>\r\n  <billTo>\r\n    <firstName>Raja</firstName>\r\n    <lastName>Saravanan</lastName>\r\n    <street1>210</street1>\r\n    <city>MINTO</city>\r\n    <state>NSW</state>\r\n    <postalCode>2566</postalCode>\r\n    <country>AU</country>\r\n    <phoneNumber>0469813438</phoneNumber>\r\n    <email>[email protected]</email>\r\n    <ipAddress>202.39.218.236</ipAddress>\r\n    <dateOfBirth>1987-02-14</dateOfBirth>\r\n    <customerID>3732442</customerID>\r\n  </billTo>\r\n  <shipTo>\r\n    <firstName>Raja</firstName>\r\n    <lastName>Saravanan</lastName>\r\n    <phoneNumber>0442911234</phoneNumber>\r\n    <email>[email protected]</email>\r\n  </shipTo>\r\n  <item id=\"0\">\r\n    <unitPrice>7.59</unitPrice>\r\n    <quantity>2</quantity>\r\n    <productName>Mccain Protein Plus Frozen Meal Satay Chicken</productName>\r\n    <productSKU>483660</productSKU>\r\n  </item>\r\n  <item id=\"1\">\r\n    <unitPrice>2.00</unitPrice>\r\n    <quantity>2</quantity>\r\n    <productName>Habee Savers Needles Household Repair</productName>\r\n    <productSKU>159489</productSKU>\r\n  </item>\r\n  <item id=\"2\">\r\n    <unitPrice>6.60</unitPrice>\r\n    <quantity>5</quantity>\r\n    <productName>Chicken Breast Fillet Skinless Small</productName>\r\n    <productSKU>118963</productSKU>\r\n  </item>\r\n  <item id=\"3\">\r\n    <unitPrice>5.43</unitPrice>\r\n    <quantity>5</quantity>\r\n    <productName>Chicken Drumsticks </productName>\r\n    <productSKU>169014</productSKU>\r\n  </item>\r\n  <item id=\"4\">\r\n    <unitPrice>3.50</unitPrice>\r\n    <quantity>4</quantity>\r\n    <productName>Chicken Thigh Cutlets Skinless</productName>\r\n    <productSKU>166830</productSKU>\r\n  </item>\r\n  <item id=\"5\">\r\n    <unitPrice>10.80</unitPrice>\r\n    <quantity>4</quantity>\r\n    <productName>Lamb Diced Heart Smart</productName>\r\n    <productSKU>208970</productSKU>\r\n  </item>\r\n  <item id=\"6\">\r\n    <unitPrice>4.94</unitPrice>\r\n    <quantity>2</quantity>\r\n    <productName>Macro Chicken Lovely Legs Free Range</productName>\r\n    <productSKU>700257</productSKU>\r\n  </item>\r\n  <item id=\"7\">\r\n    <unitPrice>19.64</unitPrice>\r\n    <quantity>2</quantity>\r\n    <productName>Macro Organic Whole Chicken</productName>\r\n    <productSKU>229320</productSKU>\r\n  </item>\r\n  <item id=\"8\">\r\n    <unitPrice>9.60</unitPrice>\r\n    <quantity>2</quantity>\r\n    <productName>Msa Australian Beef Steak Porterhouse</productName>\r\n    <productSKU>208988</productSKU>\r\n  </item>\r\n  <item id=\"9\">\r\n    <unitPrice>15.20</unitPrice>\r\n    <quantity>3</quantity>\r\n    <productName>Roast Pork Shoulder Boneless Small</productName>\r\n    <productSKU>203420</productSKU>\r\n  </item>\r\n  <item id=\"10\">\r\n    <unitPrice>10.80</unitPrice>\r\n    <quantity>2</quantity>\r\n    <productName>Select Corned Beef Silverside </productName>\r\n    <productSKU>148345</productSKU>\r\n  </item>\r\n  <item id=\"11\">\r\n    <unitPrice>13.00</unitPrice>\r\n    <quantity>2</quantity>\r\n    <productName>Clairol Nice N Easy 114a Natural Lightest Golden Brown</productName>\r\n    <productSKU>226536</productSKU>\r\n  </item>\r\n  <purchaseTotals>\r\n    <currency>AUD</currency>\r\n    <grandTotalAmount>298.09</grandTotalAmount>\r\n  </purchaseTotals>\r\n  <merchantDefinedData>\r\n    <mddField id=\"19\">Pickup</mddField>\r\n    <mddField id=\"10\">NO</mddField>\r\n    <mddField id=\"3\">Woolworths WOLLI CREEK, WOLLI CREEK</mddField>\r\n    <mddField id=\"1\">2017-09-22 16:00</mddField>\r\n    <mddField id=\"2\">NSW</mddField>\r\n    <mddField id=\"12\">NO</mddField>\r\n    <mddField id=\"16\">103</mddField>\r\n    <mddField id=\"23\"></mddField>\r\n    <mddField id=\"17\">2017-09-18 12:40</mddField>\r\n    <mddField id=\"18\">2017-09-18 12:40</mddField>\r\n    <mddField id=\"25\">2017-09-22 16:00</mddField>\r\n    <mddField id=\"20\">WEB</mddField>\r\n    <mddField id=\"57\">Normal</mddField>\r\n    <mddField id=\"58\"></mddField>\r\n    <mddField id=\"59\" />\r\n    <mddField id=\"60\">298.09</mddField>\r\n  </merchantDefinedData>\r\n  <afsService run=\"true\" />\r\n  <deviceFingerprintID>18SJBB-26IO8JUN</deviceFingerprintID>\r\n</RequestMessage>"
        },
        "challengeResponses": [
            {
                "instrumentId": "1600183",
                "type": "STEP_UP",
                "token": "tokenise-stepup-token"
            }
        ]
    }
});

var requestOptions = {
  method: 'POST',
  headers: myHeaders,
  body: raw,
  redirect: 'follow'
};

fetch(`https://${environment}.wpay.com.au/wow/v1/pay/instore/customer/payments/agreements/${paymentToken}`, requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));
import Foundation
#if canImport(FoundationNetworking)
import FoundationNetworking
#endif

var semaphore = DispatchSemaphore (value: 0)

let yourAPIkey = "YOUR-API-KEY";
let environment = "substitute environment-value here"
let accessToken = "ACCESS-TOKEN";
let payToken = "2e6f5c64-02fd-40b5-82af-27974093025e";
let parameters = """
{\
  \"data\": {\
      \"clientReference\": \"00815690\",\
      \"customerRef\": \"29332770\",\
      \"orderNumber\": \"36915651\",\
      \"billingAddress\": {\
          \"firstName\": \"John\",\
          \"lastName\": \"Doe\",\
          \"email\": \"[email protected]\",\
          \"company\": \"Wpay\",\
          \"extendedAddress\": \"4th Floor\",\
          \"streetAddress\": \"407 Elizabeth Street\",\
          \"suburb\": \"Surry Hills\",\
          \"stateOrTerritory\": \"NSW\",\
          \"postalCode\": \"2010\",\
          \"countryCode\": \"AU\"\
      },\
      \"paymentAgreement\": {\
          \"paymentInstrumentId\": \"1600183\",\
          \"type\": \"RECURRING\",\
          \"startDate\": \"2022-09-01T00:00:00.000+1100\",\
          \"endDate\": \"2023-12-31T23:59:59.999+1100\",\
          \"chargeFrequency\": \"MONTHLY\",\
          \"chargeAmount\": 149.99,\
          \"description\": \"Description for Recurring Payment\"\
      }\
  },\
  \"meta\": {\
      \"fraud\": {\
          \"provider\": \"cybersource\",\
          \"version\": \"CyberSourceTransaction_1.101\",\
          \"format\": \"XML\",\
          \"responseFormat\": \"XML\",\
          \"message\": \"<?xml version=\\"1.0\\" encoding=\\"Windows-1252\\"?>\r\n<RequestMessage xmlns:xsd=\\"http://www.w3.org/2001/XMLSchema\\" xmlns:xsi=\\"http://www.w3.org/2001/XMLSchema-instance\\">\r\n  <merchantID>woolworths_online</merchantID>\r\n  <merchantReferenceCode>1234-26IO8JUN</merchantReferenceCode>\r\n  <billTo>\r\n    <firstName>Raja</firstName>\r\n    <lastName>Saravanan</lastName>\r\n    <street1>210</street1>\r\n    <city>MINTO</city>\r\n    <state>NSW</state>\r\n    <postalCode>2566</postalCode>\r\n    <country>AU</country>\r\n    <phoneNumber>0469813438</phoneNumber>\r\n    <email>[email protected]</email>\r\n    <ipAddress>202.39.218.236</ipAddress>\r\n    <dateOfBirth>1987-02-14</dateOfBirth>\r\n    <customerID>3732442</customerID>\r\n  </billTo>\r\n  <shipTo>\r\n    <firstName>Raja</firstName>\r\n    <lastName>Saravanan</lastName>\r\n    <phoneNumber>0442911234</phoneNumber>\r\n    <email>[email protected]</email>\r\n  </shipTo>\r\n  <item id=\\"0\\">\r\n    <unitPrice>7.59</unitPrice>\r\n    <quantity>2</quantity>\r\n    <productName>Mccain Protein Plus Frozen Meal Satay Chicken</productName>\r\n    <productSKU>483660</productSKU>\r\n  </item>\r\n  <item id=\\"1\\">\r\n    <unitPrice>2.00</unitPrice>\r\n    <quantity>2</quantity>\r\n    <productName>Habee Savers Needles Household Repair</productName>\r\n    <productSKU>159489</productSKU>\r\n  </item>\r\n  <item id=\\"2\\">\r\n    <unitPrice>6.60</unitPrice>\r\n    <quantity>5</quantity>\r\n    <productName>Chicken Breast Fillet Skinless Small</productName>\r\n    <productSKU>118963</productSKU>\r\n  </item>\r\n  <item id=\\"3\\">\r\n    <unitPrice>5.43</unitPrice>\r\n    <quantity>5</quantity>\r\n    <productName>Chicken Drumsticks </productName>\r\n    <productSKU>169014</productSKU>\r\n  </item>\r\n  <item id=\\"4\\">\r\n    <unitPrice>3.50</unitPrice>\r\n    <quantity>4</quantity>\r\n    <productName>Chicken Thigh Cutlets Skinless</productName>\r\n    <productSKU>166830</productSKU>\r\n  </item>\r\n  <item id=\\"5\\">\r\n    <unitPrice>10.80</unitPrice>\r\n    <quantity>4</quantity>\r\n    <productName>Lamb Diced Heart Smart</productName>\r\n    <productSKU>208970</productSKU>\r\n  </item>\r\n  <item id=\\"6\\">\r\n    <unitPrice>4.94</unitPrice>\r\n    <quantity>2</quantity>\r\n    <productName>Macro Chicken Lovely Legs Free Range</productName>\r\n    <productSKU>700257</productSKU>\r\n  </item>\r\n  <item id=\\"7\\">\r\n    <unitPrice>19.64</unitPrice>\r\n    <quantity>2</quantity>\r\n    <productName>Macro Organic Whole Chicken</productName>\r\n    <productSKU>229320</productSKU>\r\n  </item>\r\n  <item id=\\"8\\">\r\n    <unitPrice>9.60</unitPrice>\r\n    <quantity>2</quantity>\r\n    <productName>Msa Australian Beef Steak Porterhouse</productName>\r\n    <productSKU>208988</productSKU>\r\n  </item>\r\n  <item id=\\"9\\">\r\n    <unitPrice>15.20</unitPrice>\r\n    <quantity>3</quantity>\r\n    <productName>Roast Pork Shoulder Boneless Small</productName>\r\n    <productSKU>203420</productSKU>\r\n  </item>\r\n  <item id=\\"10\\">\r\n    <unitPrice>10.80</unitPrice>\r\n    <quantity>2</quantity>\r\n    <productName>Select Corned Beef Silverside </productName>\r\n    <productSKU>148345</productSKU>\r\n  </item>\r\n  <item id=\\"11\\">\r\n    <unitPrice>13.00</unitPrice>\r\n    <quantity>2</quantity>\r\n    <productName>Clairol Nice N Easy 114a Natural Lightest Golden Brown</productName>\r\n    <productSKU>226536</productSKU>\r\n  </item>\r\n  <purchaseTotals>\r\n    <currency>AUD</currency>\r\n    <grandTotalAmount>298.09</grandTotalAmount>\r\n  </purchaseTotals>\r\n  <merchantDefinedData>\r\n    <mddField id=\\"19\\">Pickup</mddField>\r\n    <mddField id=\\"10\\">NO</mddField>\r\n    <mddField id=\\"3\\">Woolworths WOLLI CREEK, WOLLI CREEK</mddField>\r\n    <mddField id=\\"1\\">2017-09-22 16:00</mddField>\r\n    <mddField id=\\"2\\">NSW</mddField>\r\n    <mddField id=\\"12\\">NO</mddField>\r\n    <mddField id=\\"16\\">103</mddField>\r\n    <mddField id=\\"23\\"></mddField>\r\n    <mddField id=\\"17\\">2017-09-18 12:40</mddField>\r\n    <mddField id=\\"18\\">2017-09-18 12:40</mddField>\r\n    <mddField id=\\"25\\">2017-09-22 16:00</mddField>\r\n    <mddField id=\\"20\\">WEB</mddField>\r\n    <mddField id=\\"57\\">Normal</mddField>\r\n    <mddField id=\\"58\\"></mddField>\r\n    <mddField id=\\"59\\" />\r\n    <mddField id=\\"60\\">298.09</mddField>\r\n  </merchantDefinedData>\r\n  <afsService run=\\"true\\" />\r\n  <deviceFingerprintID>18SJBB-26IO8JUN</deviceFingerprintID>\r\n</RequestMessage>\"\
      },\
      \"challengeResponses\": [\
          {\
              \"instrumentId\": \"1600183\",\
              \"type\": \"STEP_UP\",\
              \"token\": \"tokenise-stepup-token\"\
          }\
      ]\
  }\
}\
"""
let postData = parameters.data(using: .utf8)

var request = URLRequest(
  url: URL(string: "https://\(environment).wpay.com.au/wow/v1/pay/instore/customer/payments/agreements/\(paymentToken)")!,
  timeoutInterval: Double.infinity
)
request.addValue("application/json", forHTTPHeaderField: "Content-Type")
request.addValue(yourAPIkey, forHTTPHeaderField: "X-Api-Key")
request.addValue("Bearer \(accessToken)", forHTTPHeaderField: "Authorization")

request.httpMethod = "POST"
request.httpBody = postData

let task = URLSession.shared.dataTask(with: request) { data, response, error in 
  guard let data = data else {
    print(String(describing: error))
    semaphore.signal()
    return
  }
  print(String(data: data, encoding: .utf8)!)
  semaphore.signal()
}

task.resume()
semaphore.wait()
var environment = "substitute environment-value here"
var yourAPIkey = "YOUR-API-KEY";
var accessToken = "ACCESS-TOKEN";
var payToken = "2e6f5c64-02fd-40b5-82af-27974093025e";
      
val response = khttp.post(
  url = "https://$environment" + 
        ".wpay.com.au/wow/v1/pay/instore/customer/payments/agreements/$paymentToken",
  headers = mapOf("Content-Type" to "application/json",
                  "X-Api-Key" to yourAPIkey,
                  "Authorization" to "Bearer $accessToken"),
  json = mapOf(
    "data" to mapOf(
        "clientReference" to "00815690",
        "customerRef" to "29332770",
        "orderNumber" to "36915651",
        "billingAddress" to mapOf(
            "firstName" to "John",
            "lastName" to "Doe",
            "email" to "[email protected]",
            "company" to "Wpay",
            "extendedAddress" to "4th Floor",
            "streetAddress" to "407 Elizabeth Street",
            "suburb" to "Surry Hills",
            "stateOrTerritory" to "NSW",
            "postalCode" to "2010",
            "countryCode" to "AU"
        ),
        "paymentAgreement" to mapOf(
            "paymentInstrumentId" to "1600183",
            "type" to "RECURRING",
            "startDate" to "2022-09-01T00 to00 to00.000+1100",
            "endDate" to "2023-12-31T23 to59 to59.999+1100",
            "chargeFrequency" to "MONTHLY",
            "chargeAmount" to 149.99,
            "description" to "Description for Recurring Payment"
        )
    ),
    "meta" to mapOf(
        "fraud" to mapOf(
            "provider" to "cybersource",
            "version" to "CyberSourceTransaction_1.101",
            "format" to "XML",
            "responseFormat" to "XML",
            "message" to "<?xml version=\"1.0\" encoding=\"Windows-1252\"?>\r\n<RequestMessage xmlns toxsd=\"http to//www.w3.org/2001/XMLSchema\" xmlns toxsi=\"http to//www.w3.org/2001/XMLSchema-instance\">\r\n  <merchantID>woolworths_online</merchantID>\r\n  <merchantReferenceCode>1234-26IO8JUN</merchantReferenceCode>\r\n  <billTo>\r\n    <firstName>Raja</firstName>\r\n    <lastName>Saravanan</lastName>\r\n    <street1>210</street1>\r\n    <city>MINTO</city>\r\n    <state>NSW</state>\r\n    <postalCode>2566</postalCode>\r\n    <country>AU</country>\r\n    <phoneNumber>0469813438</phoneNumber>\r\n    <email>[email protected]</email>\r\n    <ipAddress>202.39.218.236</ipAddress>\r\n    <dateOfBirth>1987-02-14</dateOfBirth>\r\n    <customerID>3732442</customerID>\r\n  </billTo>\r\n  <shipTo>\r\n    <firstName>Raja</firstName>\r\n    <lastName>Saravanan</lastName>\r\n    <phoneNumber>0442911234</phoneNumber>\r\n    <email>[email protected]</email>\r\n  </shipTo>\r\n  <item id=\"0\">\r\n    <unitPrice>7.59</unitPrice>\r\n    <quantity>2</quantity>\r\n    <productName>Mccain Protein Plus Frozen Meal Satay Chicken</productName>\r\n    <productSKU>483660</productSKU>\r\n  </item>\r\n  <item id=\"1\">\r\n    <unitPrice>2.00</unitPrice>\r\n    <quantity>2</quantity>\r\n    <productName>Habee Savers Needles Household Repair</productName>\r\n    <productSKU>159489</productSKU>\r\n  </item>\r\n  <item id=\"2\">\r\n    <unitPrice>6.60</unitPrice>\r\n    <quantity>5</quantity>\r\n    <productName>Chicken Breast Fillet Skinless Small</productName>\r\n    <productSKU>118963</productSKU>\r\n  </item>\r\n  <item id=\"3\">\r\n    <unitPrice>5.43</unitPrice>\r\n    <quantity>5</quantity>\r\n    <productName>Chicken Drumsticks </productName>\r\n    <productSKU>169014</productSKU>\r\n  </item>\r\n  <item id=\"4\">\r\n    <unitPrice>3.50</unitPrice>\r\n    <quantity>4</quantity>\r\n    <productName>Chicken Thigh Cutlets Skinless</productName>\r\n    <productSKU>166830</productSKU>\r\n  </item>\r\n  <item id=\"5\">\r\n    <unitPrice>10.80</unitPrice>\r\n    <quantity>4</quantity>\r\n    <productName>Lamb Diced Heart Smart</productName>\r\n    <productSKU>208970</productSKU>\r\n  </item>\r\n  <item id=\"6\">\r\n    <unitPrice>4.94</unitPrice>\r\n    <quantity>2</quantity>\r\n    <productName>Macro Chicken Lovely Legs Free Range</productName>\r\n    <productSKU>700257</productSKU>\r\n  </item>\r\n  <item id=\"7\">\r\n    <unitPrice>19.64</unitPrice>\r\n    <quantity>2</quantity>\r\n    <productName>Macro Organic Whole Chicken</productName>\r\n    <productSKU>229320</productSKU>\r\n  </item>\r\n  <item id=\"8\">\r\n    <unitPrice>9.60</unitPrice>\r\n    <quantity>2</quantity>\r\n    <productName>Msa Australian Beef Steak Porterhouse</productName>\r\n    <productSKU>208988</productSKU>\r\n  </item>\r\n  <item id=\"9\">\r\n    <unitPrice>15.20</unitPrice>\r\n    <quantity>3</quantity>\r\n    <productName>Roast Pork Shoulder Boneless Small</productName>\r\n    <productSKU>203420</productSKU>\r\n  </item>\r\n  <item id=\"10\">\r\n    <unitPrice>10.80</unitPrice>\r\n    <quantity>2</quantity>\r\n    <productName>Select Corned Beef Silverside </productName>\r\n    <productSKU>148345</productSKU>\r\n  </item>\r\n  <item id=\"11\">\r\n    <unitPrice>13.00</unitPrice>\r\n    <quantity>2</quantity>\r\n    <productName>Clairol Nice N Easy 114a Natural Lightest Golden Brown</productName>\r\n    <productSKU>226536</productSKU>\r\n  </item>\r\n  <purchaseTotals>\r\n    <currency>AUD</currency>\r\n    <grandTotalAmount>298.09</grandTotalAmount>\r\n  </purchaseTotals>\r\n  <merchantDefinedData>\r\n    <mddField id=\"19\">Pickup</mddField>\r\n    <mddField id=\"10\">NO</mddField>\r\n    <mddField id=\"3\">Woolworths WOLLI CREEK, WOLLI CREEK</mddField>\r\n    <mddField id=\"1\">2017-09-22 16 to00</mddField>\r\n    <mddField id=\"2\">NSW</mddField>\r\n    <mddField id=\"12\">NO</mddField>\r\n    <mddField id=\"16\">103</mddField>\r\n    <mddField id=\"23\"></mddField>\r\n    <mddField id=\"17\">2017-09-18 12 to40</mddField>\r\n    <mddField id=\"18\">2017-09-18 12 to40</mddField>\r\n    <mddField id=\"25\">2017-09-22 16 to00</mddField>\r\n    <mddField id=\"20\">WEB</mddField>\r\n    <mddField id=\"57\">Normal</mddField>\r\n    <mddField id=\"58\"></mddField>\r\n    <mddField id=\"59\" />\r\n    <mddField id=\"60\">298.09</mddField>\r\n  </merchantDefinedData>\r\n  <afsService run=\"true\" />\r\n  <deviceFingerprintID>18SJBB-26IO8JUN</deviceFingerprintID>\r\n</RequestMessage>"
        ),
        "challengeResponses" to arrayOf(
            mapOf(
                "instrumentId" to "1600183",
                "type" to "STEP_UP",
                "token" to "tokenise-stepup-token"
            )
        )
    )
  )
)

if(response.statusCode == 200) {
  val obj : JSONObject = response.jsonObject
    print(obj["data"])
} else {
  handleError(response)
}

Delete a Payment Agreement

Should you wish to delete a payment agreement you can utilise our delete payment agreement functionality.
This will remove the payment agreement from your customer and it can no longer be retrieved when viewing the payment agreement list or trying to retrieve the specific payment agreement.

🚧

Expiring a Payment Agreement

Should you or your customer wish to cancel a payment agreement, rather than deleting it, update the payment agreement and set the effective-to date to the date you wish to expire the agreement.

curl --location --request DELETE 'https://{{environment}}.wpay.com.au/wow/v1/pay/instore/merchant/payments/agreements/750b6962-66c0-4304-92dc-b3a29424d41d' \
--header 'Content-Type: application/json' \
--header 'X-Api-Key: {{yourApiKey}}' \
--data-raw ''
var myHeaders = new Headers();
var environment = "substitute environment-value here"
var yourAPIkey = "YOUR-API-KEY";
var payToken = "750b6962-66c0-4304-92dc-b3a29424d41d";

myHeaders.append("Content-Type", "application/json");
myHeaders.append("X-Api-Key", yourAPIkey);

var raw = "";

var requestOptions = {
  method: 'DELETE',
  headers: myHeaders,
  body: raw,
  redirect: 'follow'
};

fetch("https://${environment}.wpay.com.au/wow/v1/pay/instore/merchant/payments/agreements/${payToken}", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));
import Foundation
#if canImport(FoundationNetworking)
import FoundationNetworking
#endif

var semaphore = DispatchSemaphore (value: 0)

let yourAPIkey = "YOUR-API-KEY";
let environment = "substitute environment-value here"
let payToken = "750b6962-66c0-4304-92dc-b3a29424d41d";

var request = URLRequest(url: URL(string: "https://\(environment).wpay.com.au/wow/v1/pay/instore/merchant/payments/agreements/\(payToken)")!,timeoutInterval: Double.infinity)
request.addValue(yourAPIkey, forHTTPHeaderField: "X-Api-Key")

request.httpMethod = "DELETE"

let task = URLSession.shared.dataTask(with: request) { data, response, error in 
  guard let data = data else {
    print(String(describing: error))
    semaphore.signal()
    return
  }
  print(String(data: data, encoding: .utf8)!)
  semaphore.signal()
}

task.resume()
semaphore.wait()
var yourAPIkey = "YOUR-API-KEY";
var environment = "substitute environment-value here"
var payToken = "750b6962-66c0-4304-92dc-b3a29424d41d";

val response = khttp.delete(
  url = "https://$environment" + 
        ".wpay.com.au/wow/v1/pay/instore/merchant/payments/agreements/$payToken",
  headers = mapOf("Content-Type" to "application/json1",
                  "X-Api-Key" to yourAPIkey)
)

if(response.statusCode == 204) {
  print("Deleted payToken: $payToken")
} else {
  handleError(response)
}