The all-in-one starter kit for high-performance SaaS applications. That don't want a vendor buy in when it comes to backend and frontend. This is a front end agnostic template that you can use 100% with any SaaS application. If there are any issues please feel free to reach out to me on X - @meinbiz
Also if you want to build a next.js front end for your next app. Consider fastpocket.dev it is the fastest way to build a fully fledged PocketBase app.
When deploying this template, the sequence of steps is important. Follow the steps below in order to get up and running.
Next, we'll need to configure Stripe to handle test payments. If you don't already have a Stripe account, create one now.
For the following steps, make sure you have the "Test Mode" toggle switched on.
We need to create a webhook in the Developers
section of Stripe.
/api/webhooks
for the endpoint URL. (e.g. https://your-deployment-url.vercel.app/api/webhooks
)Select events
under the Select events to listen to
heading.Select all events
in the Select events to send
section.Signing secret
as we'll need that in the next step.Your application's webhook listens for product updates on Stripe and automatically propagates them to your Pocketbase database. So with your webhook listener running, you can now create your product and pricing information in the Stripe Dashboard.
Stripe Checkout currently supports pricing that bills a predefined amount at a specific interval. More complex plans (e.g., different pricing tiers or seats) are not yet supported.
For example, you can create business models with different pricing tiers, e.g.:
Optionally, to speed up the setup, we have added a fixtures file to bootstrap test product and pricing data in your Stripe account. The Stripe CLI fixtures
command executes a series of API requests defined in this JSON file. Simply run stripe fixtures stripe_bootstrap/stripe-fixtures.json
.
Important: Make sure that you've configured your Stripe webhook correctly and redeployed with all needed environment variables.
go run main.go serve
from a command line in the root of the folderhttps://127.0.0.1:8090/_/
and create new admin account and loginSettings
on the left hand side bar and go to Import Collections
Load from JSON file
and grab the schema file from pb_bootstrap/pb_schema.json
go run main.go
commandstripe listen --print-secret --api-key "$STRIPE_SECRET_KEY" > secret.txt
to get your secret key in a secret.txt
file. Note: this needs to be in the root of your project and is machine specificgo run main.go serve
I know, that was quite a lot to get through, but it's worth it. You're now ready to earn recurring revenue from your customers. 🥳
Install the Stripe CLI and link your Stripe account.
Next, start local webhook forwarding:
stripe listen --forward-to=127.0.0.1:8090/api/webhooks
Running this Stripe command will print a webhook secret (such as, whsec_***
) to the console. Set STRIPE_WEBHOOK_SECRET
to this value in your .env.local
file.
Please note that stripe wont forward to http. You will need to ensure you are working in an environment where you have an SSL certificate installed
Archive all test mode Stripe products before going live. Before creating your live mode products, make sure to follow the steps below to set up your live mode env vars and webhooks.
To run the project in live mode and process payments with Stripe, switch Stripe from "test mode" to "production mode." Your Stripe API keys will be different in production mode, and you will have to create a separate production mode webhook. Copy these values and paste them into Vercel, replacing the test mode values.
Afterward, you will need to rebuild your production deployment for the changes to take effect. Within your project Dashboard, navigate to the "Deployments" tab, select the most recent deployment, click the overflow menu button (next to the "Visit" button) and select "Redeploy" (do NOT enable the "Use existing Build Cache" option).
To verify you are running in production mode, test checking out with the Stripe test card. The test card should not work.
This template mirrors completed Stripe transactions to the Pocketbase database. This means that if the Pocketbase database is unavailable, the Stripe transaction will still succeed, but the Pocketbase database will not be updated, and the application will pass an error code back to Stripe. By default, Stripe will retry sending its response to the webhook for up to three days, or until the database update succeeds. This means that the Stripe transaction will eventually be reflected in the Pocketbase database as long as the database comes back online within three days. You may want to implement a process to automatically reconcile the Pocketbase database with Stripe in case of a prolonged outage.
This template is based on https://github.com/vercel/nextjs-subscription-payments/tree/main you could take the front end supplied there and adapt it to use PocketBase as a backend. Give it a try and submit a PR to this doc and I will add you as a contributor
I have added a docker container that is not production ready but you can probably get running in google cloud run quite easily or whatever your preference is for hosting. Please note:
Here is my current build flow to upgrade and deploy the container to Google Artifact
go get -u github.com/pocketbase/pocketbase
GOOS=linux GOARCH=amd64 go build -o bin/app-amd64-linux main.go
do build -t myimage . --build-1. arg STRIPE_SECRET_KEY=sk_test_WHATEVER_YOUR_KEY_IS --build-1. arg HOST=api.sign365.com.au --build-1. arg STRRETURN_URL=https://sign365.com.au/account --build-1. arg PORT=8090 --build-1. arg DEVELOPMENT="" --platform linux/amd64
docker tag myimage australia-southeast1-docker.pkg.dev/biz365-1569752078001/fastpocket/myimage:latest
docker push australia-southeast1-docker.pkg.dev/biz365-1569752078001/fastpocket/myimage
I really hope this helps in building a fresh image.
This repo is downstream from FastPocket. If you are experiencing issues I recommend that you update the packages in main.go
and then compile the binary. This fixes most of the issues I have had with stripe
MIT License
Copyright (c) 2024 BIZ365 PTY LTD
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.