<aside> đź’ˇ Follow this guide to get Stripe subscriptions setup in your Divjoy codebase. If anything is confusing please reach out.
</aside>
.env
file and fill in your Stripe "Publishable Key", "Secret Key", and the "Price IDs" you created in the above step. Feel free to change the environment variables names (such as "DEMO_STRIPE_PRICE_PRO") to a different name that better matches your intended plan name (such as "DEMO_STRIPE_PRICE_MEGA"). Just remember to do a codebase search for the changed name so you can update the name anywhere else it's used.src/util/prices.js
in your codebase and update the stripePriceIds
object so that the object keys and values correctly mirror those changes. They keys will also need to be updated in src/components/PricingSection.js
where they are passed in to the <Pricing>
component./settings/billing
within your web app. Divjoy gives you a dedicated page in your web app that automatically redirects to the portal so that you can share this URL with your users.npm run stripe-webhook
in its own terminal window. This calls the Stripe command line tool (which you should have already installed in a previous step) and tells it to forward all Stripe events to your locally running codebase at localhost:3000/api/stripe-webhook
. You'll need to copy the webhook secret that this command outputs, paste it into your .env
file as the value for STRIPE_WEBHOOK_SECRET
, and then restart your development server (if running already). You can see this npm script in your package.json
file./dashboard
page, as well as use the customer portal to change plans and billing methods.mydomain.com/api/stripe-webhook
and have it listen for the following events: checkout.session.completed
, invoice.paid
, invoice.payment_failed
, customer.subscription.updated
, customer.subscription.deleted
, customer.subscription.trial_will_end
. After creating this webhook, you'll want to make sure to use its "Signing secret" as the value for the STRIPE_WEBHOOK_SECRET
environment variable you've set for your production host (as opposed to the value that npm run stripe-webhook
gives you for local development).