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
Name | Type | In | Description |
---|---|---|---|
organizationId | string | path | Organization ID |
locationId | string | query | Location ID |
sort | string | query | Sort the resulting payments by created or updated timestamp (most recent first). Defaults to created. "created", "updated" |
after | string | query | The 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,
"externalAmount": 600,
"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"
}
],
"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"
}
],
"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"
}
],
"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"
}
],
"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,
"externalAmount": 600,
"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"
}
],
"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"
}
],
"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"
}
],
"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"
}
],
"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,
"externalAmount": 600,
"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"
}
],
"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"
}
],
"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"
}
],
"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"
}
],
"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
Name | Type | In | Description |
---|---|---|---|
organizationId | string | path | Organization ID |
paymentId | string | path | Payment 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": "GBP",
"customer": {
"email": "john@example.com",
"firstName": "John",
"id": "01FCCGYZA9JPQ97HBSTKW0KT7P",
"lastName": "Smith",
"phoneNumber": "+61411222333"
},
"discountAmount": 300,
"externalAmount": 600,
"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"
},
{
"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"
},
{
"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"
},
{
"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"
},
{
"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
Name | Type | Description |
---|---|---|
id | string | Payment ID |
locationId | string | (optional) Unique ID for the location this payment belongs to. May be null on some payments (e.g., promotion purchases). |
refId | string | (optional) Reference ID provided by payment source (e.g., POS for an order). Not guaranteed to be unique. |
completedAt | string | (optional) When the payment was completed |
createdAt | string | When the payment was initiated |
refundedAt | string | (optional) When the payment was refunded |
updatedAt | string | When the payment was last updated |
billingType | string | Billing classification of payment, corresponds to the source type (e.g., order/delivery, order/pickup, pos/bill, app/credit) |
chargedAmount | integer | The 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. |
creditAmount | integer | The 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. |
currency | string(enum) | The currency this payment was processed in "AUD", "SGD", "GBP", "NZD", "USD" |
discountAmount | integer | The 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. |
externalAmount | integer | The amount (to be) paid by an external payment method (cash etc). This is what the chargedAmount would have been if the customer had payed via LOKE. Only one of chargedAmount or externalPaymentAmount will be non-zero. |
feeAmount | integer | The 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. |
payoutAmount | integer | The amount (to be) paid out to the merchant in the lowest denomination (e.g., cents). This will be the chargedAmount minus the feeAmount. |
state | string | Current state of payment (e.g., completed, refunded) |
tipAmount | integer | The 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. |
total | integer | The 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. |
customer | CustomerTiny | (optional) |
items | PaymentLineItem[] |
CustomerTiny
Name | Type | Description |
---|---|---|
id | string | Unique ID of the Customer |
string | (optional) The Customers email address | |
firstName | string | Customer first name or given name |
lastName | string | Customer last name or surname |
phoneNumber | string | (optional) The Customers mobile phone number |
PaymentLineItem
Name | Type | Description |
---|---|---|
id | string | Product identifier for the item. Depending on the source this could be a SKU, PLU, a database identifier, or something composite. |
name | string | Item name |
amount | integer | The amount in the lowest denomination (e.g., cents). This will be the price of a single quantity of the item. |
quantity | integer | The quantity of identical items purchased on this line. |
type | string | The type of line item (e.g., item, discount, surcharge) |
options | PaymentLineItemOption[] | (optional) options chosen for this item |
PaymentLineItemOption
Name | Type | Description |
---|---|---|
id | string | Identifier for the option (group of choices) |
name | string | Option name (e.g., 'size', 'milk', 'sugar') |
choices | PaymentLineItemOptionChoice[] | Choices made for this option |
PaymentLineItemOptionChoice
Name | Type | Description |
---|---|---|
id | string | Product identifier for the choice. Depending on the source this could be a SKU, PLU, a database identifier, or something composite. |
name | string | Choice name (e.g., 'small', 'medium', 'large') |
amount | integer | The amount of this choice in the lowest denomination (e.g., cents). |