When an asynchronous event happens in your Stripe account; for example, a customer’s bank confirms a payment, a recurring payment succeeds, or a customer disputes a charge; Stripe uses webhooks to notify your application.
Webhooks (also called a web callback or HTTP push API) enable Stripe to send notifications to your website immediately when certain events occur.
A webhook is similar to a phone number that Stripe calls in order to let you know about a given activity in your account. There can be different activities such as the creation of a new customer or the payout of funds to your bank account. To stick with the above-mentioned metaphor, the Stripe webhook endpoint is the person answering that call and taking action based on the received information.
In practice, a Stripe webhook endpoint means some code running on your server, which can be written in PHP, Node.js, Ruby, Java, C#, just to mention a few. The Stripe webhook endpoint also has an associated URL. Stripe notifications are called Event objects, which contain all the relevant information regarding what happened, including the type of event and its associated data. The Stripe webhook endpoint uses the details of the event to take any required actions.
Many events that happen in your Stripe account have synchronous, immediate results. For instance, a successful request to create a customer immediately returns a Customer object, and for that, you don’t need to use webhooks as the information is readily available.
However, other events are asynchronous which means these happen at a later time and not directly in response to your code’s execution, such as notifications of payouts, recurring charges of subscriptions, or invoice related notifications. For these and similar events, you will need Stripe webhooks to notify your integration about changes to the status of an object so your integration can take the necessary steps.
Actions executed by your Stripe webhook endpoint are event specific such as logging an accounting entry when a transfer is paid, making changes to an invoice when it’s created but has not been paid yet, indicating that an order can be fulfilled or updating a customer’s database information when a recurring payment succeeds.
API is an acronym, and it stands for “Application Programming Interface”. An API is a set of functions that applications can use to access data and features. APIs can be thought of as building blocks for creating a larger system. APIs can share data or functionality, for instance, you can use a “places API” to search for restaurants by name or location, acquiring data about each place. Furthermore, you can combine that information with a “mapping API”, using it as an interface for displaying data.
Webhooks are sometimes referred to as “reverse APIs”, in the sense there is no need to initiate a request, data is sent whenever there’s new information available.
Below you can see common scenarios and related events examples. These events are sent by Stripe to your webhook endpoint in response.
Read more about Stripe charges here.
Read about Stripe customers here.
Disputes can and do happen from time to time. Let’s say a customer disputes a charge and you upload evidence. In such case, Stripe send your application a series of webhooks as the dispute process evolves: charge.dispute.created; charge.dispute.updated; charge.dispute.closed
Read about Stripe disputes here.
We hope this article will give you an overall idea of how Stripe webhooks work. Stay tuned as we are continuously creating more content for you to learn and grow with WP Full Stripe.
Stay on top of the latest news about WP Full Pay