Customers are your buyers. https://starmedpharmacy.com/ Information like names, email addresses, and payment methods (credit cards, debit cards, etc.) is stored on the Customer object.
Products are what you sell.
Prices represent how much and how often you charge for a product. You can define multiple prices for a product so you can charge different amounts based on currency or interval (monthly, yearly, etc.).
Subscriptions represent your Customers’ access to a product and require a customer and payment method to be created. The status of a subscription indicates when to provision access to your service for a customer.
Invoices are generated when it’s time to bill a customer for a subscription. Invoices have line items, tax rates, and the total amount owed by a customer.
Payment Intents represent the state of all attempts to pay an invoice.
See our Pasha photo hosting demo for an example integration. This demo is used to illustrate how Stripe’s objects are used in a subscriptions integration. If you’re ready to build your own integration, see our fixed-price guide.
On the frontend, the landing page collects an email address first. In your application, there might be other customer-specific information you want to collect like a username or address. After the customer clicks the signup button, the information collected on the landing page is sent to the backend. From there, a new customer is created and the pricing page is displayed on the frontend.
The pricing page displays the different subscription options. This information is based on the products and prices you create when you first set up your integration, you don’t create new ones every time customers sign up. Your pricing page displays the prices you created, and your customers choose the option they want. In the Pasha example, as soon as a customer selects an option, a payment form is displayed.
The payment form collects a name and card information. This form is hosted by Stripe and is one of the key features that allows you to collect payments and remain PCI compliant. After clicking the Subscribe button:
The payment method is saved to the customer and set as the default payment method. This is required for subsequent payments.
A new subscription is created, with the customer and price IDs.
An invoice is generated for the initial subscription cycle.
The invoice is paid using the saved payment method.
After a successful payment, a confirmation page is displayed. At this point it’s safe to provision the product for the customer. This generally means:
Verifying the status of the subscription is active.
Granting the customer access to the products and features they subscribed to.
How payments work with subscriptions
The payment process differs across payment methods and geographical locations. Payments can also fail initially (customer enters the wrong card number, insufficient funds, etc.) so there are a few payment outcomes you need to understand.
The lifecycle of every payment is tracked with a Every time payment is due for a subscription, an invoice and are generated. ID is attached to the invoice and you can access it from the Invoice and Subscription objects. The state of the affects the state of the invoice and the subscription. Here’s how the different outcomes of a payment map to the different statuses:
PAYMENT OUTCOME PAYMENTINTENT STATUS INVOICE STATUS SUBSCRIPTION STATUS
Success succeeded paid active
Fails due to card error open incomplete
Fails due to authentication open incomplete
The following sections explain these statuses and the actions to take for each.
When the payment succeeds, the subscription is active and the status of is succeeded. The payment is complete and you should provision access to your product.
RESPONSE SUBSCRIPTION PAYMENTINTENT
Requires payment method
If payment fails because of a card error such as a decline, the status of the and the subscription is incomplete.
RESPONSE SUBSCRIPTION PAYMENTINTENT
To resolve these scenarios:
Notify the customer, collect new payment information, and create a new payment method
Attach the payment method to the customer
Update the default payment method
Pay the invoice using the new payment method