Process orders
Fetch paid orders, record shipments with tracking and keep customers informed using the Orders API.
This guide shows how to build a simple fulfillment loop: find paid orders, ship them and record the tracking number. It uses the Orders API.
Before you begin
Create an API key with orders:read and orders:write. See Authentication.
1. Find orders to ship
List paid orders. Keep the filters narrow so that each call returns only what you need:
curl "https://wafle.click/api/v1/stores/your-store/orders?status=paid&per_page=50" \
-H "X-Wafle-Store-Key: $WAFLE_KEY"
If there are more orders than fit on one page, keep requesting the next page until a page comes back with fewer than per_page items.
2. Read the order
Open an order to see what to pack and where to send it:
curl "https://wafle.click/api/v1/stores/your-store/orders/1042" \
-H "X-Wafle-Store-Key: $WAFLE_KEY"
Check the items, the shipping address and the payment status before you ship. Only ship orders that are paid.
3. Record the shipment
After you ship, send the carrier and tracking number. Wafle marks the order as shipped and emails the customer if shipping notifications are on for your store:
const res = await fetch(`${process.env.WAFLE_API}/stores/your-store/orders/1042/ship`, {
method: 'POST',
headers: {
'X-Wafle-Store-Key': process.env.WAFLE_KEY,
'Content-Type': 'application/json',
},
body: JSON.stringify({
carrier: 'UPS',
tracking_number: '1Z999AA10123456784',
tracking_url: 'https://www.ups.com/track?tracknum=1Z999AA10123456784',
notify_customer: true,
}),
});
if (!res.ok) throw new Error(`Ship failed: ${res.status}`);
Do not retry this request blindly if it times out. Read the order first: if its status is already shipped, the first attempt worked.
4. Leave a note
Add an internal note for your team, or a note the customer can see on their order page:
import os, requests
API = os.environ["WAFLE_API"]
H = {"X-Wafle-Store-Key": os.environ["WAFLE_KEY"], "Content-Type": "application/json"}
requests.post(
f"{API}/stores/your-store/orders/1042/note",
json={"text": "Packed by warehouse team.", "customer_visible": False},
headers=H,
timeout=30,
).raise_for_status()
A customer-visible note is shown on the order page but does not send an email.
5. Cancel or refund
You can cancel an order that has not shipped with POST /orders/{id}/cancel. Cancelling does not return the customer's payment. Refunds are issued from your dashboard. See Issue a refund.
Related
Need help with an integration? Contact support.