Payments with Stripe
1. Initiate a Stripe Account:
- Register for a new account on Stripe's website. Complete all necessary steps to finish setting up the account.
2. Enable Payment Processing:
- After account creation, provide your business details and bank information to enable the processing of payments.
3. Update Website Information:
- Go to
Settings
and selectPublic Details
. - Enter your website's URL to link Stripe back to your site.
4. Customize Stripe’s Appearance:
- Within
Settings
, accessBranding
. - Upload your company's logo and select a color scheme that represents your brand.
5. Configure Email Notifications for Customers:
- In
Settings
, look forCustomer Emails
. - Activate email notifications for both successful payments and refunds to ensure your customers are well-informed.
6. Set Up the Customer Portal Access:
- Find
Customer Portal
underSettings
. - Turn on the portal link, which might be necessary for future use.
7. Implement Anti-Fraud Measures:
- Search for 'rules' and navigate to
Fraud Prevention > Rules
. - Activate the primary 3DS rule for security, and consider enabling the second recommended rule.
- Set it to reject payments when the CVC check fails.
8. Switch to Test Mode:
- Activate Test Mode in the Stripe dashboard to simulate transactions without actual monetary exchanges.
9. Generate a New Product:
- In Stripe, create a product and note its price ID (e.g., price_1ju5GD464564).
- Incorporate this price ID into your config.stripe.plans[0].priceId in the config.js file.
10. Integrate API Keys:
- Retrieve your public and private API keys from
Developers
in Stripe. - Add these keys to STRIPE_SECRET_KEY & STRIPE_PUBLIC_KEY in your .env.local file.
11. Set Up Local Webhook Testing:
- Follow the instructions under
Developers
,Webhook
,Test in local environment
in Stripe. - Once logged into Stripe CLI, use a specified command to forward webhook events to your API.
terminal
stripe listen --forward-to localhost:3000/api/webhooks
⚙️
Going to production?
- Disable Test Mode: Turn off Test Mode in your Stripe Dashboard.
- API Keys Setup: Copy public & private keys from
Developers
in Stripe; add them to STRIPE_SECRET_KEY & STRIPE_PUBLIC_KEY in production variables. - Webhook Configuration: In
Developers
>Webhook
>Add Endpoint
, set endpoint to your domain + /api/webhook/stripe, selectcheckout.session.completed
, and add the signing secret to STRIPE_WEBHOOK_SECRET in production variables. - Payout Schedule (Optional): In
Balance
>Manage Payouts
, set a specific payout date, like the 10th each month. - Customer Email Notifications (Optional): Activate emails for successful payments & refunds in
Settings
>Customer Emails
.