Webhook Setup
Learn how to set up a payment provider to receive payment informations for your products.
Development Mode
Create a webhook endpoint in your application to receive events from Stripe. This is necessary to handle events like payment success, failure, and refunds.
Activate Test Mode
Go to the Stripe dashboard and activate the test mode in the navbar. This will allow you to test the payment flow without charging real money.
Create an Ngrok Tunnel
To receive webhooks from Stripe locally, you need to create an Ngrok tunnel. This will expose your local server to the internet and allow Stripe to send events to your application.
Install Ngrok by following the instructions on the Ngrok website
Run the following command in your terminal to create a tunnel:
Replace 3000
with the port your application is running on.
Create Webhook
Go to the Stripe dashboard and create a webhook endpoint. It`s located in the Developers section
Events
For one-time payments, you need to activate the checkout.session.completed
event. This event is triggered when a payment is successful.
Ready to test your application
Your application is now ready to receive payment events from Stripe in the development mode.
Stripe CLI
Additionally to ngrok you could even install the Stripe CLI to listen to specific events in your terminal.
Just install the Stripe CLI and login to your account. After that you can run the following command to start listening to events:
Now you can see the events in your terminal when you trigger them in your application. For example, to trigger a payment success event, run the following command:
Production Mode
Create a webhook endpoint in your application to receive events from Stripe. This is necessary to handle events like payment success, failure, and refunds.
Create Webhook
Go to the Stripe dashboard and create a webhook endpoint. It`s located in the Developers section
Events
For one-time payments, you need to activate the checkout.session.completed
event. This event is triggered when a payment is successful.
Endpoint
Choose the “Webhook endpoint” in the “choose destination type” and fill in the the URL of your webhook endpoint.
Ready for Deployment
Your application is now ready to receive payment events from Stripe in the production mode.
Check out the Deployment section to learn how to deploy your application to production.
Was this page helpful?