Manage subscriptions
List and retrieve subscriptions, handle failed charges, update payment methods, and cancel subscriptions with the Commerce API.
Once a subscription is active, Pay.com handles billing automatically. From your server, you can still find a customer's subscriptions, read their state, respond to failed charges, update the payment method, and cancel. Customers can make the same changes themselves in the customer portal.
Requirements
Before you can manage subscriptions, you need:
- A subscription ID (
sub_...). Follow the create a subscription guide to create one. - A payment method saved for off-session use if you plan to update the billing card. See save a payment method.
List a customer's subscriptions
Send a GET request to /v1/subscriptions
with customer_reference_id to find every subscription a customer has, from
both sellers and every engine. Filter by status, and page through the
results with limit and starting_after.
curl -G https://api.sandbox.pay.com/v1/subscriptions \
-u ':sk-pay-com-sandbox-…' \
-d customer_reference_id=cust-jane-doe-001{
"resource": "subscriptions",
"data": [
{
"id": "sub_684790996696828928",
"resource": "subscription",
"status": "active",
"customer_reference_id": "cust-jane-doe-001",
"engine": { "type": "pay_com", "connection": null, "collection_model": "native" },
"access": { "status": "granted", "ends_at": null },
"current_period_end": "2026-12-25T10:30:00.000Z"
}
],
"has_more": false
}Retrieve a subscription
Send a GET request to /v1/subscriptions/{subscription_id}
to get the current state of a subscription:
curl https://api.sandbox.pay.com/v1/subscriptions/sub_684790996696828928 \
-u ':sk-pay-com-sandbox-…'{
"id": "sub_684790996696828928",
"resource": "subscription",
"status": "active",
"customer_reference_id": "cust-jane-doe-001",
"payment_method": "pm_card_684790996696828928",
"reference": "sub-jane-doe-premium-001",
"items": [
{ "id": "subitem_684790996696828930", "price": "prc_691180240037724160", "price_version": 1, "quantity": 1 }
],
"current_period_start": "2026-11-25T10:30:00.000Z",
"current_period_end": "2026-12-25T10:30:00.000Z",
"latest_invoice": { "id": "inv_691230018734120960", "number": "INV-2026-0042", "status": "paid", "issuer": "pay_com" }
}The status field reflects the current billing state. See
Subscription statuses
for each status and what causes each transition.
Handle a failed charge
When a renewal fails, the subscription moves to unpaid and Pay.com retries
it on the failed_payment rules in your
subscription settings,
or the price's own. Each attempt fires a subscription.attempted event. Once
the retries are used up, Pay.com applies final_action. With cancel, the
subscription ends with cancellation_reason set to payment_failed and fires
subscription.canceled. With pause, billing is suspended and the
subscription moves to paused. With leave_unpaid, it stays unpaid. See
Failed renewals.
You can also retry the renewal yourself. Send a POST request to
/v1/subscriptions/{subscription_id}/retry
with no body. It charges the payment method on the subscription, so to use
another card, update the payment method first.
The retry takes only unpaid subscriptions on Pay.com's engine. Other
engines retry on their own, so the request returns 422 with
not_collector.
curl -X POST https://api.sandbox.pay.com/v1/subscriptions/sub_684790996696828928/retry \
-u ':sk-pay-com-sandbox-…' \
-H "idempotency-key: $(uuidgen)"{
"id": "sub_684790996696828928",
"resource": "subscription",
"status": "active",
"current_period_end": "2026-12-25T10:30:00.000Z",
"last_failure": null
}A successful retry returns status: active. A failed retry returns
status: unpaid. Subscribe to these events to automate retry and recovery
logic:
subscription.attempted: fires for each renewal attempt.subscription.active: fires when a retry succeeds and the subscription recovers.
Update a payment method
To replace the billing card on an active subscription, send a PATCH request
to /v1/subscriptions/{subscription_id}
with the new payment method ID. The card must already be saved for
off-session use. See
save a payment method.
curl -X PATCH https://api.sandbox.pay.com/v1/subscriptions/sub_684790996696828928 \
-u ':sk-pay-com-sandbox-…' \
-H "Content-Type: application/json" \
-d '{ "payment_method": "pm_card_685125114794084354" }'{
"id": "sub_684790996696828928",
"resource": "subscription",
"status": "active",
"payment_method": "pm_card_685125114794084354"
}Change the plan or quantity
To move a subscription to another price or quantity, preview the change with
POST /v1/subscriptions/{subscription_id}/previews,
then apply the preview with
PATCH /v1/subscriptions/{subscription_id}.
See Plan changes.
Cancel a subscription
Canceling a subscription stops future billing without immediately ending
access. Send a POST request to /v1/subscriptions/{subscription_id}/cancel.
You can cancel at the end of the current billing period or on any later
date.
Send an empty body. The subscription stays active until the current
period ends, then Pay.com cancels it automatically.
curl https://api.sandbox.pay.com/v1/subscriptions/sub_684790996696828928/cancel \
-u ':sk-pay-com-sandbox-…' \
-H "Content-Type: application/json" \
-H "idempotency-key: $(uuidgen)" \
-d '{}'{
"id": "sub_684790996696828928",
"resource": "subscription",
"status": "active",
"cancel_at": "2026-12-25T10:30:00.000Z",
"current_period_end": "2026-12-25T10:30:00.000Z",
"canceled_at": null
}In both cases the subscription doesn't end immediately, and the customer
keeps access until it does. The canceled_at field is set when the
cancellation takes effect. The cancellation_reason field records why it
ended (requested when you or the customer canceled it, ended when it
reached its cancel_at date, withdrawn when the customer withdrew from the
contract, payment_failed when retries were used up, or dispute after a
dispute action).
Test a renewal in the sandbox
You don't have to wait for a billing date to test a renewal. In the
sandbox, send a POST request to
/v1/subscriptions/{subscription_id}/simulate/charge
to run the next renewal immediately without waiting for the scheduled billing
date. The request returns the subscription after the renewal, and Pay.com sends
the renewal's subscription events,
such as subscription.charged. Live keys return 403.
curl -X POST https://api.sandbox.pay.com/v1/subscriptions/sub_684790996696828928/simulate/charge \
-u ':sk-pay-com-sandbox-…' \
-H "idempotency-key: $(uuidgen)"Next steps
- Trials, plan changes, and canceling: add a trial, preview a plan change, and let customers cancel online.
- Save a payment method: store a card for off-session use before updating a subscription's billing method.
- How subscriptions work: statuses, lifecycle, and failed renewals.