पाठ 13 / 25

Recurring Prices and Subscriptions

Products, recurring prices and creating a subscription.

How recurring billing works

A recurring Price has an interval (day, week, month or year) and optionally an interval_count, for example every 3 months. A Subscription links a Customer to one or more prices through subscription items. At the start of each billing period Stripe creates an Invoice, finalises it and attempts payment with the customer's default payment method. The simplest way to start a subscription is Checkout in subscription mode, which collects the payment method, handles authentication and creates the Customer and Subscription. Trials, coupons, usage-based and tiered pricing build on the same objects.

Recurring revenue on autopilot

Recurring prices create subscriptions, which generate invoices that are paid automatically each period.

Three ideas: recurring billing, the subscription lifecycle, and self-service plan changes.
Figure 5.1 — Price, subscription, invoice and payment each period.

Subscription Checkout with a trial

Server-side Node.js.

const session = await stripe.checkout.sessions.create({
  mode: 'subscription',
  customer: 'cus_...',                       // or let Checkout create one
  line_items: [{ price: 'price_monthly_...', quantity: 1 }],
  subscription_data: {
    trial_period_days: 14,
    metadata: { userId: 'u_42' },
  },
  success_url: 'https://example.com/billing?session_id={CHECKOUT_SESSION_ID}',
  cancel_url: 'https://example.com/pricing',
});
res.redirect(303, session.url);

A magazine subscription

The price is the yearly rate on the subscription card, the subscription is your entry on the publisher's list, and each invoice is the renewal notice that is paid automatically from your saved card.

त्वरित जाँच: What does Stripe generate at the start of each billing period of a subscription?

  • A new Product
  • An Invoice that it then tries to pay
  • A new Customer
  • A Payment Link
Answer

An Invoice that it then tries to pay — Subscriptions bill through invoices.