Payments
Last updated
Last updated
Create Stripe account:
Important to note. You can switch between "live" and "test" environment with the following toggle. API keys you generate, products you create etc., are bound to the environment you create them in. So if you create API key in test, it won't exist in "live". Same goes for products, coupons, etc.
Create public
and secret
key test:
Create webhook
key in test:
Set .env
variables:
STRIPE_PUBLIC_KEY=pk_...
STRIPE_SECRET_KEY=sk_...
STRIPE_WEBHOOK_SECRET=whsec_...
Note: Public key is prefixed with "pk", secret key with "sk" and webhook secret with "whsec".
When creating a webhook select a route which handles these, in our case it's: /api/webhook/payment
and select events you want to recieve, example:
If you want to know how to test webhooks locally, without having website online, checkout this section.
Now your Stripe setup is ready and you can add products :) Further documentation:
When creating a webhook select a route which handles the incoming events, in our case it's: /api/webhook/payment
and select events you want to recieve (see picture above).
If you want to know how to test webhooks locally, without having website online, checkout this section.
Set .env
variables:
LEMON_SQUEEZY_API_KEY=
LEMON_SQUEEZY_WEBHOOK_SECRET
=
Webhook allow external services, in this case payment provider, to notify your application when specific events occur, such as successful payments.
Your application listens for incoming webhook events at this route:
Testing webhooks locally
Configure your webhook sender (e.g., Stripe) to send events to this URL.
Install CLI globally: npm install -g @webhooksite/cli
Run the listener with the command:
whcli forward --token=xxxxxxxxxxx --target=http://localhost:3000/api/webhook.payment
(Note: make sure you use correct token. Also use http, rather then https)
Make a "test" purchase to trigger the webhook
Check the logs in webhook.site to see the payload being sent.
Create account:
Create api
keys. API keys are bound to enviroment. API key created in "test" won't work in "production":
Create webhook
key and signing secret:
Now your LemonSqueezy setup is ready and you can add products :) Further documentation:
Since webhooks are usually sent to public URLs, testing them locally requires a workaround. You can use to inspect and debug incoming webhooks and test them before going live.
Visit and copy the generated URL.