Get Order Status
curl --request GET \
--url https://api.example.com/v1/order/{orderId} \
--header 'Authorization: <authorization>' \
--header 'X-Client-ID: <x-client-id>'import requests
url = "https://api.example.com/v1/order/{orderId}"
headers = {
"Authorization": "<authorization>",
"X-Client-ID": "<x-client-id>"
}
response = requests.get(url, headers=headers)
print(response.text)const options = {
method: 'GET',
headers: {Authorization: '<authorization>', 'X-Client-ID': '<x-client-id>'}
};
fetch('https://api.example.com/v1/order/{orderId}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.example.com/v1/order/{orderId}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>",
"X-Client-ID: <x-client-id>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/v1/order/{orderId}"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "<authorization>")
req.Header.Add("X-Client-ID", "<x-client-id>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.example.com/v1/order/{orderId}")
.header("Authorization", "<authorization>")
.header("X-Client-ID", "<x-client-id>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/v1/order/{orderId}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = '<authorization>'
request["X-Client-ID"] = '<x-client-id>'
response = http.request(request)
puts response.read_body{
"requestId": "<string>",
"orderId": "<string>",
"status": {},
"paidAt": "<string>",
"metadata": {
"metadata.paymentId": "<string>",
"metadata.txHash": "<string>",
"metadata.note": "<string>"
}
}Orders
Get Order Status
Fetch the current status of an order by ID. Use this to poll for async completion after a payment is submitted.
GET
/
v1
/
order
/
{orderId}
Get Order Status
curl --request GET \
--url https://api.example.com/v1/order/{orderId} \
--header 'Authorization: <authorization>' \
--header 'X-Client-ID: <x-client-id>'import requests
url = "https://api.example.com/v1/order/{orderId}"
headers = {
"Authorization": "<authorization>",
"X-Client-ID": "<x-client-id>"
}
response = requests.get(url, headers=headers)
print(response.text)const options = {
method: 'GET',
headers: {Authorization: '<authorization>', 'X-Client-ID': '<x-client-id>'}
};
fetch('https://api.example.com/v1/order/{orderId}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.example.com/v1/order/{orderId}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>",
"X-Client-ID: <x-client-id>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/v1/order/{orderId}"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "<authorization>")
req.Header.Add("X-Client-ID", "<x-client-id>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.example.com/v1/order/{orderId}")
.header("Authorization", "<authorization>")
.header("X-Client-ID", "<x-client-id>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/v1/order/{orderId}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = '<authorization>'
request["X-Client-ID"] = '<x-client-id>'
response = http.request(request)
puts response.read_body{
"requestId": "<string>",
"orderId": "<string>",
"status": {},
"paidAt": "<string>",
"metadata": {
"metadata.paymentId": "<string>",
"metadata.txHash": "<string>",
"metadata.note": "<string>"
}
}Overview
After creating an order withPOST /v1/order and directing the user through an external payment flow, use this endpoint to poll for the outcome. The order status will progress from STARTED to one of the terminal states: COMPLETED, FAILED, or EXPIRED.
Request
Headers
string
required
Bearer token for the authenticated user. Format:
Bearer <userAccessToken>string
required
Your application’s client ID, issued during onboarding.
Path Parameters
string
required
The unique ID of a previously created order, as returned by
POST /v1/order. Example: "abcd_1234"Example Request
const response = await fetch(`https://api.baanx.com/v1/order/${orderId}`, {
headers: {
'X-Client-ID': 'your_client_id',
'Authorization': `Bearer ${userAccessToken}`
}
});
const order = await response.json();
console.log(order.status); // e.g. "COMPLETED"
import requests
response = requests.get(
f'https://api.baanx.com/v1/order/{order_id}',
headers={
'X-Client-ID': 'your_client_id',
'Authorization': f'Bearer {user_access_token}'
}
)
order = response.json()
print(order['status']) # e.g. "COMPLETED"
curl --request GET \
--url https://api.baanx.com/v1/order/abcd_1234 \
--header 'Authorization: Bearer <userAccessToken>' \
--header 'X-Client-ID: your_client_id'
Response
200 — Success
{
"requestId": "payment_1234",
"orderId": "abcd_1234",
"status": "COMPLETED",
"paidAt": "2023-03-27 17:07:12.662+03",
"metadata": {
"paymentId": "abcpaymentId1234ABC",
"txHash": "0x3a11a86cf218c448be519728cd3ac5c741fb3424",
"note": "payment_refunded"
}
}
string
The payment request identifier, correlating this order to a payment gateway transaction. Example:
"payment_1234"string
required
The unique identifier of the order.
enum
required
The current state of the order.
| Value | Description |
|---|---|
STARTED | Order created; payment not yet confirmed. Continue polling. |
COMPLETED | Payment received and order fulfilled successfully. |
FAILED | Payment failed or was rejected. Check metadata.note for context. |
EXPIRED | Order was not paid within the allowed time window. |
string
Timestamp of when payment was confirmed. Only present when
status is COMPLETED.object
Additional context about the payment outcome. Individual fields may be absent depending on the result.
Error Responses
401 — Authentication Error
401 — Authentication Error
The bearer token is missing, expired, or invalid.
403 — Authorization Error
403 — Authorization Error
The authenticated user does not have permission to access this order.
404 — Order Not Found
404 — Order Not Found
No order exists with the given
orderId. Verify the ID matches one returned by POST /v1/order.{
"error": "Order not found"
}
498 — Invalid Client Key
498 — Invalid Client Key
The
X-Client-ID header value is not recognised.499 — Missing Client Key
499 — Missing Client Key
The
X-Client-ID header is absent from the request.500 — Internal Server Error
500 — Internal Server Error
An unexpected server error occurred. Retry with exponential backoff.
Polling Pattern
Order completion is asynchronous. Poll this endpoint after the user completes the external payment step, stopping whenstatus reaches a terminal value (COMPLETED, FAILED, or EXPIRED).
async function waitForOrderCompletion(orderId, clientId, accessToken) {
const TERMINAL_STATES = ['COMPLETED', 'FAILED', 'EXPIRED'];
const MAX_ATTEMPTS = 40; // ~2 minutes at 3s intervals
const POLL_INTERVAL_MS = 3000;
for (let i = 0; i < MAX_ATTEMPTS; i++) {
const response = await fetch(`https://api.baanx.com/v1/order/${orderId}`, {
headers: {
'X-Client-ID': clientId,
'Authorization': `Bearer ${accessToken}`
}
});
if (!response.ok) throw new Error(`Unexpected error: ${response.status}`);
const order = await response.json();
if (TERMINAL_STATES.includes(order.status)) return order;
await new Promise(resolve => setTimeout(resolve, POLL_INTERVAL_MS));
}
throw new Error('Order polling timed out. Please check back later.');
}
const order = await waitForOrderCompletion(orderId, clientId, accessToken);
if (order.status === 'COMPLETED') {
// Unlock product, show success UI
} else {
// Handle failure or expiry
console.warn('Order did not complete:', order.metadata?.note);
}
Related Endpoints
Create Order
Initiate a new order and receive the
orderId to track here.Get Available Products
Discover which products are available and eligible before ordering.
Was this page helpful?