How can I test my webhook API's with a realistic Stripe event? I want to see which JSON key/value pairs contain the customer data I need to execute my business logic.
I'm using Stripe's Product Pricing table inserted into a 'join.ejs' page on my website. Works well, looks great. Stripe will handle all payment transactions, I only care about which product ID was selected and can capture that in the return URL after successful payment. My need for webhooks then is only to know when a recurring charge for a product failed, when a charge for a recurring product succeeded, and when a customer cancels their recurring payment (no longer wants access to my website).
I have added the following webhooks in my development environment:
I have the local Stripe CLI installed and working so I can right-click and select "Test Stripe Webhook":
This output is from a right-click on the 'charge.failed' webhook, but it contains no customer data. I can't see a way to trigger the Stripe CLI to include any customer data in it's $_POST to my webhook.
Viewing the web server logs in Wappler, while creating a "Test Stripe Webhook" event showed me the Stripe key/value pairs returned from that particular event.
This is one step closer to knowing which keys might have values during the event. It still seems very difficult to test a webhook using a local machine versus one with a public IP address where I can trigger events in Stripe's test mode with my staging server defined as an end point (haven't gotten that far yet).
I'm I overlooking something that would make my life easier, or is testing on publicly available servers how this is done?
It's actually very easy using software like ngrok, but I don't know anything about how Wappler Stripe webhooks work, so I don't know if it works with it. Wappler has built-in ngrok support
@Cheese I can see the output from the Stripe Webhooks Terminal. Since I'm very new to the structure of the JSON objects returned by Stripe during different events, I'm wanting to see test data populated into the key value pairs. For example, certain events have more than one "email" key value pair in the JSON. If I want the product ID, I see "ID", "Product", and "Line_Items.Price.Product". The "test webhook" feature kicks off events but a lot of the key value pairs have null as the value. Me and ChatGPT are having lots of conversations today about which key value pair contains the info I need.
My use cases are to provision and deprovision assets on the website based on different events. Starting off with a null value for a variable just doesn't make for a productive day.
To be fair to the Wappler team, the Stripe CLI, at the time of my post, doesn't support adding data into the event's JSON object. I came across this tidbit of info reading the fine manuals on stripe.com.
Currently I'm looking for a way to test my webhook API. There's really not much I can take from the "Getting started with Stripe webhooks" How To. Here's some examples of what might have more value to users when it comes to this topic:
Catching an event on our end point machine, navigating the JSON object for specific key value pairs and executing task(s) on our server: creating or deleting a user, updating info about an existing user, making an external API call to another service.
Catching an event on our end point machine, packing up the JSON object and attaching it to an email: for a support or finance team to review, to trigger a welcome message to a new user, or a thank you message for upgrading their plan.
One very cool feature it has is the "inspector" which allows you to inspect the JSON for any object ID in your Stripe transactions.
This seems to be what I'm looking for to help build my webhooks, since one of the biggest challenges with building them is knowing which key value pair is going to give you the data you need in your server side business logic.