A Stripe plugin which uses checkout for subscriptions. This plugin is a modified version of stripe-samples/checkout-single-subscription for CrafterCMS Studio.
A sample CrafterCMS Project uses this plugin: https://github.com/phuongnq/craftercms-stripe-sample-project
-
Install the plugin via Studio's Plugin Management UI under
Site Tools
>Plugin Management
You will need the following information:
-
publishableKey: Stripe publishable key. Example:
${enc:CCE-V1#bUhsL6BI...}
-
secretKey: Stripe secret key. Example:
${enc:CCE-V1#z48hAvk...}
-
callbackDomain: Callback domain of your application. Example:
http://localhost:8080
OR You can also install this plugin by cloning this repository and using the Studio API.
-
Create a Studio JWT Token.
-
Execute the following CURL command a terminal
curl --location --request POST 'http://SERVER_AND_PORT/studio/api/2/marketplace/copy' \ --header 'Authorization: Bearer THE_JWT_TOKEN_FOR_STUDIO' \ --header 'Content-Type: application/json' \ --data-raw '{ "siteId": "YOUR-PROJECT-ID", "path": "THE_ABSOLUTEL_FILE_SYSTEM_PATH_TO_THIS_REPO", "parameters": { } }
OR You can aslo install this plugin by cloning this repository and using Crafter CLI Commands
./crafter-cli copy-plugin -e local -s PROJECT_ID --path /PLUGIN_PATH/stripe-plugin \ --param publishableKey='${enc:CCE-V1#bUhsL6BI...}' \ --param secretKey='${enc:CCE-V1#z48hAvk...}' \ --param callbackDomain='http://localhost:8080'
-
Note: Values starting with ${enc:...}
are encrypted text using CrafterCMS Encryption Tool
1. Create a new Stripe Prices Page
- Page URL:
/plans
- Page Name:
Plans
- Heading:
Choose a CrafterCMS plan
Enter your prices plans. For example, by default the plugin has 3 plans: basicPrice
, proPrice
, enterprisePrice
.
- basicPrice:
- Title: Starter
- Thumbnail: /static-assets/plugins/org/craftercms/plugin/stripe/img/starter.png
- Price: $12
- Price Id: Price Id from step 2. Example:
price_1Mi...
- Recurring: month
- proPrice:
- Title: Professional
- Thumbnail: /static-assets/plugins/org/craftercms/plugin/stripe/img/professional.png
- Price: $18
- Price Id: Price Id from step 2. Example:
price_1Mi...
- Recurring: month
- enterprisePrice:
- Title: Enterprise
- Thumbnail: /static-assets/plugins/org/craftercms/plugin/stripe/img/enterprise.webp
- Price: $250
- Price Id: Price Id from step 2. Example:
price_1Mi...
- Recurring: year
After created, you can alson use the Experience Builder functionality to Edit the page.
2. Use the Stripe CLI to create equivalent products from step 1
Checkout is a pre-built payment page that lets you accept cards and Apple Pay. Billing is a suite of APIs that lets you model complex subscription plans. You can combine the two products to get a subscription payment page up and running without the need of a server.
When your customer is ready to pay, use Stripe.js with the ID of your Checkout Session to redirect them to your Checkout page.
Demo
The demo is running in test mode -- use 4242424242424242
as a test card number with any CVC + future expiration date.
Use the 4000002500003155
test card number to trigger a 3D Secure challenge flow.
Read more about testing on Stripe at https://stripe.com/docs/testing.
For more features see the Checkout documentation.
The integration uses the Checkout Sessions API for additional functionality.
2. Create Products and Prices on Stripe
This sample requires three Price IDs to create the Checkout page. Products and Prices are objects on Stripe that let you model a subscription.
Using the Stripe CLI
Create basic product
./stripe products create --name="Basic" --description="Basic plan"
Create premium product
./stripe products create --name="Premium" --description="Premium plan"
Create enterprise product
./stripe products create --name="Enterprise" --description="Enterprise plan"
Take note of the id value for the products you just created as you will need this to create prices. For example:
{
"id": "price_RANDOM_ID_VALUE"
}
Create price for Basic product, substituting ID_OF_BASIC_PRODUCT
with the appropriate product Id:
./stripe prices create \
-d "product=ID_OF_BASIC_PRODUCT" \
-d "unit_amount=1200" \
-d "currency=usd" \
-d "recurring[interval]=month"
Create price for Premium product, substituting ID_OF_PREMIUM_PRODUCT
with the appropriate product Id:
./stripe prices create \
-d "product=ID_OF_PREMIUM_PRODUCT" \
-d "unit_amount=1800" \
-d "currency=usd" \
-d "recurring[interval]=month"
Create price for Enterprise product, substituting ID_OF_ENTERPRISE_PRODUCT
with the appropriate product Id:
./stripe prices create \
-d "product=ID_OF_ENTERPRISE_PRODUCT" \
-d "unit_amount=25000" \
-d "currency=usd" \
-d "recurring[interval]=year"
More Information: Docs - Update your Products and Prices
Using the Dashboard
You can create Products and Prices in the dashboard. Create three recurring Prices to run this sample.
3. Open your plans page and try subscribing a plan