www/apps/resources/references/payment/IPaymentModuleService/methods/payment.IPaymentModuleService.getWebhookActionAndData/page.mdx
import { TypeList } from "docs-ui"
This documentation provides a reference to the getWebhookActionAndData method. This belongs to the Payment Module.
You should only use this methods when implementing complex customizations. For common cases, check out available workflows instead.
</Note>This method retrieves webhook event data with the associated payment provider.
Learn more about handling webhook events in this guide
In the following example, req is an instance of MedusaRequest:
const dataAndAction = await paymentModuleService.getWebhookActionAndData({
provider: "stripe",
payload: {
data: req.body,
rawData: req.rawBody,
headers: req.headers,
},
})
<TypeList types={[{"name":"data","type":"ProviderWebhookPayload","description":"The webhook event's details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"provider","type":"string","description":"The ID of the provider to pass the webhook event payload to.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"object","description":"The webhook event payload passed to the specified provider.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"data","type":"Record<string, unknown>","description":"The parsed webhook body.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"rawData","type":"string \| Buffer<ArrayBufferLike>","description":"The raw webhook request body.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"headers","type":"Record<string, unknown>","description":"The headers of the webhook request.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="getWebhookActionAndData"/>
<TypeList types={[{"name":"Promise","type":"Promise<WebhookActionResult>","optional":false,"defaultValue":"","description":"Resolves when the webhook event is handled successfully.","expandable":false,"children":[{"name":"action","type":"PaymentActions","description":"The action that was performed so that Medusa can handle it internally.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"data","type":"WebhookActionData","description":"The webhook action's details.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"session_id","type":"string","description":"The ID of the payment session in Medusa.\nMake sure to store this ID in the third-party payment provider\nto be able to retrieve the payment session later.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"amount","type":"BigNumberValue","description":"The amount to be captured or authorized (based on the action's type.)","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="getWebhookActionAndData"/>