FeaturesPayments
Setup
- Create a new account on Stripe and activate payments (boring, I know.. see you in a bit!)
- In your [Settings], [Public Details], add your website URL
- In your [Settings], [Branding], add your logo & colors
- In your [Settings], [Customer Emails], turn on emails for successful payments & refunds
- In your [Settings], [Customer Portal], activate link to customer portal (in case you need later)
- In the search box, type 'rules' and click [Fraud Prevention > Rules] , make sure the firsrt 3DS rule is enabled. I also turn on the second one (recommended). Make sure to block payments if CVV fails (check below)
- Turn ON Test Mode
- Create a new product and copy the price ID (price_1ju5GD464564) in
config.stripe.plans[0].priceId
in theconfig.js
file. - In your [Developers], copy your public & private keys and add them to
STRIPE_SECRET_KEY
&STRIPE_PUBLIC_KEY
in.env.local
- To set up the webhook locally, follow the steps in [Developers], [Webhook], [Test in local environment]. After login to Stripe CLI, use this command to forward webhook events to our API:
terminal
1stripe listen --forward-to localhost:3000/api/webhook/stripe
Going to production?
- Turn OFF Test Mode
- In your [Developers], copy your public & private keys and add them to
STRIPE_SECRET_KEY
&STRIPE_PUBLIC_KEY
in your production environment variables. - In your [Developers], [Webhook], [Add Enpoint]. Set your domain + /api/webhook/stripe. Select [checkout.session.completed] event (or more if needed). Copy the signing secret and add it to
STRIPE_WEBHOOK_SECRET
in your production environment variables. - Optional: In [Balance], [Manage Payouts], set a specific date of the month to receive your payouts (I use the 10th of each month)
Create a checkout
From the fron-end, use the apiClient (/libs/api.js) to POST our API at /stripe/create-checkout with the priceId & success/cancel URLs
Stripe webhooks
Our API listens to Stripe selected webhooks events & update the user accordingly. The /api/webhook/stripe endpoint is where you do the business logic (add user to a plan, add credits, send email with paid e-books etc.)
Don't get banned from Stripe before getting your first customer
Prevent disputes before they happen with ByeDispute
![Stripe Chart](/_next/static/media/byedispute.acbdb5af.jpg)