Skip to Content
Docs

The Commerce API

The Commerce API owns checkout, payment links, the catalog, orders, invoices, and subscriptions, on the Pay.com API's hosts and keys.

The Commerce API runs checkout sessions and their design profiles, payment links, your catalog, orders, invoices, credit notes, Insights, and subscriptions. It's a separate API on the same hosts as the Pay.com API, and it takes the same API keys, so your workspace's keys call both and there's no Commerce account to create. Every route is in the Commerce API reference.

How the two APIs split the work

Each resource belongs to either Commerce or the Pay.com API, never both. Commerce doesn't add routes or request fields to Pay.com API resources, so every route has one owner and every object has one shape.

Both APIs share everything else:

  • Base URLs: https://api.sandbox.pay.com/v1 in the sandbox and https://api.pay.com/v1 live.
  • Authentication: HTTP Basic, with your secret key as the password and an empty username. See Authentication.
  • Idempotency: an idempotency-key header makes a POST safe to retry. See Idempotency and retries.
  • Lists: the same limit, cursor, and created filters, sorted by creation time, oldest first. See Pagination and filtering.
  • Errors: the same error envelope, with error.type, error.code, and error.message. The Commerce API's error.type can also be authentication_error, permission_error, not_found_error, or rate_limit_error, so read the HTTP status first, as Handle errors describes.
  • Webhooks: Commerce's events reach your existing webhook endpoints, in the same envelope and with the same signature.

Amounts are integers in the smallest currency unit, for example 1999 for $19.99 USD. IDs start with a prefix that names the object, such as ord_691204561890402304, and timestamps are ISO 8601, in UTC. Objects created with a sandbox key have test_mode set to true.

What Commerce owns

Commerce owns these resources and every route under them:

ResourceRoutesReference
Checkout sessions/v1/checkout, /v1/checkout/{checkout_session_id}, and its actionsCheckout sessions
Payment links/v1/payment_links, /v1/payment_links/{link_id}Payment links
Products/v1/products, /v1/products/{product_id}Products
Prices/v1/prices, /v1/prices/{price_id}Prices
Shipping rates/v1/shipping_rates, /v1/shipping_rates/{shipping_rate_id}Shipping rates
Orders/v1/orders, /v1/orders/{order_id}, its refund, and its refundsOrders
Invoices/v1/invoices, /v1/invoices/{invoice_id}, and its actionsInvoices
Credit notes/v1/credit_notes, /v1/credit_notes/{credit_note_id}Credit notes
Commerce settings/v1/commerce_settingsCommerce settings
Design profiles/v1/design_profiles, /v1/design_profiles/{design_profile_id} and its actions, and /v1/design_profile_previewsDesign profiles
Insights/v1/insightsInsights
Subscriptions/v1/subscriptions and every route under itSubscriptions
Subscription settings/v1/subscription_settingsSubscription settings
Subscription connections/v1/subscription_connections and its actionsSubscription connections
Portal sessions/v1/portal_sessionsCustomer portal sessions
Entitlements/v1/entitlementsEntitlements
Customer claims/v1/customer_claimsCustomer claims
Report runs/v1/report_runs, /v1/report_runs/{report_run_id}Report runs

Prices replace subscription packages. A recurring price has a schedule, and a subscription bills prices the same way a checkout session's line items do. Your subscription settings hold the failed-renewal and dispute rules that subscription packages previously held. An API key's permissions set which of these resources it can call, in the Checkout, Catalog, Orders, Subscriptions, and Financial reporting groups.

What the Pay.com API keeps

The Pay.com API continues to own refunds, customers, payment sessions, setup sessions, tokenization sessions, charges, holds, tax quotes, settlements, payment method domains, and webhook endpoints.

Charges and refunds made for an order include a read-only order field linking the payment back to what was sold. It's the only field Commerce adds to them.

Refunds go through what billed them

A refund goes through the Commerce object that billed it, so orders, invoices, and credit notes stay in sync:

What was billedHow to refund it
An orderPOST /v1/orders/{order_id}/refund. Calling POST /v1/refunds for the order's charge returns 422 with use_order_refund.
A renewal, on an invoice Pay.com issuedPOST /v1/invoices/{invoice_id}/refund. Calling POST /v1/refunds for the invoice's charge returns 422 with use_invoice_refund.
A renewal, on an invoice another engine issuedAt that engine. When Pay.com collected the charge, the engine asks Pay.com to refund it.
A payment your system scheduled (merchant_scheduled)POST /v1/refunds, since Commerce has no order or invoice for it.

The order and invoice routes refund what's left by default, or the items or lines you send, with their tax. They return the same refund object (rfnd_) as the Pay.com API, so GET /v1/refunds/{id} returns it as well. When there's an invoice to credit, Pay.com issues a credit note. This works regardless of who sells. When Pay.com is the seller, Pay.com processes the refund on its own accounts. See Orders and refunds.

Subscription options

subscription_options specifies which engine runs a subscription and what it starts with. Only Commerce routes accept it:

Payment sessions, setup sessions, charges, and holds don't take subscription_options. For an external (merchant_scheduled) subscription billed by your system, collect each payment with POST /v1/subscriptions/{subscription_id}/payments.

A price's own subscription_options sets the default engine, connection, failed-payment rules, and dispute rules for subscriptions on that price, overriding your account's subscription settings. Pay.com takes the engine from the session or request, then the price, then your account default, then pay_com. When Pay.com sells, the engine is pay_com. The engine is locked when the customer confirms, and the response shows how it resolved, with the seller and processor, in subscription_options.resolved. See Choose a subscription engine.

Webhook events

Commerce events lists every event Commerce sends, grouped by the object it carries. The checkout session and subscription events Pay.com sends today keep their names under Commerce, except subscription.payment_method.upcoming_expiry, which Commerce doesn't send. Each one carries the Commerce object in data, so check the fields your listeners read. For example, a canceled subscription's cancellation_reason is requested, ended, withdrawn, payment_failed, or dispute, and a subscription has trial_end and canceled_at, not trial_period_end and ended_at. Pay.com sends subscription.upcoming_renewal when a renewal is 7 days away. Commerce also adds events, such as checkout_session.expired, subscription.created, and subscription.paused.

Earlier reference pages

The Pay.com API reference's checkout, payment links, and subscriptions pages now redirect to their Commerce pages, and the subscription package pages to prices.

Next steps

Was this page helpful?