Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/srmullen/sveltekit-stripe
Integrating SvelteKit and Stripe Checkout
https://github.com/srmullen/sveltekit-stripe
Last synced: about 2 months ago
JSON representation
Integrating SvelteKit and Stripe Checkout
- Host: GitHub
- URL: https://github.com/srmullen/sveltekit-stripe
- Owner: srmullen
- Created: 2021-04-21T16:18:13.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-02-17T20:16:00.000Z (10 months ago)
- Last Synced: 2024-10-11T12:50:59.969Z (2 months ago)
- Language: Svelte
- Size: 546 KB
- Stars: 119
- Watchers: 11
- Forks: 21
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-svelte-kit - #1 - stripe-js) (🏃 SvelteKit Starter Kits and Integrations / The _How To's?_)
README
# SvelteKit Stripe Integration
**Update in this branch:**
* code is up to date with the latest versions of sveltekit & stripe apis
* enjoy ;-)The SvelteKit demo template comes with an awesome counter application built in. It would be better though if it was a subscription SAAS counter. That's what this repo does.
**Check it out at https://sveltekit-stripe.netlify.app/.**
This demo application implements subscriptions using [SvelteKit](http://kit.svelte.dev/) and [Stripe Checkout](https://stripe.com/payments/checkout).
[It is based on this guide.](https://stripe.com/docs/billing/subscriptions/checkout)## How to use.
First you need to have an account on [Stripe](https://stripe.com/).
- Clone or fork the project
`git clone https://github.com/srmullen/sveltekit-stripe.git`- Install the dependencies
`cd sveltekit-stripe && npm install`- Rename `.env.example` to `.env` and update with your Stripe public and private api keys. You can get them from the Stripe dashboard.
- Create products and prices on Stripe, using the script provided by this repo.
`npm run stripe:init`
This script creates the Stripe entities needed for a subscription billing model and writes them to a json file that will be loaded by a SvelteKit endpoint. You can also create the entites needed by using the Stripe dashboard, [following this section of the guide](https://stripe.com/docs/billing/subscriptions/checkout#create-business-model).- Start up the development server
`npm run dev`### Stripe Webhooks
This repo contains a SvelteKit endpoint for Stripe Webhook events.
To test the hook locally see this guide https://stripe.com/docs/webhooks/test
The stripe webhook endpoint is https://localhost:3000/stripe/webhook. That is where you'll want to forward stripe events.
Verify webhook signatures by adding STRIPE_WEBHOOK_SECRET to your .env file.
## See the demo
https://sveltekit-stripe.netlify.app
(Read more about the implementation here.)[https://www.srmullen.com/articles/sveltekit-stripe-integration]