Developers API
Authorization
Every API request must include 2 headers for authorization:
--header 'Authorization: Bearer {apiKey}'
--header 'x-store-id: {storeId}'{storeId} and {apiKey} are located on the Store page in your Keterion account.
Creating invoices flow
Step 1. The "Create invoice" endpoint returns the paymentGateway property which should be used to navigate users to when they are ready to pay for your order.
The Payment Gateway URL has a time limit and is valid for only 20 minutes.
We recommend calling the "Create invoice" endpoint every time before navigating your users to the Payment Gateway. E.g. you might want to call it when users click the "Checkout" button on your website, get the Payment Gateway URL in response, and redirect users to it.
Calling the endpoint multiple times with exact same externalOrderId does not create new invoices in our DB, but it extends the payment session for an existing invoice by another 20 minutes.
Step 2. You can use this endpoint to update an existing invoice to change network, coin, amount, and description. Note that changing network, coin and amount leads to a new payment token (Payment Gateway URL). Previous tokens become no longer valid.
Invoices with txStatus 0 or 2 cannot be updated.
Step 3. Use the "Check invoice status" endpoint to see if an invoice is paid or has some other status.
The payment status is reflected in the txStatus property of the response. And it may have following values:
txStatus: null - No payment transaction was created. This value indicates that your user has not clicked the Pay button.
txStatus: 0 - Payment transaction has been created and queued for processing. This indicates that your user has clicked the Pay button on the Payment Gateway page.
txStatus: 2 - Invoice has been successfully paid.
txStatus: 3 - An error has occurred during the transaction processing. No funds were moved.
API Endpoints
Create invoice
This endpoint creates an invoice in Keterion for an existing order in your store.
POST https://api.keterion.com/v1/merchants/order
| Parameter | Type | Accepted values | Description |
|---|---|---|---|
| externalOrderId | string (required) | a-zA-Z0-9.-+()*$!?#@% and space | This is the order id in your system. externalOrderId has a unique value for every store. |
| network | string (required) | bitcoin, ethereum | |
| coin | string (required) | For bitcoin network: btc. For ethereum netowork: eth, dai, usdc, usdt, wbtc, weth | Combination of netowork and coin specifies the cryptocurrency of the invoice. |
| amount | string (required) | Number string, has to not start with 0. | Payment amount in base units of the spcified cryptocurrency |
| description | string (optional, 255 chars max) | Invoice description. |
// Example
// The following request creates an invoice to pay 25.99 USDT (Ethereum USDT) for an order with id af83211
curl --request POST 'https://api.keterion.com/v1/merchants/order'
--header 'Authorization: Bearer {apiKey}'
--header 'x-store-id: {storeId}'
--data-raw {
externalOrderId: "af83211"
network: "ethereum",
coin: "usdt",
amount: "25990000"
description: "Order id af83211 (1 x Magic sword, 2 x Healing potion)"
}
// Successful result will return the created invoice data:
{
"status": 200,
"body": {
"order": {
"id": "wl1ltgofhtyhez2893ha8d2jp2v5qy15n6h2szckwl5ejpw3",
"storeId": "ab6e62b9-5e46-42f4-84f2-e4b2c4a5d6f1",
"externalOrderId": "af83211",
"description": "Order id af83211 (1 x Magic sword, 2 x Healing potion)",
"network": "ethereum",
"coin": "usdt",
"amount": "25990000",
"token": "f05c44k7c657030f882d7f77f0ea725e6d20b282caz077fdbf3d666187178e5c",
"tokenExpiresAt": "yyyy-mm-dd H:i:s",
"createdAt": "yyyy-mm-dd H:i:s",
"updatedAt": "yyyy-mm-dd H:i:s",
"paymentGateway": "https://app.keterion.com/pay/?s=ab6e62b9-5e46-42f4-84f2-e4b2c4a5d6f1&o=wl1ltgofhtyhez2893ha8d2jp2v5qy15n6h2szckwl5ejpw3&t=f05c44k7c657030f882d7f77f0ea725e6d20b282caz077fdbf3d666187178e5c"
}
}
}
Check invoice status
This endpoint returns invoice information with transaction data.
GET https://api.keterion.com/v1/merchants/order?e={externalOrderId}
| Parameter | Type | Accepted values | Description |
|---|---|---|---|
| externalOrderId | string (required) | a-zA-Z0-9.-+()*$!?#@% and space | This is the order id in your system. externalOrderId has a unique value for every store. |
// Example
// The following request queries data for an invoice with order id af83211
curl --request GET 'https://api.keterion.com/v1/merchants/order?e=af83211'
--header 'Authorization: Bearer {apiKey}'
--header 'x-store-id: {storeId}'
// Successful result will return the invoice data and transaction data:
{
"status": 200,
"body": {
"order": {
"id": "wl1ltgofhtyhez2893ha8d2jp2v5qy15n6h2szckwl5ejpw3",
"storeId": "ab6e62b9-5e46-42f4-84f2-e4b2c4a5d6f1",
"externalOrderId": "af83211",
"description": "Order id af83211 (1 x Magic sword, 2 x Healing potion)",
"network": "ethereum",
"coin": "usdt",
"amount": "25990000",
"token": "f05c44k7c657030f882d7f77f0ea725e6d20b282caz077fdbf3d666187178e5c",
"tokenExpiresAt": "yyyy-mm-dd H:i:s",
"createdAt": "yyyy-mm-dd H:i:s",
"updatedAt": "yyyy-mm-dd H:i:s",
"txStatus": 2
"txStatusDescription": null
"txUuidv4": "9f43b8bb-df0d-4e99-9b6d-68e7fd2990a1"
}
}
}