Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: add stripe events to provider guide #10618

Merged
merged 1 commit into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ In this document, you’ll learn about the Stripe Module Provider and how to con
link: "https://support.stripe.com/questions/locate-api-keys-in-the-dashboard"
},
{
text: "For deployed Medusa applications, a Stripe webhook secret. When creating the Webhook, set the endpoint URL to {server_url}/hooks/payment/stripe_stripe, where {server_url} with the URL to your deployed Medusa server.",
text: "For deployed Medusa applications, a Stripe webhook secret. Refer to the end of this guide for details on the URL and events.",
link: "https://docs.stripe.com/webhooks#add-a-webhook-endpoint"
}
]} />
Expand Down Expand Up @@ -192,33 +192,18 @@ STRIPE_API_KEY=<YOUR_STRIPE_API_KEY>

---

## Use Provider
## Setup Stripe Webhooks

To use the Stripe provider, create a payment session for the provider:
For production applications, you must set up webhooks in Stripe that inform Medusa of changes and updates to payments. Refer to [Stripe's documentation](https://docs.stripe.com/webhooks#add-a-webhook-endpoint) on how to setup webhooks.

```ts
const paymentSession =
await paymentModuleService.createPaymentSession(
"pay_col_123",
{
provider_id: "stripe-usd",
amount: 5000,
currency_code: "usd",
data: {
// any necessary data
// to pass to stripe
},
}
)
```

---
### Webhook URL

## Stripe Webhook Endpoint URLs
Medusa has a `{server_url}/hooks/payment/{provider_id}` API route that you can use to register webhooks in Stripe, where:

As mentioned in the prerequisites, when you set up a webhook in Stripe, you set the webhook endpoint URL to `{server_url}/hooks/payment/stripe_stripe`. This endpoint URL is for basic payments with Stripe.
- `{server_url}` is the URL to your deployed Medusa application in server mode.
- `{provider_id}` is the ID of the provider, such as `stripe_stripe` for basic payments.

The Stripe Module Provider supports other payment types, and the webhook endpoint URL is different for each:
The Stripe Module Provider supports the following payment types, and the webhook endpoint URL is different for each:

<Table>
<Table.Header>
Expand Down Expand Up @@ -315,6 +300,14 @@ The Stripe Module Provider supports other payment types, and the webhook endpoin
</Table.Body>
</Table>

### Webhook Events

When you set up the webhook in Stripe, choose the following events to listen to:

- `payment_intent.amount_capturable_updated`
- `payment_intent.succeeded`
- `payment_intent.payment_failed`

---

## Useful Guides
Expand Down
2 changes: 1 addition & 1 deletion www/apps/resources/generated/edit-dates.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export const generatedEditDates = {
"app/commerce-modules/payment/payment/page.mdx": "2024-10-09T10:59:08.463Z",
"app/commerce-modules/payment/payment-collection/page.mdx": "2024-10-09T10:56:49.510Z",
"app/commerce-modules/payment/payment-flow/page.mdx": "2024-10-09T11:18:53.332Z",
"app/commerce-modules/payment/payment-provider/stripe/page.mdx": "2024-12-12T12:46:28.557Z",
"app/commerce-modules/payment/payment-provider/stripe/page.mdx": "2024-12-16T13:21:03.554Z",
"app/commerce-modules/payment/payment-provider/page.mdx": "2024-10-09T11:07:27.269Z",
"app/commerce-modules/payment/payment-session/page.mdx": "2024-10-09T10:58:00.960Z",
"app/commerce-modules/payment/webhook-events/page.mdx": "2024-11-19T11:45:02.167Z",
Expand Down
Loading