|
1
|
{"slug":"/references/payment/getWebhookActionAndData","title":"getWebhookActionAndData - Payment Module Reference","frontmatter":{"displayed_sidebar":"paymentReference","slug":"/references/payment/getWebhookActionAndData","sidebar_label":"getWebhookActionAndData"},"toc":[{"title":"Example","id":"example","level":2},{"title":"Parameters","id":"getwebhookactionanddata-parameters","level":2},{"title":"Returns","id":"getwebhookactionanddata-returns","level":2}],"blocks":[{"kind":"markdown","html":"This documentation provides a reference to the `getWebhookActionAndData` method. This belongs to the Payment Module."},{"kind":"note","variant":"note","html":"You should only use this methods when implementing complex customizations. For common cases, check out [available workflows instead](/medusa-workflows-reference)."},{"kind":"markdown","html":"This method retrieves webhook event data with the associated payment provider.\n\nLearn more about handling webhook events in [this guide](https://docs.medusajs.com/resources/commerce-modules/payment/webhook-events)"},{"kind":"heading","level":2,"text":"Example","id":"example"},{"kind":"markdown","html":"In the following example, `req` is an instance of `MedusaRequest`:\n\n```ts\nconst dataAndAction = await paymentModuleService.getWebhookActionAndData({\n provider: \"stripe\",\n payload: {\n data: req.body,\n rawData: req.rawBody,\n headers: req.headers,\n },\n})\n```"},{"kind":"heading","level":2,"text":"Parameters","id":"getwebhookactionanddata-parameters"},{"kind":"typeList","sectionTitle":"getWebhookActionAndData","types":[{"name":"data","type":"[ProviderWebhookPayload](/references/payment/interfaces/payment.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":[]}]}]}]},{"kind":"heading","level":2,"text":"Returns","id":"getwebhookactionanddata-returns"},{"kind":"typeList","sectionTitle":"getWebhookActionAndData","types":[{"name":"Promise","type":"Promise<[WebhookActionResult](/references/payment/interfaces/payment.WebhookActionResult)>","optional":false,"defaultValue":"","description":"Resolves when the webhook event is handled successfully.","expandable":false,"children":[{"name":"action","type":"[PaymentActions](/references/payment/types/payment.PaymentActions)","description":"The action that was performed so that Medusa can handle it internally.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"data","type":"[WebhookActionData](/references/payment/interfaces/payment.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](/references/payment/types/payment.BigNumberValue)","description":"The amount to be captured or authorized (based on the action's type.)","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]}]} |