LogoLogo
  • Getting Started
  • CLI
    • Docker
    • Config.yaml
  • GUI (SOON)
  • Tunnels Types
    • HTTP/s
      • HTTP/s plugins
      • HTTP/s apps
    • TLS
    • TCP
    • UDP
  • Reservations
    • Domain
    • Endpoint
  • Troubleshoot
    • Common errors
  • Tutorials
    • Expose a local web server
    • Expose Apache/Nginx web server
    • Share files from localhost
    • Use LocalXpose with Traefik
    • Expose PocketBase backend
    • Create a custom domain name
    • Make Let's Encrypt certificate
    • Access your IP camera remotely
    • Access your Raspberry Pi remotely
    • Sync your Keepass password manager
    • Expose localhost RASA chatbot for Telegram Integration
    • Expose your local Netdata Instance
    • Testing Stripe webhook
    • Expose localhost Kubernetes
    • Expose database server (PostgreSQL)
    • Exposing local Minecraft server
    • More Tutorials
Powered by GitBook
On this page
  • 1. Creating a simple webhook receiver
  • 2. Exposing your stripe webhook
  • 3. Register a webhook
  • 4. Triggering Events (Dashboard)
  • 5. Triggering Events (CLI)
  • i) Login to your stripe CLI.
  • ii) Create a forwarding listener
  • iii) Create a webhook event

Was this helpful?

  1. Tutorials

Testing Stripe webhook

This tutorial will show you how you can test your Stripe payment gateway webhooks.

This tutorial assumes that you have created Stripe account & have access to your dashboard.

1. Creating a simple webhook receiver

Here we use flask to create a simple webhook receiver, If the webhook receives a POST it will respond with a message. The flask application is set to run in port 8080.

Ideally, you would want to write statement for handling the events and exceptions with return codes.

from flask import Flask, jsonify, request 
app = Flask(__name__)

@app.route('/', methods=['POST'])      #You may add other route eg: '/webhook'
def webhook():
    data = request.get_json(silent=True)
    print(data)                        #Prints payload
    return jsonify('Yey! Success')     #Returns happy message

if __name__ == '__main__': 
    app.run(port=8080)                 #Running on port 8080

You can then run your code.

python stripe_webhook.py

2. Exposing your stripe webhook

loclx tunnel http  --basic-auth stripeuser:stripepwd
# also using in-built basic authentication feature (Optional)

LocalXpose should provide you with http/https tunnel endpoints.

3. Register a webhook

  • Click on 'Add endpoint'.

  • Enter your LocalXpose URL in format https://<username>:<password>@<localxposeurl>

  • Select event/s you want to generate.

  • Save by clicking 'Add endpoint'.

4. Triggering Events (Dashboard)

In order to test the working of your setup, we can trigger webhook events.

  • Click on 'Send test webhook'

  • Select the event you want to trigger.

  • Confirm by clicking 'Send test webhook'

You should see the return message from our webhook 'Yey! Success'.

5. Triggering Events (CLI)

i) Login to your stripe CLI.

stripe login
> Your pairing code is: gems-pretty-holy-honor
> Press Enter to open up the browser (^C to quit)

ii) Create a forwarding listener

stripe listen --forward-to https://stripeuser:stripepwd@hawlmbpb6j19.loclx.io
# Ideally you would want to setup a listner in server, but if you can't, you can
# forward using localxpose's url to forward webhook events like such.

iii) Create a webhook event

stripe trigger payment_intent.created

You should receive the event and it will be forwarded to your webhook.

PreviousExpose your local Netdata InstanceNextExpose localhost Kubernetes

Last updated 2 years ago

Was this helpful?

this flask webhook app is meant for test use only, in production you would want to follow .

Since our webhook is running on port 8080, we can now expose this port with LocalXpose. If you want to use custom domain please visit ().

Head over to and click on Developers > Webhooks.

Follow instructions to setup Stripe CLI in your machine.

In this way you can expose your webhook and test against with Stripe's events. For developer's documentation refer to .

best-practices
creating a custom domain
Stripe Dashboard
these
stripe official docs