Casper 2.0 comes with a complete Stripe integration, including the Stripe customer portal for user plan management.
You will need your Stripe API keys for this step. If your Stripe account has been approved for payments, you will have keys for test mode and different keys for live mode. If you are not sure where to find your keys, read this.
To use the Stripe integration, you must create one product in Stripe for each paid pricing tier in your app. To offer monthly and yearly options for the same plan, create one product with two prices: one with a yearly billing cycle and one with a monthly billing cycle.
Be sure to note the Price IDs of each product. You will need to add these to the Pricing Plans Option Set.
To ensure seamless communication between Stripe and your app, you need to set up webhooks that will transmit data from Stripe to your app whenever a specific event is triggered.
From your Bubble app editor, copy your Workflow API root URL. This is the base URL for your webhook endpoints in Stripe.
The /stripe-subscription-update endpoint is responsible for updating workspace subscriptions. It listens to the following 3 Stripe events:
customer.subscription.created
customer.subscription.deleted
customer.subscription.updated
Endpoint URL for test mode: https://yourdomain.bubbleapps.io/version-test/api/1.1/wf/stripe-subscription-update
Endpoint URL for live mode: https://yourdomain.bubbleapps.io/api/1.1/wf/stripe-subscription-update
Don't forget to replace yourdomain with your actual bubbleapps.io domain.
The Stripe customer portal makes subscription management easy for your users and provides many configuration options. For this demo, we will set up a simple portal that allows users to upgrade, downgrade, and cancel their plans.