xtopaydocs

Subscriptions

Charge customers on repeat. Make a plan, put a customer on it, and Xtopay asks them to pay each period.

Live

Plans and subscriptions work today, with test and live keys.

Paid by link, for now

Each period, Xtopay makes a checkout for it and sends its link to your customer by email, if you gave one. You get the link too, as renewal.url on the subscription and in its webhooks, to send on WhatsApp or by SMS. They pay with Mobile Money as usual. Automatic charging (MoMo mandates and saved cards) comes later: collection will say which a subscription uses, and nothing else changes for you.

A plan is what you charge and how often: weekly, monthly, every 3 months or yearly, with an optional free trial. A subscription puts one customer on a plan. Each period is a renewal: its checkout is made a few days before the period starts (a day before, for weekly plans) and its link goes to your customer.

StatusWhat it means
incompleteWaiting for its first payment
trialingOn its free trial; the first payment is asked for as the trial ends
activePaid up
past_dueA renewal is a day late. Your customer is reminded
cancelledStopped: by you, or because a renewal wasn't paid before its checkout ran out (30 days, or the period's length if shorter)

Periods follow on from the day it started, whenever each is paid: a monthly plan started on the 31st renews on the last day of shorter months.

Plans

POST/v1/plans

Prop

Type

curl https://api.xtopay.co/v1/plans \
  -H "Authorization: Bearer sk_test_…" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Family meal plan",
    "amount": 1200,
    "interval": "monthly",
    "trial_days": 7
  }'

GET /v1/plans lists them, GET /v1/plans/:id gets one, and PATCH /v1/plans/:id changes its name, description, price or free trial. A new price applies from each subscriber's next renewal. POST /v1/plans/:id/archive stops it taking new subscribers (those on it carry on); POST /v1/plans/:id/restore undoes that.

Subscribe a customer

POST/v1/subscriptions

Prop

Type

curl https://api.xtopay.co/v1/subscriptions \
  -H "Authorization: Bearer sk_test_…" \
  -H "Content-Type: application/json" \
  -d '{
    "plan": "pln_7k2m9qh4tz3bxw5r8n6p",
    "customer": {
      "name": "Akosua Boateng",
      "phone": "024 400 1234",
      "email": "akosua@example.com"
    },
    "metadata": { "account": "1042" }
  }'

Without a free trial its first renewal is made at once: send your customer its renewal.url (we've emailed it too, if you gave an email). A customer can be on a plan once at a time.

Response
{
  "success": true,
  "data": {
    "id": "sub_9t4w…",
    "reference": "XTP-SB-9T4W2KQM",
    "status": "incomplete",
    "collection": "request",
    "plan": { "id": "pln_7k2m…", "name": "Family meal plan", "amount": 1200, "interval": "monthly" },
    "customer": { "id": "cus_…", "name": "Akosua Boateng", "phone": "233244001234", "email": "akosua@example.com" },
    "next_billing_at": "2026-11-24T10:00:00.000Z",
    "trial_ends_at": null,
    "current_period_end": null,
    "paid_count": 0,
    "total_paid": 0,
    "renewal": {
      "id": "sbr_…",
      "amount": 1200,
      "due_at": "2026-11-24T10:00:00.000Z",
      "period_end": "2026-12-24T10:00:00.000Z",
      "url": "https://pay.xtopay.co/chk_…",
      "sent_at": "2026-11-24T10:00:00.000Z"
    },
    "metadata": { "account": "1042" }
  }
}

GET /v1/subscriptions lists them (filter with status, plan or customer); GET /v1/subscriptions/:id adds its renewals, each period with its status (open, paid, expired or void).

Cancel

POST/v1/subscriptions/:id/cancel

It stops at once: nothing more is asked for, and a renewal still open can't be paid any more. What they've paid stays paid.

Webhooks

EventWhen
subscription.createdA customer was put on a plan
subscription.renewedA period was paid; with payment_reference
subscription.past_dueA renewal is a day late
subscription.cancelledIt stopped; cancel_reason is business or unpaid

Each period's payment also sends payment.successful, like any other.

Testing

A test key's plans and subscriptions are test copies, kept apart from live ones: their renewals are test checkouts, which you approve or decline yourself, and they email nobody.

On this page