Lesson 3 / 25

The Core Stripe Objects

Customers, products, prices, intents and invoices.

A map of the main resources

A Customer represents a buyer and can hold saved payment methods, an email and addresses. A Product describes what you sell; a Price says how much and how often (one-off or recurring) in a currency, and one product can have many prices. A PaymentIntent tracks one attempt to collect a payment through its lifecycle (requires_payment_method, requires_confirmation, requires_action, processing, requires_capture, succeeded, canceled). A PaymentMethod is a card, wallet or bank account used to pay. A Charge is the record of an individual payment attempt created by a PaymentIntent. An Invoice is a bill, often generated by a Subscription, which bills a customer on a recurring Price. IDs carry prefixes such as cus_, prod_, price_, pi_, pm_, ch_, in_ and sub_.

Creating a customer, product and price

Node.js library calls (IDs are placeholders).

const customer = await stripe.customers.create({
  email: 'asha@example.com',
  name: 'Asha Verma',
  metadata: { userId: 'u_42' },   // link back to your own database
});

const product = await stripe.products.create({ name: 'Pro Plan' });

const monthly = await stripe.prices.create({
  product: product.id,
  unit_amount: 1500,               // 15.00
  currency: 'usd',
  recurring: { interval: 'month' },
});

const oneOff = await stripe.prices.create({
  product: product.id,
  unit_amount: 9900,               // 99.00 one-time setup fee
  currency: 'usd',
});

A shop catalogue and its receipts

Products and prices are the catalogue on the shelf, the customer is the loyalty card, and each PaymentIntent is the till transaction that records whether the sale went through.

Quick check: Which object tracks a single payment from creation to success?

  • Customer
  • Product
  • Price
  • PaymentIntent
Answer

PaymentIntent — A PaymentIntent moves through statuses until it succeeds or is canceled.