Reference
API v1: checkout and payments
Use the checkout API to create a checkout for an order, and to check if it has been paid with USDC or SOL.
Create a checkout
POSThttps://www.switro.com/api/v1/checkout
Uses the checkout API key in your settings.
| Field | Required | What it is |
|---|---|---|
amount_total | Yes | What the customer pays, at least 0.1. It must include delivery and tax |
amount_currency | Yes | Always use USD |
items | Yes | A list of what they are buying |
items[].item_title | Yes | Its name |
items[].item_quantity | Yes | How many |
items[].item_amount | Yes | The price of one |
items[].item_description | No | More about it |
items[].item_image_url | No | The web address of its picture |
amount_shipping, amount_tax | No | Already included in amount_total. At least 0.01, so leave them out if they are zero |
customer_name, customer_email, customer_phone, customer_address | No | Only send what you need |
order_reference_id | No | Your own order ID |
success_url, cancel_url | No | Where the customer goes next. If you leave them out, Switro uses the addresses in your settings |
{
"amount_total": 45.5,
"amount_currency": "USD",
"amount_shipping": 5.5,
"order_reference_id": "order-1001",
"success_url": "https://example.com/order",
"cancel_url": "https://example.com/cart",
"items": [
{ "item_title": "Headphones", "item_quantity": 1, "item_amount": 40 }
]
}{
"id": "CHECKOUT_ID",
"url": "https://www.switro.com/p/checkout/CHECKOUT_ID"
}Save id with your order, then send the customer to url. It works for 10 minutes.
Work out the total on your server
Switro charges
amount_total, and does not check that the items add up to it. Never use a price sent by the browser.Sending this again creates another checkout
This request has no idempotency key. Use the checkout you saved while it still works.
Get a payment
GEThttps://www.switro.com/api/v1/payment/PAYMENT_ID
Use the
payment_id from the webhook, not the checkout ID.{
"id": "PAYMENT_ID",
"status": "confirmed",
"network": "devnet",
"checkout_id": "CHECKOUT_ID",
"payment_link_id": null,
"amount_original": "45.5000000000",
"amount_currency": "SOL",
"amount_sol": "0.2275000000",
"transaction_signaure": "SOLANA_TRANSACTION",
"transaction_url": "https://solscan.io/tx/...",
"transaction_error": null
}| Status | What it means |
|---|---|
confirmed | Paid |
initiated | There is no final result yet. Check again later, and do not ask the customer to pay again |
failed | The payment failed |
Before you mark an order as paid, check that status is confirmed, and that checkout_id, the amount and network match your order.
amount_originalis the price in US dollars.amount_currencyis what the customer paid with,SOLorUSDC. Do not use them together.amount_solis null for a USDC payment.- Amounts can be text. Compare them in whole cents.
transaction_signaureis missing at. Keep that spelling in your code.
An empty answer means not paid
If the payment does not exist, or belongs to another account, the answer is
{} with status 200. A 200 does not prove payment.