Skip to Content

Quickstart

Create an order, take a payment, and receive the webhook.

1. Create an API key

In the merchant console, open API 密钥 (API keys) and create a key. The full key, starting with cp_live_, is shown only once. Store it on your server, for example in an environment variable. Never put it in browser or mobile app code.

export CASHPAYMENT_API_KEY=cp_live_xxx

2. Add a webhook endpoint

Open Webhook in the merchant console, add your HTTPS endpoint, and subscribe to order.paid and order.expired. Copy the signing secret (whsec_…); you need it to verify signatures.

Use 发送测试事件 (Send test event) to check that your endpoint receives a webhook.test event.

3. Create an order

Call Create an order when the customer checks out. Use a new idempotency key for each order, and reuse it if you retry the same request.

curl -X POST https://api.cashpayment.co/v1/orders \
  -H "Authorization: Bearer $CASHPAYMENT_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{
    "slug": "onne",
    "amountUsdCents": 1500,
    "reference": "WC-10234",
    "successUrl": "https://shop.example.com/thanks",
    "cancelUrl": "https://shop.example.com/cart"
  }'

slug is one of your pay links; the order is booked under it. The response is the new order with status: "pending".

4. Send the customer to checkout

Redirect the customer to checkoutUrl. The checkout page shows the amount, a QR code and the invoice, and counts down to expiresAt, one hour after creation.

After payment the page returns the customer to successUrl. While the order is unpaid, a Return to store link leads to cancelUrl. See Checkout & redirects.

5. Fulfil on the webhook

When the invoice is paid, your endpoint receives order.paid:

{
  "id": "0b6a3c52-7f0e-4c4e-9d43-5a0f1f4c2e9b",
  "type": "order.paid",
  "timestamp": "2026-11-17T12:03:42.000Z",
  "data": {
    "id": "12345678-1234-4234-8234-123456789abc",
    "reference": "WC-10234",
    "status": "paid",
    "amountUsdCents": 1500,
    "amountSat": 15000,
    "paidAt": "2026-11-17T12:03:41.000Z"
  }
}

Verify the signature, find your order by data.reference or data.id, mark it paid, and respond with any 2xx status. The payload above is shortened; see Payload for every field.

Fulfil orders from the webhook or from Retrieve an order, not from the customer reaching successUrl. Anyone can open that URL.

On this page