Orders API

Manage orders, process refunds, generate invoices, and create checkout sessions. Orders are created when a customer completes a payment through ClapPay checkout.

Endpoints

GET
/api/v1/payment/payment-intents/

List all orders (payment intents)

GET
/api/v1/payment/payment-intents/{id}/

Retrieve a specific order

POST
/api/v1/payment/payment-intents/{id}/refund/

Refund an order (full or partial)

GET
/api/v1/payment/invoices/

List all invoices

GET
/api/v1/payment/invoices/{id}/

Retrieve an invoice

GET
/api/v1/payment/invoices/{id}/download/

Download invoice as PDF

POST
/api/v1/payment/storefront/checkout/

Create a checkout session

GET
/api/v1/payment/portal/{token}/orders/

Customer portal: order history

GET
/api/v1/payment/portal/{token}/invoices/

Customer portal: invoices

Order Object

FieldTypeDescription
idstring (UUID)Unique order identifier
statusstringOrder status: pending, succeeded, failed, refunded
amountintegerTotal amount in smallest currency unit
currencystringISO 4217 currency code
customer_emailstringCustomer email address
customer_namestringCustomer name
itemsarrayLine items in the order
refunded_amountintegerAmount refunded
metadataobjectArbitrary key-value metadata
created_atdatetimeOrder creation timestamp

Example: Create Checkout Session

curl -X POST https://api.clappay.com/api/v1/payment/storefront/checkout/ \
  -H "Content-Type: application/json" \
  -d '{
    "product_id": "prod_abc123",
    "price_id": "price_xyz789",
    "customer_email": "customer@example.com",
    "success_url": "https://yoursite.com/success",
    "cancel_url": "https://yoursite.com/cancel"
  }'

# Response:
{
  "checkout_url": "https://checkout.clappay.com/cs_abc123",
  "session_id": "cs_abc123"
}

Example: Issue Refund

curl -X POST https://api.clappay.com/api/v1/payment/payment-intents/{id}/refund/ \
  -H "Authorization: Bearer sk_live_..." \
  -H "Content-Type: application/json" \
  -d '{
    "amount": 500,
    "reason": "customer_request"
  }'