Checkout
Accept a payment with Checkout
Create a Checkout Session on your server, open Hosted Checkout, then mark the order paid after confirmation (ship or unlock access).
Accept a payment with Checkout
Use Checkout when a buyer pays a fixed amount once (order, invoice, top-up). Your server creates a Checkout Session; the buyer pays on Hosted Checkout (pay.doggiepay.com) or via the Button SDK; after webhook checkout.paid (and/or a trusted server-side status read), mark the order paid and continue shipping or unlocking access.
Prerequisite: Getting started (Secret key + Request-Id).
Your server Doggie Pay Buyer
| | |
|-- POST /checkout/sessions -->| |
|<-- hosted_url, id -----------| |
|-- open hosted_url ---------->|---------------------->|
| |<-- on-chain USDC/USDT --|
|<-- webhook checkout.paid ----| |
|-- fulfill order -------------| |
1. Create a Checkout Session
POST /v1/checkout/sessions
Auth: Secret or Publishable (+ Request-Id)
Request body
| Field | Type | Required | Description |
|---|---|---|---|
amount | string | Yes | Positive decimal amount as a string (e.g. "19.99") |
currency | string | Yes | Asset code, e.g. USDC, USDT |
chain | string | Cond. | Single chain alias (e.g. ETH, BASE). Use chain or chains. |
chains | string[] | Cond. | Multiple chain aliases; buyer can pick among pre-claimed addresses |
success_url | string | No | Redirect after Hosted success flow |
cancel_url | string | No | Redirect after cancel |
metadata | object | No | String map for your correlation IDs (order_id, etc.) |
Example
curl -sS https://api.doggiepay.com/v1/checkout/sessions \
-H "Authorization: Bearer dp_live_sk_YOUR_SECRET" \
-H "X-DoggiePay-Request-Id: $(uuidgen | tr '[:upper:]' '[:lower:]')" \
-H "Idempotency-Key: order-1001-pay" \
-H "Content-Type: application/json" \
-d '{
"amount": "19.99",
"currency": "USDC",
"chain": "BASE",
"success_url": "https://merchant.example/orders/1001/paid",
"cancel_url": "https://merchant.example/orders/1001/cancel",
"metadata": { "order_id": "1001" }
}'
Response data fields
| Field | Type | Description |
|---|---|---|
id | uuid | Session id (same as payment_id) |
payment_id | uuid | Payment aggregate id (alias of id) |
status | string | pending | paid | expired | cancelled | partial_refund | refunded |
amount | string | Charged amount |
currency | string | Asset |
chain | string | Primary / selected chain alias |
address | string | Deposit address when a single chain is used |
chain_options | array | Multi-chain: [{ "chain", "address" }, …] |
client_secret | string | For Hosted / public poll (treat as sensitive) |
hosted_url | string | Open this URL for the buyer (…/c/{id}#client_secret=…) |
expires_at | string | ISO-8601 expiry when present |
success_url / cancel_url | string | Echo of create input |
metadata | object | Echo of create input |
refundable | bool | Whether a refund can be requested |
cancellable | bool | Whether cancel is allowed |
tx_hash | string | Set after on-chain confirmation (when available) |
refunded_amount | string | Cumulative refunded amount when applicable |
created_at | string | ISO-8601 |
Recommended: create with Secret on the server, then pass only hosted_url (or id + client_secret) to the browser.
Create errors
| HTTP | error.code | Meaning |
|---|---|---|
| 400 | invalid_amount | Bad amount/currency |
| 400 | invalid_chain | Chain not enabled / invalid |
| 400 | invalid_body | Non-JSON body |
| 503 | pool_exhausted | No idle payment address (retry later) |
| 503 | checkout_unavailable | Checkout not configured |
| 422 | checkout_create_failed | Other create failure |
2. Open Hosted Checkout
Redirect or window.open the hosted_url. Hosted lives on https://pay.doggiepay.com.
Button SDK (optional)
npm install @doggiepay/checkout
import { mountDoggiePayButton } from "@doggiepay/checkout";
mountDoggiePayButton("#pay", {
hostedUrl, // from your server create response
openMode: "new_tab", // or "same_tab"
onPaid: () => refreshOrder(),
});
| Option | Type | Description |
|---|---|---|
hostedUrl | string | Preferred: full URL from create |
sessionId + clientSecret | string | Alternative to hostedUrl |
openMode | string | new_tab (default) or same_tab |
onPaid | function | Fired when client-side poll sees paid (still verify with webhook) |
3. Read session status
Merchant (Secret)
GET /v1/checkout/sessions/{id}
curl -sS "https://api.doggiepay.com/v1/checkout/sessions/SESSION_UUID" \
-H "Authorization: Bearer dp_live_sk_YOUR_SECRET" \
-H "X-DoggiePay-Request-Id: $(uuidgen | tr '[:upper:]' '[:lower:]')"
Public / Hosted poll (no Bearer)
Provide client_secret via query or header:
GET /v1/checkout/sessions/{id}?client_secret=…
X-DoggiePay-Client-Secret: …
Do not mark the order paid from a browser redirect alone — use Webhooks.
4. Cancel a session
POST /v1/checkout/sessions/{id}/cancel
Auth: Secret, or client_secret (Hosted cancel)
Only while cancellable is true (typically pending).
Emits webhook checkout.cancelled.
5. After payment is confirmed
- Prefer
checkout.paidwebhook as source of truth - Optionally double-check
GET …/sessions/{id}→status === "paid" - Idempotently mark your order paid using
payment_id/metadata.order_id, then ship or unlock access - Handle
checkout.expiredandcheckout.cancelledso inventory is released
6. Refund a paid Checkout (optional)
POST /v1/refunds — Secret; Payment-only (not customer deposits).
| Field | Required | Description |
|---|---|---|
payment_id | Yes* | Session / payment UUID (checkout_session_id accepted as alias) |
checkout_session_id | Yes* | Alias of payment_id |
amount | Yes | Refund amount string |
currency | Yes | Must match payment |
to_address | Yes | Buyer receive address |
chain | Yes | Outflow chain (enabled for the asset) |
curl -sS https://api.doggiepay.com/v1/refunds \
-H "Authorization: Bearer dp_live_sk_YOUR_SECRET" \
-H "X-DoggiePay-Request-Id: $(uuidgen | tr '[:upper:]' '[:lower:]')" \
-H "Content-Type: application/json" \
-d '{
"payment_id": "SESSION_UUID",
"amount": "19.99",
"currency": "USDC",
"chain": "BASE",
"to_address": "0xBuyer…"
}'
Follow progress via refund.* webhooks and GET /v1/refunds.
7. Next steps
- Webhooks — HMAC verify
checkout.paid - Customers rail — long-lived deposit addresses for in-app balances
