27 lines
1.6 KiB
Plaintext
27 lines
1.6 KiB
Plaintext
export const metadata = {
|
||
title: `Webhook Events`,
|
||
}
|
||
|
||
# {metadata.title}
|
||
|
||
In this document, you’ll learn how the Payment Module supports listening to webhook events.
|
||
|
||
## What's a Webhook Event?
|
||
|
||
A webhook event is sent from a third-party payment provider to your application. It indicates a change in a payment’s status.
|
||
|
||
This is useful in many cases such as when a payment is being processed asynchronously or when a request is interrupted and the payment provider is sending details on the process later.
|
||
|
||
---
|
||
|
||
## processEvent Method
|
||
|
||
The Payment Module’s main service has a [processEvent method](/references/payment/processEvent) used to handle incoming webhook events from third-party payment services. The method delegates the handling to the associated payment provider, which returns the event's details.
|
||
|
||
Medusa implements a webhook listener route at the `/hooks/payment/[provider]` API route, where `[provider]` is the ID of the provider (for example, `stripe`). Use that webhook listener in your third-party payment provider's configurations.
|
||
|
||

|
||
|
||
If the event's details indicate that the payment should be authorized, then the [authorizePaymentSession method of the main service](/references/payment/authorizePaymentSession) is executed on the specified payment session.
|
||
|
||
If the event's details indicate that the payment should be captured, then the [capturePayment method of the main service](/references/payment/capturePayment) is executed on the payment of the specified payment session. |