CALCULATE

Used to calculate how many Miles to issue for all eligible items in the basket.
POST /checkout/issuance/calculate

Take a look at our OpenAPI (Swagger-Spec) schema to learn more about the API calls.

The CALCULATE endpoint is used to calculate how many Miles to issue for all eligible items in the basket. This API call DOES NOT issue actual Miles to the Collector.

API call validation process

After making a call to CALCULATE, you will receive one of the following responses:

If the call is SUCCESSFUL
  • You will receive a response code of 200
  • No further action is required
If the call is REJECTED due to incorrect or invalid details
  • You will receive a response code of 400
  • You must retry the request with a valid transaction record and/or the corrected details
If the call FAILS due to an error or other issue
  • You will receive a response code of 500
  • It’s recommended you retry the request at least 2 additional times

Sample request

curl -X POST https://cert.airmilesapis.ca/checkout/issuance/calculate \
-H "Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJ..." \
-H "Content-Type: application/json" \
-d {
    "basketGSTAmount": 0,
    "basketPSTAmount": 0,
    "basketHSTAmount": 3.25,
    "basketQSTAmount": 0,
    "basketPreTaxAmount": 24.97,
    "basketPostTaxAmount": 28.22,
    "checkoutDateTime": "2019-05-30T14:12:59.479Z",
    "checkoutTransactionId": "12340001111",
    "collectorNumber": "81111111111",
    "context": {"key1": "value1","key2": "value2"},
    "coupon": ["57841","57862"],
    "deviceId": "POS1",
    "items": [{
            "baseAmount": 9.99,
            "categoryId" : "11101",
            "departmentId":"10001",
            "finalAmount": 19.98,
            "id": "SKU1234",
            "name": "Dog Food",
            "number": 1,
            "quantity": 2
        },
        {
            "baseAmount": 4.99,
            "categoryId" : "CAT2",
            "departmentId":"DEPT2",
            "finalAmount": 4.99,
            "id": "SKU1252",
            "name": "Potato Chips",
            "number": 2,
            "quantity": 1
        }
    ],
    "locationCode": "1137",
    "originalTransactionId": "d445b671-7a7f-490f-a3f8-adfc443408a5",
    "sponsorCode": "TEST",
    "tender": ["CASH", "CREDIT"],
    "transactionType": "RETURN"
}

Request parameters

* required field

Parameter Description
basketGSTAmount The dollar amount of GST (Government Sales Tax) to be added.
basketHSTAmount The dollar amount of HST (Harmonized Sales Tax) to be added.
basketPSTAmount The dollar amount of PST (Provincial Sales Tax) to be added.
basketQSTAmount The dollar amount of QST (Quebec Sales Tax) to be added.
basketPostTaxAmount* The total dollar amount of the basket, POST-TAX (i.e., what the Collector spent at checkout).
basketPreTaxAmount* The total dollar amount of the basket, PRE-TAX (i.e., before taxes are calculated and added to the total).
checkoutDateTime* Standard date/time format for the transaction at checkout. (see ISO-8601)
checkoutTransactionId* Unique identifier generated by the Partner for the transaction at checkout.
collectorNumber* The customer’s AIR MILES account number. Must be 11 digits in length and must start with an 8
context Notes or additional information that is desired on each request as a key value pair.
coupon A list of all coupon codes applied to the bill at checkout.
deviceId ID number used to identify the POS terminal currently in use.
items This optional object contains data elements related to purchase details, including the list of item(s) purchased, their quantity, individual price, and total amount paid (pre-tax).
locationCode A maximum of four alpha-numeric characters created by the Partner and used to identify the Partner’s location.
originalTransactionId This value represents the transactionId returned in the ISSUE transaction response from AIR MILES. Alternatively the checkoutTransactionId supplied by the Partner in an ISSUE transaction can be sent in this field.
sponsorCode* Alpha-numeric value used to identify the Partner. To be provided by AIR MILES
tender The method of payment used to pay for the transaction at checkout.
transactionType* Transaction Type can be PURCHASE (ISSUE) or RETURN.

Sample response

HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
Transfer-Encoding: chunked
Date: Mon, 29 Oct 2018 15:27:34 GMT
{
  "basketGSTAmount": 0,
  "basketPSTAmount": 0,
  "basketHSTAmount": 3.25,
  "basketQSTAmount": 0,
  "basketPreTaxAmount": 24.97,
  "basketPostTaxAmount": 28.22,
  "checkoutDateTime": "2019-05-30T14:12:59.479Z",
  "checkoutTransactionId": "12340001111",
  "collectorNumber":"81111111111",
  "context": {"key1": "value1","key2": "value2"},
  "coupon": ["57841","57862"],
  "deviceId": "POS1",
  "issuances": [{
      "contributingItemIds": ["SKU1234","SKU1252"],
      "issuanceOfferCode": "STANDARD",
      "locationCode": "1100",
      "milesAmount": 5,
      "offerDescription": "Bonus Miles for Groceries.",
      "offerId": "123454"
    }],
    "items": [{
            "baseAmount": 9.99,
            "categoryId" : "11101",
            "departmentId":"10001",
            "finalAmount": 19.98,
            "id": "SKU1234",
            "name": "Dog Food",
            "number": 1,
            "quantity": 2
        },
              {
            "baseAmount": 4.99,
            "categoryId" : "CAT2",
            "departmentId":"DEPT2",
            "finalAmount": 4.99,
            "id": "SKU1252",
            "name": "Potato Chips",
            "number": 2,
            "quantity": 1
        }],
  "locationCode": "1137",
  "originalTransactionId": "d445b671-7a7f-490f-a3f8-adfc443408a5",
  "sponsorCode": "TEST",
  "tender": ["CASH","CREDIT"],
  "transactionId": "c4f6cd00-dd00-4aaf-9099-b0685ab710b3",
  "transactionType": "RETURN"
}

Response parameters

Only parameters unique to the Sample Response are listed below. For all other parameters, refer to the table above.

Parameter Description
issuances This optional object contains data elements related to issuance data.
transactionId A unique ID created for the particular transaction. To be provided by AIR MILES

Status codes

Refer to our Audit report errors table for more information.

Status Code Description
200 Request processed successfully.
400 Bad request, failed to process.
500 Request failed due to internal error.