# Designing an integration Learn what choices you need to make to integrate subscriptions into your business. Before you start building your *subscription* integration, you need to choose the right integration path, especially if you’re not writing the code yourself and need to collaborate with others. Use this guide to help you decide on the best way to build your integration, and follow the links to in-depth, step-by-step guides. This guide is for users who aren’t necessarily writing code, but want to learn about the high-level subscription integration process so that they can create plans and organize resources. If you already know how you’re going to build your integration, or if you want to start coding right away, see our [integration builder](https://docs.stripe.com/billing/quickstart.md). ## Subscription models You need to understand the available subscription models to help you make later choices, such as which pricing model and payment form to use. First, consider your business model: - If you want customers to pay, then provision access to your service, click the **pay up front** tab below to learn more. - If you want to collect payment details, then offer customers a free trial period before billing them, click the **free trial** tab below to learn more. - If you want to provide users access to your service without asking them for any payment information (a _freemium_ model), click the **freemium** tab below to learn more. ![Pay-up-front subscription model](images/billing/subscriptions/sub_model_pay_up_front.svg) Pay-up-front model In the pay-up-front model, you collect payment details and charge customers before provisioning access to your service. After the initial charge, you continue to charge customers the same fixed price for the same service at regular intervals. In this model, you use the Dashboard or [Subscriptions API](https://docs.stripe.com/api/subscriptions.md) manage customer subscriptions. If you want to allow customers to modify their subscriptions directly, you need to integrate the [customer portal](https://docs.stripe.com/customer-management.md). For example, a photo hosting company that offers basic and premium service levels and charges customers on a monthly basis might have this setup: - One product for the basic option - One product for the premium option - One price for the basic option ( per month) - One price for the premium option ( per month) A typical flow for this model would look like the following: In step 3, the specific event you’re looking for is called [checkout.session.completed](https://docs.stripe.com/billing/subscriptions/build-subscriptions.md#provision-and-monitor). If you’re using [Elements](https://docs.stripe.com/payments/elements.md), provision access after receiving an [invoice.paid](https://docs.stripe.com/billing/subscriptions/build-subscriptions.md#provision-access) event. In step 4, look for an event called `invoice.paid`. 1. The customer chooses their plan (basic or premium). 1. You collect payment information. 1. You provision access to your service. You know when to do this by monitoring [webhook events](https://docs.stripe.com/webhooks.md). 1. You continue to provision access for customers throughout the lifecycle of the subscription. Check regularly to make sure you’re not providing access if a customer’s payment has failed. See the [integration guide](https://docs.stripe.com/billing/subscriptions/build-subscriptions.md) to learn how to build an integration with a low-code approach that uses a prebuilt and hosted page from [Stripe Checkout](https://docs.stripe.com/payments/checkout.md) or a custom version with [Stripe Elements](https://docs.stripe.com/payments/elements.md). ![Free trial subscription model](images/billing/subscriptions/sub_model_free_trial.svg) Free trial model In the free trial model, you provide access to your service for a limited time before charging the customer. Creating the subscription automatically creates an invoice for . At the end of the trial period, a new billing period starts for the customer. When the billing period ends, another invoice is created with an amount based on the price you’ve defined for the product. You can offer a free trial for fixed-amount and metered usage subscriptions. Additionally, you can offer a free trial of a subscription without collecting payment details from your customer. Subscriptions and invoices are created at the start of the trial and become active at the end of the trial if the customer provides a payment method. At the end of the trial period, you can pause or resume the trial. Learn more about how to configure [free trials without a payment method](https://docs.stripe.com/billing/subscriptions/trials.md#create-free-trials-without-payment). If you want to add a setup fee or another one-time charge when you create the invoice for the first billing period, you can do so with [add_invoice_items](https://docs.stripe.com/api/subscriptions/update.md#update_subscription-add_invoice_items). In a free trial model, the products and prices setup could look similar to the fixed-price model, where a photo hosting company offers basic and premium levels: - One product for the basic option - One product for the premium option - One price for the basic option ( per month) - One price for the premium option ( per month) Or the photo hosting service may set up a tiered price model, where each product still has one price but the prices include tiers that you can graduate or base on volume and tie usage: - One product for the basic option - Tier one: per month for 2TB of storage - Tier two: An additional for each GB above 2TB - Premium option - Tier one: per month for 10TB - Tier two: An additional for each GB above 10TB In either case, the flow would be roughly the same for the free trial model: For step 2, you create a subscription with [trial_end](https://docs.stripe.com/api/subscriptions/create.md#create_subscription-trial_end) to define when the trial ends (which is the preferred method). Or you can use [trial_period_days](https://docs.stripe.com/api/subscriptions/create.md#create_subscription-trial_period_days) to define how many days until the trial ends. For step 3, the event you’re looking for is `customer.subscription.trial_will_end` In step 4, an `invoice.created` event notification is also sent out. 1. The customer chooses their plan. 1. You provision access to your service. 1. Use [webhooks](https://docs.stripe.com/webhooks.md) to monitor for an event that lets you know when the trial is about to end and billing is about to begin. 1. When the trial ends, a new billing cycle starts for the customer. As soon as the trial period is up, Stripe generates an invoice. Approximately 1 hour later, Stripe attempts to charge that invoice. You can use free trials for integrations built with Stripe Checkout or Stripe Elements. For more details about free trials, see [Using trial periods on subscriptions](https://docs.stripe.com/billing/subscriptions/trials.md). ![Freemium subscription model](images/billing/subscriptions/sub_model_freemium.svg) Freemium model The freemium model is similar to the free-trial model. The primary difference is that in the freemium model you provision access to your service without collecting any payment information. In a freemium model, the products and prices setup could be similar to the other models, but in this case the photo hosting company offers a per month plan for individuals and an per month plan for teams. Customers are offered a 7-day trial that they can start without providing their credit card information. - One product for the team plan - One product for the individual plan - One price for the team plan ( per month) - One price for the individual option ( per month) This is what the flow for this model looks like: For step 2, you create a subscription with [trial_end](https://docs.stripe.com/api/subscriptions/create.md#create_subscription-trial_end) to define when the trial ends (which is the preferred method). Or you can use [trial_period_days](https://docs.stripe.com/api/subscriptions/create.md#create_subscription-trial_period_days) to define how many days until the trial ends. For step 3, the event you’re looking for is `customer.subscription.trial_will_end` In step 4, an `invoice.created` event notification is also sent out. 1. The customer chooses their plan. 1. You provision access to your service. 1. Use [webhooks](https://docs.stripe.com/webhooks.md) to monitor for an event that lets you know when the trial is about to end and billing is about to begin. 1. At this point, you also need to collect the user’s payment information or else the trial will fail to convert because you don’t have a payment method associated with the customer. You can use the customer portal to collect payment information or you can redirect them to a Checkout session to do this. 1. When the trial ends, a new billing cycle starts for the customer. As soon as the trial period is up, Stripe generates an invoice. Approximately 1 hour later, Stripe attempts to charge that invoice. ## Metered billing If you need to meter usage, see [metered billing](https://docs.stripe.com/products-prices/pricing-models.md#usage-based-pricing). You need to do this when you [create a price](https://docs.stripe.com/products-prices/manage-prices.md#create-price). ## Collect payment information If you don’t want to write a lot of code, use [Checkout](https://docs.stripe.com/payments/checkout.md), Stripe’s prebuilt, hosted payment page. See the [subscriptions with Checkout](https://docs.stripe.com/billing/subscriptions/build-subscriptions.md?ui=stripe-hosted) integration guide to get started. If you want a more customized payment form that you can embed into your existing website, use [Elements](https://docs.stripe.com/payments/elements.md), a set of prebuilt UI elements that’s part of [Stripe.js](https://docs.stripe.com/payments/elements.md). ## Display pricing information Embed a [pricing table](https://docs.stripe.com/payments/checkout/pricing-table.md) on your website to show customers pricing information for subscriptions. When customers choose a subscription option, they’re taken directly to checkout. Configure, customize, and update directly in the [Dashboard](https://dashboard.stripe.com/test/pricing-tables) without writing any code. ## Modify subscriptions If you’re collecting payment information with Checkout, you can use the [customer portal](https://docs.stripe.com/customer-management.md) to allow customers to directly update their subscription details, like payment method and frequency. See the [integration guide](https://docs.stripe.com/billing/subscriptions/build-subscriptions.md?ui=stripe-hosted) for detailed instructions on setting this up. (Before integrating, you should also be aware of the [limitations](https://docs.stripe.com/customer-management.md) of the portal.) If you’re integrating with Elements, you can add a form on the frontend to collect details about the plan they want to change (such as the price ID and their customer information) and send that to an endpoint on the backend. For more details and sample code, see the section about [letting customers change their plans](https://docs.stripe.com/billing/subscriptions/build-subscriptions.md?ui=elements#change-price) in the Elements quickstart. ## Pricing models If you’re providing the same good every month and don’t expect that to change, use a simple fixed-price model. If the price varies depending on the number of users or units, you can use volume-based or tier-based prices. For a complete list of available models and a detailed description of each one, see [examples of pricing models](https://docs.stripe.com/products-prices/pricing-models.md). ## Set up webhooks Set up [webhook endpoints](https://docs.stripe.com/billing/subscriptions/webhooks.md) to receive notifications about subscription-related events. For example, when you see the `invoice.paid=true` notification, you can safely provision access to your service. See [the subscription lifecycle](https://docs.stripe.com/billing/subscriptions/overview.md#subscription-lifecycle) for more information about *webhook* events. See a complete list of [subscription-related events](https://docs.stripe.com/billing/subscriptions/overview.md#subscription-events). To learn about managing access to your product’s feature, see [Entitlements](https://docs.stripe.com/billing/entitlements.md). ## Other considerations Depending on your requirements, you may also need to consider: - [Tax rates](https://docs.stripe.com/billing/taxes/tax-rates.md) - [Discounts](https://docs.stripe.com/billing/subscriptions/coupons.md) - [Prorations](https://docs.stripe.com/billing/subscriptions/prorations.md) - [Revenue recognition](https://docs.stripe.com/revenue-recognition.md)