Skip to content

kazamori/stripe-webhook-sample

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

stripe-webhook-sample

Sample application using stripe-go to provide webhook endpoint for stripe.

How to run (with test mode)

Set your secret key. See your keys here: https://dashboard.stripe.com/apikeys

$ export SK_KEY="sk_test_xxx"

Start up the server provides your webhook endpoint.

$ go run main.go 
2023/06/11 12:56:38 INFO serve `/webhook` as an endpoint port=8080

Install Stripe CLI, then listen any payment events.

$ stripe login
$ stripe listen --forward-to localhost:8080/webhook

Trigger an any payment event.

$ stripe trigger payment_intent.succeeded

Scan QR code of your product with your smartphone.

(This is an example of my test product for test mode)

qr code

Use test cards to simulate a successful payment.

After you paid using above QR code, you can see some event logs in the stripe listener/webhook sample application.

Integrate with IFTTT webhook

After a webhook endpoint was called, request another webhook endpoint on IFTTT.

Use simple webhook events described at Receive a web request. Define 3 environemnt variables to integrate with it.

$ export IFTTT_KEY="..."
$ export IFTTT_TURN_ON="turn-on-something"
$ export IFTTT_TURN_OFF="turn-off-something"

When the turn-on event is done, then trigger the turn-off event after 3 seconds.

=================================
2023/06/12 19:32:30 INFO Congratulations! You've fired the turn-on-something event
=================================
2023/06/12 19:32:33 INFO Congratulations! You've fired the turn-off-something event
2023/06/12 19:32:33 INFO completed trigger off

Reference

Releases

No releases published

Packages

No packages published

Languages