Test modeDucat runs on Stripe's test mode for now, so no real card is charged.

Use cases

SaaS subscriptions

A team signs up on your site, chooses a plan, pays on Stripe's page, and your product switches the plan on. Later they add seats, switch to yearly, or cancel, in your billing page or Ducat's portal. This is exactly how ducatpay.dev sells its own Growth plan.

Step by step

  1. Make your plans

    One price per plan and interval, matched on your own metadata.plan so a deploy script makes only the missing ones.

    POST /v1/prices

  2. One customer per team

    Made the first time the team opens checkout, kept on the team's row.

    POST /v1/customers

  3. Checkout

    Send the team to Stripe's page with your price and the number of seats.

    POST /v1/checkout-sessions

  4. Switch the plan on

    On the success page, then from every event: read the subscription back and set the team's plan from its status.

    GET /v1/subscriptions/{id}

  5. Billing page

    Plan and status, invoices with Stripe's pages, cancel at the period's end and undo.

    GET /v1/customers/{id}/invoices

  6. Self-serve changes

    A portal link where the customer switches plan, sets seats and replaces their card.

    POST /v1/customers/{id}/portal-sessions

In code

Switch the plan on from the subscription, whichever way you heard

TypeScript

// ducat(): the small fetch helper from the quickstart
const ON = new Set(["active", "trialing"]);

export async function applySubscription(subId: string) {
  const sub = await ducat("GET", `/v1/subscriptions/${subId}`);
  await db.teams.update(sub.metadata.team, {
    plan: planByPrice(sub.items[0]?.price),
    seats: sub.items[0]?.quantity,
    paid: ON.has(sub.status),
    endsAt: sub.cancel_at_period_end ? sub.current_period_end : null,
  });
}

Python

# ducat(): the small helper from the quickstart
ON = {"active", "trialing"}

def apply_subscription(sub_id: str) -> None:
    sub = ducat("GET", f"/v1/subscriptions/{sub_id}")
    item = (sub["items"] or [{}])[0]
    db.teams.update(sub["metadata"]["team"],
        plan=plan_by_price(item.get("price")),
        seats=item.get("quantity"),
        paid=sub["status"] in ON,
        ends_at=sub["current_period_end"] if sub["cancel_at_period_end"] else None)

curl

curl -s https://api.ducatpay.dev/v1/checkout-sessions/cs_test_… -H "authorization: Bearer $DUCAT_TOKEN"
# → {"status": "complete", "payment_status": "paid", "subscription": "sub_…", …}

curl -s https://api.ducatpay.dev/v1/subscriptions/sub_… -H "authorization: Bearer $DUCAT_TOKEN"
# → {"status": "active", "items": [{"price": "price_…", "quantity": 3}], "metadata": {"team": "org_acme"}, …}

Every change reaches you

Renewals, failed payments, plan changes and cancellations made anywhere, the portals included, arrive as events: pushed and signed, or polled.

Good to know

Features it uses

Start building in test mode

Sign up, make a key, and take a test payment in a few minutes. No card needed.