Create recurring charges
Charge customers off-session using a stored payment method token and the Pay.com API.
Use the Pay.com API to charge a customer's stored payment method without them being present. This approach gives you full control over when each charge fires, the amount, and retry logic.
If you want Pay.com to manage the billing schedule automatically, see create a subscription instead.
Requirements
Before you charge a stored card off-session, make sure you have the following:
- A stored payment method ID (
pm_card_xxx) from a previous on-session charge with"setup_future_usage": "off_session". See save a payment method. - Retrieve your API credentials from the Pay.com dashboard.
- Generate a unique
idempotency-keyheader for each request. - The
underlying_network_idfrom the initial charge if you have multiple active recurring sequences on the same card.
When you created the initial charge with "setup_future_usage": "off_session",
the response included two values you need for future recurring charges:
payment_method: the stored card ID (pm_card_...)underlying_network_id: the network transaction ID that links all charges in this recurring sequence
Charge the stored card
Create the charge with "off_session": true, then handle its result in your backend.
- 1
Create the recurring charge
Send a
POSTrequest to/v1/chargeswith"off_session": true. Amounts are in minor units (the smallest currency unit). For example,5000equals $50.00 USD.There are four ways to target the stored card. Choose the one that fits how your system stores customer data.
Pass the
pm_card_...ID insource. Pay.com looks up theunderlying_network_idautomatically. Use this when you store the payment method ID in your own database.{ "amount": 5000, "currency": "usd", "source": "pm_card_687080745486778368", "off_session": true, "description": "Monthly subscription renewal", "reference": "sub-renewal-pm-001" }{ "id": "chrg_687080841926412288", "resource": "charge", "amount": 5000, "amount_human_readable": "50.00", "currency": "usd", "status": "succeeded", "payment_method": "pm_card_687080745486778368", "customer_reference_id": "cust-jane-doe-recurring-001", "test_mode": true } - 2
Handle the response
Because recurring charges happen in the background, your system must handle each response status programmatically.
succeeded: The charge was approved and the funds captured. Settlement to your account happens later (seepaid).pending: Used for payment methods that require bank confirmation, such as SEPA or ACH.
A declined charge doesn't return a status. The API returns HTTP
400witherror.type: "payment_method_error", the charge ID inerror.charge, and adecline_code, often for insufficient funds or an expired card. Trigger a retry or prompt the customer to update their payment method. See decline codes.
Listen for webhooks
Because the customer is not present during recurring billing, subscribe to the following events to automate fulfillment and recovery logic on your backend:
charge.succeeded: The payment was confirmed. Use this to keep the subscription active.charge.failed: The charge was declined. Use this to send recovery emails or retry the payment.
Verify each event's signature with the Pay-Signature header and your
endpoint's signing secret (HMAC SHA-256) before you act on it. See
verify webhook signatures.
Next steps
- Create a subscription: set up automated recurring billing with Pay.com managing the schedule.
- Manage subscriptions: handle renewals, failed charges, retries, payment method updates, and cancellations.
- Webhooks: set up your endpoint and verify signatures.
- Refund a charge: process full or partial returns for settled recurring charges.