Appearance
Stripe 💳
JetShip is pre-configured to support Stripe, allowing you to easily integrate it in your SaaS platform. This guide will walk you through the steps to configure Stripe and begin accepting payments.
Configuration ⚙️
Before starting the integration, you will need to create a Stripe account and obtain the necessary credentials.
Step-by-Step Guide to Configure Stripe
Create a Stripe Account:
- If you haven't already, sign up for a Stripe account at Stripe.
Log in to Stripe Dashboard:
- Head over to the Stripe Dashboard.
Select Test Mode or Live Mode:
- Decide if you want to use Test Mode (for testing payments) or Live Mode (for real transactions). You can toggle the Test mode switch in the top right corner of the Stripe dashboard to change modes.
Obtain API Keys:
Go to Developers > API keys on the top menu.
Copy the Publishable Key and save it in your
.env
file under:bashSTRIPE_PUBLISHABLE_KEY=your_publishable_key
Click "Reveal live key token" to get the Secret Key and add it to the
.env
file under:bashSTRIPE_SECRET_KEY=your_secret_key
Set Up Webhooks:
In the Stripe dashboard, go to the Webhooks tab.
Click Add endpoint and use the following URL:
bashhttp://your-site-url/api/stripe/webhook
After entering the URL, click Select events, then check all the following events:
- All
payment_intent.xyz
events - All
customer.xyz
events - All
invoice.xyz
events charge.refunded
charge.failed
- All
After selecting these events, click Add endpoint.
Add Webhook Secret:
Once the webhook is created, copy the Webhook Signing Secret and add it to the
.env
file:bashSTRIPE_WEBHOOK_SECRET=your_webhook_secret
Your .env
file should now include
bash
STRIPE_PUBLISHABLE_KEY=your_publishable_key
STRIPE_SECRET_KEY=your_secret_key
STRIPE_WEBHOOK_SECRET=your_webhook_secret
Creating Products in Stripe 🛍️
To create a product in Stripe, follow these instructions:
- Refer to Stripe's official guide on how to create products and prices.
- Once your product is set up, you will need to create a JSON representation of your product to integrate it into JetShip.
Below is the sample JSON representation of your product data.
One-off product.
json
[
{
"name": "One Time Product",
"description": "This is one time product. There would be multiple price variants.",
"oneoff": true,
"plans": [
{
"name": "Basic",
"price": 99,
"discountedPrice": 99,
"price_id": "price_XXXXXX",
"description": "Basic license",
"icon": "tabler-rocket",
"most_popular": false,
"features": [
"feature1",
"feature2",
"feature3"
]
},
{
"name": "Pro",
"price": 199,
"discountedPrice": 199,
"price_id": "price_XXXXXX",
"description": "Pro license",
"most_popular": true,
"icon": "tabler-users",
"features": [
"feature1",
"feature2",
"feature3"
]
}
],
"coupon_id": "LP2Whte4"
}
]
Subscription product.
json
[
{
"name": "Basic",
"description": "It is a basic JetShip plan with two subscription intervals: yearly and monthly.",
"id": "prod_QMXg3yaqmyrVC8",
"plans": [
{
"interval": "yearly",
"nickname": "JetShip Yearly",
"price": 399,
"discountedPrice": 399,
"price_id": "price_XXXXXX"
},
{
"interval": "monthly",
"nickname": "JetShip Monthly",
"price": 39,
"discountedPrice": 39,
"price_id": "price_XXXXXX"
}
],
"features": [
"feature1",
"feature2",
"feature3"
],
"icon": "tabler-rocket",
"most_popular": false,
"coupon_id": "LP2Whte4"
}
]
You can use this JSON data within JetShip to manage and display the product information.
Final Steps 🎉
Once everything is set up:
- You can test the payment flow using Stripe's Test Mode before going live.
- Be sure to monitor your webhooks in Stripe to ensure everything is running smoothly (e.g., payment success, refunds, or failed transactions).
- You can switch to Live Mode when you're ready to accept real payments.
Pro Tip 💡
When running tests, use the test card numbers provided by Stripe to simulate different payment scenarios without using real money. For example:
bash
Card Number: 4242 4242 4242 4242
Expiration: Any future date
CVC: Any 3 digits
This completes the Stripe integration process! You are now ready to start processing payments with JetShip and Stripe! 🎉