BETA: Please note that the current endpoints are considered beta. It is possible there may be changes before these endpoints are finalised.

Payments

See currencies for more information on providing and using currency values. All values are in lowest denomination.

List Payments

List payments

get /organizations/{organizationId}/payments

Parameters

NameTypeInDescription
organizationIdstringpathOrganization ID
locationIdstringqueryLocation ID
sortstringquerySort the resulting payments by created or updated timestamp (most recent first). Defaults to created.
"created", "updated"
afterstringqueryThe cursor to use for pagination. Do not use this field manually it will be automatically provided in the response headers (see Paging guide).

Responses

200: OK response.Payment[]
[
  {
    "billingType": "order/pickup",
    "chargedAmount": 600,
    "completedAt": "2018-08-08T02:35:21Z",
    "createdAt": "2018-08-08T02:35:21Z",
    "creditAmount": 200,
    "currency": "AUD",
    "customer": {
      "email": "john@example.com",
      "firstName": "John",
      "id": "01FCCGYZA9JPQ97HBSTKW0KT7P",
      "lastName": "Smith",
      "phoneNumber": "+61411222333"
    },
    "discountAmount": 300,
    "feeAmount": 10,
    "id": "29e13de7-d158-4aba-a928-7d868c1dbfb9",
    "items": [
      {
        "amount": 450,
        "id": "FOOD001",
        "name": "Coffee",
        "options": [
          {
            "choices": [
              {
                "amount": 50,
                "id": "CSML1",
                "name": "Small"
              },
              {
                "amount": 50,
                "id": "CSML1",
                "name": "Small"
              },
              {
                "amount": 50,
                "id": "CSML1",
                "name": "Small"
              }
            ],
            "id": "OPT01",
            "name": "Size"
          },
          {
            "choices": [
              {
                "amount": 50,
                "id": "CSML1",
                "name": "Small"
              },
              {
                "amount": 50,
                "id": "CSML1",
                "name": "Small"
              },
              {
                "amount": 50,
                "id": "CSML1",
                "name": "Small"
              }
            ],
            "id": "OPT01",
            "name": "Size"
          },
          {
            "choices": [
              {
                "amount": 50,
                "id": "CSML1",
                "name": "Small"
              },
              {
                "amount": 50,
                "id": "CSML1",
                "name": "Small"
              },
              {
                "amount": 50,
                "id": "CSML1",
                "name": "Small"
              }
            ],
            "id": "OPT01",
            "name": "Size"
          }
        ],
        "quantity": 2,
        "type": "item"
      },
      {
        "amount": 450,
        "id": "FOOD001",
        "name": "Coffee",
        "options": [
          {
            "choices": [
              {
                "amount": 50,
                "id": "CSML1",
                "name": "Small"
              },
              {
                "amount": 50,
                "id": "CSML1",
                "name": "Small"
              },
              {
                "amount": 50,
                "id": "CSML1",
                "name": "Small"
              }
            ],
            "id": "OPT01",
            "name": "Size"
          },
          {
            "choices": [
              {
                "amount": 50,
                "id": "CSML1",
                "name": "Small"
              },
              {
                "amount": 50,
                "id": "CSML1",
                "name": "Small"
              },
              {
                "amount": 50,
                "id": "CSML1",
                "name": "Small"
              }
            ],
            "id": "OPT01",
            "name": "Size"
          },
          {
            "choices": [
              {
                "amount": 50,
                "id": "CSML1",
                "name": "Small"
              },
              {
                "amount": 50,
                "id": "CSML1",
                "name": "Small"
              },
              {
                "amount": 50,
                "id": "CSML1",
                "name": "Small"
              }
            ],
            "id": "OPT01",
            "name": "Size"
          }
        ],
        "quantity": 2,
        "type": "item"
      },
      {
        "amount": 450,
        "id": "FOOD001",
        "name": "Coffee",
        "options": [
          {
            "choices": [
              {
                "amount": 50,
                "id": "CSML1",
                "name": "Small"
              },
              {
                "amount": 50,
                "id": "CSML1",
                "name": "Small"
              },
              {
                "amount": 50,
                "id": "CSML1",
                "name": "Small"
              }
            ],
            "id": "OPT01",
            "name": "Size"
          },
          {
            "choices": [
              {
                "amount": 50,
                "id": "CSML1",
                "name": "Small"
              },
              {
                "amount": 50,
                "id": "CSML1",
                "name": "Small"
              },
              {
                "amount": 50,
                "id": "CSML1",
                "name": "Small"
              }
            ],
            "id": "OPT01",
            "name": "Size"
          },
          {
            "choices": [
              {
                "amount": 50,
                "id": "CSML1",
                "name": "Small"
              },
              {
                "amount": 50,
                "id": "CSML1",
                "name": "Small"
              },
              {
                "amount": 50,
                "id": "CSML1",
                "name": "Small"
              }
            ],
            "id": "OPT01",
            "name": "Size"
          }
        ],
        "quantity": 2,
        "type": "item"
      }
    ],
    "locationId": "01HMWZ6W8HK7FHE4H0RJC74M7R",
    "payoutAmount": 590,
    "refId": "INV123456",
    "refundedAt": "2018-08-08T02:35:21Z",
    "state": "completed",
    "tipAmount": 100,
    "total": 1000,
    "updatedAt": "2018-08-08T02:35:21Z"
  },
  {
    "billingType": "order/pickup",
    "chargedAmount": 600,
    "completedAt": "2018-08-08T02:35:21Z",
    "createdAt": "2018-08-08T02:35:21Z",
    "creditAmount": 200,
    "currency": "AUD",
    "customer": {
      "email": "john@example.com",
      "firstName": "John",
      "id": "01FCCGYZA9JPQ97HBSTKW0KT7P",
      "lastName": "Smith",
      "phoneNumber": "+61411222333"
    },
    "discountAmount": 300,
    "feeAmount": 10,
    "id": "29e13de7-d158-4aba-a928-7d868c1dbfb9",
    "items": [
      {
        "amount": 450,
        "id": "FOOD001",
        "name": "Coffee",
        "options": [
          {
            "choices": [
              {
                "amount": 50,
                "id": "CSML1",
                "name": "Small"
              },
              {
                "amount": 50,
                "id": "CSML1",
                "name": "Small"
              },
              {
                "amount": 50,
                "id": "CSML1",
                "name": "Small"
              }
            ],
            "id": "OPT01",
            "name": "Size"
          },
          {
            "choices": [
              {
                "amount": 50,
                "id": "CSML1",
                "name": "Small"
              },
              {
                "amount": 50,
                "id": "CSML1",
                "name": "Small"
              },
              {
                "amount": 50,
                "id": "CSML1",
                "name": "Small"
              }
            ],
            "id": "OPT01",
            "name": "Size"
          },
          {
            "choices": [
              {
                "amount": 50,
                "id": "CSML1",
                "name": "Small"
              },
              {
                "amount": 50,
                "id": "CSML1",
                "name": "Small"
              },
              {
                "amount": 50,
                "id": "CSML1",
                "name": "Small"
              }
            ],
            "id": "OPT01",
            "name": "Size"
          }
        ],
        "quantity": 2,
        "type": "item"
      },
      {
        "amount": 450,
        "id": "FOOD001",
        "name": "Coffee",
        "options": [
          {
            "choices": [
              {
                "amount": 50,
                "id": "CSML1",
                "name": "Small"
              },
              {
                "amount": 50,
                "id": "CSML1",
                "name": "Small"
              },
              {
                "amount": 50,
                "id": "CSML1",
                "name": "Small"
              }
            ],
            "id": "OPT01",
            "name": "Size"
          },
          {
            "choices": [
              {
                "amount": 50,
                "id": "CSML1",
                "name": "Small"
              },
              {
                "amount": 50,
                "id": "CSML1",
                "name": "Small"
              },
              {
                "amount": 50,
                "id": "CSML1",
                "name": "Small"
              }
            ],
            "id": "OPT01",
            "name": "Size"
          },
          {
            "choices": [
              {
                "amount": 50,
                "id": "CSML1",
                "name": "Small"
              },
              {
                "amount": 50,
                "id": "CSML1",
                "name": "Small"
              },
              {
                "amount": 50,
                "id": "CSML1",
                "name": "Small"
              }
            ],
            "id": "OPT01",
            "name": "Size"
          }
        ],
        "quantity": 2,
        "type": "item"
      },
      {
        "amount": 450,
        "id": "FOOD001",
        "name": "Coffee",
        "options": [
          {
            "choices": [
              {
                "amount": 50,
                "id": "CSML1",
                "name": "Small"
              },
              {
                "amount": 50,
                "id": "CSML1",
                "name": "Small"
              },
              {
                "amount": 50,
                "id": "CSML1",
                "name": "Small"
              }
            ],
            "id": "OPT01",
            "name": "Size"
          },
          {
            "choices": [
              {
                "amount": 50,
                "id": "CSML1",
                "name": "Small"
              },
              {
                "amount": 50,
                "id": "CSML1",
                "name": "Small"
              },
              {
                "amount": 50,
                "id": "CSML1",
                "name": "Small"
              }
            ],
            "id": "OPT01",
            "name": "Size"
          },
          {
            "choices": [
              {
                "amount": 50,
                "id": "CSML1",
                "name": "Small"
              },
              {
                "amount": 50,
                "id": "CSML1",
                "name": "Small"
              },
              {
                "amount": 50,
                "id": "CSML1",
                "name": "Small"
              }
            ],
            "id": "OPT01",
            "name": "Size"
          }
        ],
        "quantity": 2,
        "type": "item"
      }
    ],
    "locationId": "01HMWZ6W8HK7FHE4H0RJC74M7R",
    "payoutAmount": 590,
    "refId": "INV123456",
    "refundedAt": "2018-08-08T02:35:21Z",
    "state": "completed",
    "tipAmount": 100,
    "total": 1000,
    "updatedAt": "2018-08-08T02:35:21Z"
  }
]

Examples

Syncing payments on a schedule

To sync the full historical set of payments on a schedule (rather than using webhook events) without needing to refetch all payments you may use the sort=updated query parameter. This will fetch payments starting with those updated most recently. Typically this is the timestamp when the payment last changed state. Continue to fetch next pages until you pass the updated timestamp from the last scheduled run.

The following example demonstrates the approach using fetch in Typescript (note: limited error handling for brevity).

async function getUpdatedPayments(organizationId: string, updatedAt: Date | null) {
  let payments = [];
  let path: string | null = `/organizations/${organizationId}/payments?sort=updated`;

  do {
    const url = new URL(path, "https://api.loke.global");
    const response = await fetch(url, {
      headers: { Authorization: "Bearer my_access_token" },
    });
    if (!response.ok) throw new Error("Network response was not OK");
    path = response.headers.get("X-Next-Page");

    payments.push(await response.json());

    const lastPayment =  payments[payments.length - 1];
    if (!lastPayment || (updatedAt && new Date(lastPayment.updatedAt) < updatedAt)) {
      // don't continue, even if more pages
      path = null;
    }
  } while (path);

  return { payments, updatedAt: payments[0]?.updatedAt ?? updatedAt };
}

async function doScheduledJob() {
  // load the job params, in particular last known updatedAt
  const job = await getMyJob();
  
  const {payments, updatedAt} = await getUpdatedPayments(
    job.organizationId,
    job.updatedAt // will be null on first run
  );

  // do something with payments
  await updatePaymentsInMySystem(payments);

  // remember the new updatedAt value for next run
  await updateMyJob(job.id, { updatedAt });
}

Get a Payment

Get payment by ID

get /organizations/{organizationId}/payments/{paymentId}

Parameters

NameTypeInDescription
organizationIdstringpathOrganization ID
paymentIdstringpathPayment ID

Responses

200: OK response.Payment
{
  "billingType": "order/pickup",
  "chargedAmount": 600,
  "completedAt": "2018-08-08T02:35:21Z",
  "createdAt": "2018-08-08T02:35:21Z",
  "creditAmount": 200,
  "currency": "NZD",
  "customer": {
    "email": "john@example.com",
    "firstName": "John",
    "id": "01FCCGYZA9JPQ97HBSTKW0KT7P",
    "lastName": "Smith",
    "phoneNumber": "+61411222333"
  },
  "discountAmount": 300,
  "feeAmount": 10,
  "id": "29e13de7-d158-4aba-a928-7d868c1dbfb9",
  "items": [
    {
      "amount": 450,
      "id": "FOOD001",
      "name": "Coffee",
      "options": [
        {
          "choices": [
            {
              "amount": 50,
              "id": "CSML1",
              "name": "Small"
            },
            {
              "amount": 50,
              "id": "CSML1",
              "name": "Small"
            },
            {
              "amount": 50,
              "id": "CSML1",
              "name": "Small"
            },
            {
              "amount": 50,
              "id": "CSML1",
              "name": "Small"
            }
          ],
          "id": "OPT01",
          "name": "Size"
        },
        {
          "choices": [
            {
              "amount": 50,
              "id": "CSML1",
              "name": "Small"
            },
            {
              "amount": 50,
              "id": "CSML1",
              "name": "Small"
            },
            {
              "amount": 50,
              "id": "CSML1",
              "name": "Small"
            },
            {
              "amount": 50,
              "id": "CSML1",
              "name": "Small"
            }
          ],
          "id": "OPT01",
          "name": "Size"
        }
      ],
      "quantity": 2,
      "type": "item"
    },
    {
      "amount": 450,
      "id": "FOOD001",
      "name": "Coffee",
      "options": [
        {
          "choices": [
            {
              "amount": 50,
              "id": "CSML1",
              "name": "Small"
            },
            {
              "amount": 50,
              "id": "CSML1",
              "name": "Small"
            },
            {
              "amount": 50,
              "id": "CSML1",
              "name": "Small"
            },
            {
              "amount": 50,
              "id": "CSML1",
              "name": "Small"
            }
          ],
          "id": "OPT01",
          "name": "Size"
        },
        {
          "choices": [
            {
              "amount": 50,
              "id": "CSML1",
              "name": "Small"
            },
            {
              "amount": 50,
              "id": "CSML1",
              "name": "Small"
            },
            {
              "amount": 50,
              "id": "CSML1",
              "name": "Small"
            },
            {
              "amount": 50,
              "id": "CSML1",
              "name": "Small"
            }
          ],
          "id": "OPT01",
          "name": "Size"
        }
      ],
      "quantity": 2,
      "type": "item"
    },
    {
      "amount": 450,
      "id": "FOOD001",
      "name": "Coffee",
      "options": [
        {
          "choices": [
            {
              "amount": 50,
              "id": "CSML1",
              "name": "Small"
            },
            {
              "amount": 50,
              "id": "CSML1",
              "name": "Small"
            },
            {
              "amount": 50,
              "id": "CSML1",
              "name": "Small"
            },
            {
              "amount": 50,
              "id": "CSML1",
              "name": "Small"
            }
          ],
          "id": "OPT01",
          "name": "Size"
        },
        {
          "choices": [
            {
              "amount": 50,
              "id": "CSML1",
              "name": "Small"
            },
            {
              "amount": 50,
              "id": "CSML1",
              "name": "Small"
            },
            {
              "amount": 50,
              "id": "CSML1",
              "name": "Small"
            },
            {
              "amount": 50,
              "id": "CSML1",
              "name": "Small"
            }
          ],
          "id": "OPT01",
          "name": "Size"
        }
      ],
      "quantity": 2,
      "type": "item"
    },
    {
      "amount": 450,
      "id": "FOOD001",
      "name": "Coffee",
      "options": [
        {
          "choices": [
            {
              "amount": 50,
              "id": "CSML1",
              "name": "Small"
            },
            {
              "amount": 50,
              "id": "CSML1",
              "name": "Small"
            },
            {
              "amount": 50,
              "id": "CSML1",
              "name": "Small"
            },
            {
              "amount": 50,
              "id": "CSML1",
              "name": "Small"
            }
          ],
          "id": "OPT01",
          "name": "Size"
        },
        {
          "choices": [
            {
              "amount": 50,
              "id": "CSML1",
              "name": "Small"
            },
            {
              "amount": 50,
              "id": "CSML1",
              "name": "Small"
            },
            {
              "amount": 50,
              "id": "CSML1",
              "name": "Small"
            },
            {
              "amount": 50,
              "id": "CSML1",
              "name": "Small"
            }
          ],
          "id": "OPT01",
          "name": "Size"
        }
      ],
      "quantity": 2,
      "type": "item"
    }
  ],
  "locationId": "01HMWZ6W8HK7FHE4H0RJC74M7R",
  "payoutAmount": 590,
  "refId": "INV123456",
  "refundedAt": "2018-08-08T02:35:21Z",
  "state": "completed",
  "tipAmount": 100,
  "total": 1000,
  "updatedAt": "2018-08-08T02:35:21Z"
}
404: not_found: Not Found response.

Models

Payment

NameTypeDescription
idstringPayment ID
locationIdstring(optional) Unique ID for the location this payment belongs to. May be null on some payments (e.g., promotion purchases).
refIdstring(optional) Reference ID provided by payment source (e.g., POS for an order). Not guaranteed to be unique.
completedAtstring(optional) When the payment was completed
createdAtstringWhen the payment was initiated
refundedAtstring(optional) When the payment was refunded
updatedAtstringWhen the payment was last updated
billingTypestringBilling classification of payment, corresponds to the source type (e.g., order/delivery, order/pickup, pos/bill, app/credit)
chargedAmountintegerThe amount charged to the customer's payment method (credit card) in the lowest denomination (e.g., cents). This will be the total plus tips, minus any discounts and credits.
creditAmountintegerThe LOKE-applied credit amount in the lowest denomination (e.g., cents). This will be 0 if there is no credit associated with the payment. If multiple credits have been applied this will be the sum of all credits. Exclude external credits.
currencystring(enum)The currency this payment was processed in
"AUD", "SGD", "GBP", "NZD", "USD"
discountAmountintegerThe LOKE-applied discount amount in the lowest denomination (e.g., cents). This will be 0 if there is no discount associated with the payment. If multiple discounts have been applied this will be the sum of all discounts. Exclude external discounts.
feeAmountintegerThe fee collected and withheld by LOKE for this payment in the lowest denomination (e.g., cents). This will be 0 if there is no fee associated with the payment.
payoutAmountintegerThe amount (to be) paid out to the merchant in the lowest denomination (e.g., cents). This will be the chargedAmount minus the feeAmount.
statestringCurrent state of payment (e.g., completed, refunded)
tipAmountintegerThe tip amount in the lowest denomination (e.g., cents). This will be 0 if the tip was 0 or if there is no tip associated with the payment.
totalintegerThe total amount in the lowest denomination (e.g., cents). This will be the sum of all the items, external (non-LOKE) discounts, external surcharges, and delivery fees.
customerCustomerTiny(optional)
itemsPaymentLineItem[]

CustomerTiny

NameTypeDescription
idstringUnique ID of the Customer
emailstring(optional) The Customers email address
firstNamestringCustomer first name or given name
lastNamestringCustomer last name or surname
phoneNumberstring(optional) The Customers mobile phone number

PaymentLineItem

NameTypeDescription
idstringProduct identifier for the item. Depending on the source this could be a SKU, PLU, a database identifier, or something composite.
namestringItem name
amountintegerThe amount in the lowest denomination (e.g., cents). This will be the price of a single quantity of the item.
quantityintegerThe quantity of identical items purchased on this line.
typestringThe type of line item (e.g., item, discount, surcharge)
optionsPaymentLineItemOption[](optional) options chosen for this item

PaymentLineItemOption

NameTypeDescription
idstringIdentifier for the option (group of choices)
namestringOption name (e.g., 'size', 'milk', 'sugar')
choicesPaymentLineItemOptionChoice[]Choices made for this option

PaymentLineItemOptionChoice

NameTypeDescription
idstringProduct identifier for the choice. Depending on the source this could be a SKU, PLU, a database identifier, or something composite.
namestringChoice name (e.g., 'small', 'medium', 'large')
amountintegerThe amount of this choice in the lowest denomination (e.g., cents).

In this article