Accept a one-off payment

Guide

A complete server-side charge flow, from creating the customer to showing the tax invoice. Uses test mode - swap in ck_live_ and a real card flow when you're ready to go live.

1. Create a customer

curl -X POST https://api.ching.co.il/ching/v1/customers \
  -H "Authorization: Bearer ck_test_..." \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Tal Levi",
    "email": "tal@example.com"
  }'

Best practice: do this once per person, then store the returned cus_* id on your own user record and reuse it for every later action on that person's behalf - checkout sessions, setup sessions, subscriptions, charges, and billing-portal sessions. The cus_* id is the durable handle that ties saved cards, subscriptions (the user's current plan), charge history, and tax documents together, so reusing it keeps the user's plan and self-service billing pages intact. Creating a fresh customer each time fragments one person into duplicate, disconnected records. One person in your system = one CHING customer, for life.

2. Attach a card

In test mode you can skip the setup-session flow entirely:

curl -X POST https://api.ching.co.il/ching/v1/payment_methods/test-card \
  -H "Authorization: Bearer ck_test_..." \
  -H "Content-Type: application/json" \
  -d '{ "customer": "cus_V8ltq1pK_MWH" }'

In live mode, replace this step with a setup session so CHING collects the card on your behalf.

3. Run the charge

curl -X POST https://api.ching.co.il/ching/v1/charges \
  -H "Authorization: Bearer ck_test_..." \
  -H "Content-Type: application/json" \
  -d '{
    "customer": "cus_V8ltq1pK_MWH",
    "payment_method": "pm_WMc9X22NT1af",
    "amount": 9900,
    "description": "One-off order #1234"
  }'

The response contains the charge status and the id of the tax invoice CHING issues on your behalf:

{
  "success": true,
  "data": {
    "id": "ch_9mTPfRSDmEOU",
    "status": "succeeded",
    "amount": 9900,
    "currency": "ils",
    "document": "doc_R0i70cuPK_yO"
  }
}

4. Send the receipt (optional)

Fetch the document to get its PDF URL and include it in your own order confirmation email:

curl https://api.ching.co.il/ching/v1/documents/doc_R0i70cuPK_yO \
  -H "Authorization: Bearer ck_test_..."