Is it possible to set localhost as a Stripe webhook URL?

后端 未结 9 1922
故里飘歌
故里飘歌 2021-02-12 03:36

I am creating a payment gateway using Stripe.

I want to set my localhost url localhost/stripe/webhook.php as my webhook url. Is it possible to set a localho

相关标签:
9条回答
  • 2021-02-12 04:15

    It is possible to send the webhooks to your local host. Look up "ngrok", when you run that it opens up a port to public internet access and provides you with a url that can access your localhost from. take this url and set it as your webhook address and finish the url by pointing it at your webhook.php file.

    * EDIT *

    This is only appropriate for testing.

    0 讨论(0)
  • 2021-02-12 04:15

    You can use expose.sh to expose your server using a public HTTPS URL.

    Install expose.sh

    For Mac or Linux, go to Expose.sh and copy/paste the installation code shown into a terminal.

    For Windows go to Expose.sh, download the binary and put it somewhere in your PATH.

    Expose your api to the web

    Start your API server. Then run expose <port> where port is the port your API server is running on, like 80 or 8080.

    Expose.sh will generate a random public expose.sh URL. You'll see output like

    https://s3rh.expose.sh is forwarding to localhost:80
    http://s3rh.expose.sh is forwarding to localhost:80
    

    Then you can get Stripe to use the public HTTPS URL, which will forward to localhost. I've written a full guide here

    Disclaimer: I built expose.sh

    0 讨论(0)
  • 2021-02-12 04:20

    Stripe now has an official tool, the Stripe CLI that makes this easy (but still requires installing another tool).

    See this answer below or the official Stripe CLI docs.

    Alternatively, the another way to achieve this is with http://www.ultrahook.com which allows you to receive webhooks on localhost. This alternative will work with all webhooks, not just Stripe's

    0 讨论(0)
提交回复
热议问题