Raw
1 ---
2 sidebar_label: "Stripe"
3 ---
4
5 import { Table, Prerequisites } from "docs-ui"
6
7 export const metadata = {
8 title: `Stripe Module Provider`,
9 }
10
11 # {metadata.title}
12
13 In this document, you’ll learn about the Stripe Module Provider and how to configure it in the Payment Module.
14
15 <Note title="Looking for no-code docs?">
16
17 Your technical team must install the Stripe Module Provider in your Medusa application first. Then, refer to [this user guide](!user-guide!/settings/regions#edit-region-details) to learn how to enable the Stripe payment provider in a region using the Medusa Admin dashboard.
18
19 </Note>
20
21 ## Register the Stripe Module Provider
22
23 <Prerequisites items={[
24 {
25 text: "Stripe account",
26 link: "https://stripe.com/"
27 },
28 {
29 text: "Stripe Secret API Key",
30 link: "https://support.stripe.com/questions/locate-api-keys-in-the-dashboard"
31 },
32 {
33 text: "For deployed Medusa applications, a Stripe webhook secret. Refer to the end of this guide for details on the URL and events.",
34 link: "https://docs.stripe.com/webhooks#add-a-webhook-endpoint"
35 }
36 ]} />
37
38 The Stripe Module Provider is installed by default in your application. To use it, add it to the array of providers passed to the Payment Module in `medusa-config.ts`:
39
40 ```ts title="medusa-config.ts"
41 module.exports = defineConfig({
42 // ...
43 modules: [
44 {
45 resolve: "@medusajs/medusa/payment",
46 options: {
47 providers: [
48 {
49 resolve: "@medusajs/medusa/payment-stripe",
50 id: "stripe",
51 options: {
52 apiKey: process.env.STRIPE_API_KEY,
53 },
54 },
55 ],
56 },
57 },
58 ],
59 })
60 ```
61
62 ### Environment Variables
63
64 Make sure to add the necessary environment variables for the above options in `.env`:
65
66 ```bash
67 STRIPE_API_KEY=<YOUR_STRIPE_API_KEY>
68 ```
69
70 ### Module Options
71
72 <Table>
73 <Table.Header>
74 <Table.Row>
75 <Table.HeaderCell>
76 Option
77 </Table.HeaderCell>
78 <Table.HeaderCell>
79 Description
80 </Table.HeaderCell>
81 <Table.HeaderCell>
82 Required
83 </Table.HeaderCell>
84 <Table.HeaderCell>
85 Default
86 </Table.HeaderCell>
87 </Table.Row>
88 </Table.Header>
89 <Table.Body>
90 <Table.Row>
91 <Table.Cell>
92
93 `apiKey`
94
95 </Table.Cell>
96 <Table.Cell>
97
98 A string indicating the Stripe Secret API key.
99
100 </Table.Cell>
101 <Table.Cell>
102
103 Yes
104
105 </Table.Cell>
106 <Table.Cell>
107
108 \-
109
110 </Table.Cell>
111 </Table.Row>
112 <Table.Row>
113 <Table.Cell>
114
115 `webhookSecret`
116
117 </Table.Cell>
118 <Table.Cell>
119
120 A string indicating the Stripe webhook secret. This is only useful for deployed Medusa applications.
121
122 </Table.Cell>
123 <Table.Cell>
124
125 Yes
126
127 </Table.Cell>
128 <Table.Cell>
129
130 \-
131
132 </Table.Cell>
133 </Table.Row>
134 <Table.Row>
135 <Table.Cell>
136
137 `capture`
138
139 </Table.Cell>
140 <Table.Cell>
141
142 Whether to automatically capture payment after authorization.
143
144 </Table.Cell>
145 <Table.Cell>
146
147 No
148
149 </Table.Cell>
150 <Table.Cell>
151
152 `false`
153
154 </Table.Cell>
155 </Table.Row>
156 <Table.Row>
157 <Table.Cell>
158
159 `automatic_payment_methods`
160
161 </Table.Cell>
162 <Table.Cell>
163
164 A boolean value indicating whether to enable Stripe's automatic payment methods. This is useful if you integrate services like Apple pay or Google pay.
165
166 </Table.Cell>
167 <Table.Cell>
168
169 No
170
171 </Table.Cell>
172 <Table.Cell>
173
174 `false`
175
176 </Table.Cell>
177 </Table.Row>
178 <Table.Row>
179 <Table.Cell>
180
181 `payment_description`
182
183 </Table.Cell>
184 <Table.Cell>
185
186 A string used as the default description of a payment if none is available in cart.context.payment_description.
187
188 </Table.Cell>
189 <Table.Cell>
190
191 No
192
193 </Table.Cell>
194 <Table.Cell>
195
196 \-
197
198 </Table.Cell>
199 </Table.Row>
200 <Table.Row>
201 <Table.Cell>
202
203 `oxxoExpiresDays`
204
205 </Table.Cell>
206 <Table.Cell>
207
208 The number of days before an OXXO payment expires. Only applicable if you plan to use OXXO as a payment method.
209
210 </Table.Cell>
211 <Table.Cell>
212
213 No
214
215 </Table.Cell>
216 <Table.Cell>
217
218 `3`
219
220 </Table.Cell>
221 </Table.Row>
222 <Table.Row>
223 <Table.Cell>
224
225 `paymentMethodConfiguration` (v2.18.0+)
226
227 </Table.Cell>
228 <Table.Cell>
229
230 A string indicating the ID of a Stripe [Payment Method Configuration](https://docs.stripe.com/payments/payment-method-configurations) (PMC) to apply a Dashboard-managed set of payment methods to the intent. This option is only used when `payment_method_types` is not set.
231
232 </Table.Cell>
233 <Table.Cell>
234
235 No
236
237 </Table.Cell>
238 <Table.Cell>
239
240 \-
241
242 </Table.Cell>
243 </Table.Row>
244 </Table.Body>
245 </Table>
246
247 ---
248
249 ## Enable Stripe Providers in a Region
250
251 Before customers can use Stripe to complete their purchases, you must enable the Stripe payment provider(s) in the region where you want to offer this payment method.
252
253 Refer to the [user guide](!user-guide!/settings/regions#edit-region-details) to learn how to edit a region and enable the Stripe payment provider.
254
255 ---
256
257 ## Stripe Payment Provider IDs
258
259 When you register the Stripe Module Provider, it registers different providers, such as basic Stripe payment, Bancontact, and more.
260
261 Each provider is registered and referenced by a unique ID made up of the format `pp_{identifier}_{id}`, where:
262
263 - `{identifier}` is the ID of the payment provider as defined in the Stripe Module Provider.
264 - `{id}` is the ID of the Stripe Module Provider as set in the `medusa-config.ts` file. For example, `stripe`.
265
266 Assuming you set the ID of the Stripe Module Provider to `stripe` in `medusa-config.ts`, the Medusa application will register the following payment providers:
267
268 <Table>
269 <Table.Header>
270 <Table.Row>
271 <Table.HeaderCell>
272 Provider Name
273 </Table.HeaderCell>
274 <Table.HeaderCell>
275 Provider ID
276 </Table.HeaderCell>
277 </Table.Row>
278 </Table.Header>
279 <Table.Body>
280 <Table.Row>
281 <Table.Cell>
282
283 Basic Stripe Payment
284
285 </Table.Cell>
286 <Table.Cell>
287
288 `pp_stripe_stripe`
289
290 </Table.Cell>
291 </Table.Row>
292 <Table.Row>
293 <Table.Cell>
294
295 Bancontact Payments
296
297 </Table.Cell>
298 <Table.Cell>
299
300 `pp_stripe-bancontact_stripe`
301
302 </Table.Cell>
303 </Table.Row>
304 <Table.Row>
305 <Table.Cell>
306
307 BLIK Payments
308
309 </Table.Cell>
310 <Table.Cell>
311
312 `pp_stripe-blik_stripe`
313
314 </Table.Cell>
315 </Table.Row>
316 <Table.Row>
317 <Table.Cell>
318
319 giropay Payments
320
321 </Table.Cell>
322 <Table.Cell>
323
324 `pp_stripe-giropay_stripe`
325
326 </Table.Cell>
327 </Table.Row>
328 <Table.Row>
329 <Table.Cell>
330
331 iDEAL Payments
332
333 </Table.Cell>
334 <Table.Cell>
335
336 `pp_stripe-ideal_stripe`
337
338 </Table.Cell>
339 </Table.Row>
340 <Table.Row>
341 <Table.Cell>
342
343 Przelewy24 Payments
344
345 </Table.Cell>
346 <Table.Cell>
347
348 `pp_stripe-przelewy24_stripe`
349
350 </Table.Cell>
351 </Table.Row>
352 <Table.Row>
353 <Table.Cell>
354
355 PromptPay Payments
356
357 </Table.Cell>
358 <Table.Cell>
359
360 `pp_stripe-promptpay_stripe`
361
362 </Table.Cell>
363 </Table.Row>
364 <Table.Row>
365 <Table.Cell>
366
367 OXXO Payments (Available since [Medusa v2.12.0](https://github.com/medusajs/medusa/releases/tag/v2.12.0))
368
369 </Table.Cell>
370 <Table.Cell>
371
372 `pp_stripe-oxxo_stripe`
373
374 </Table.Cell>
375 </Table.Row>
376 </Table.Body>
377 </Table>
378
379 ---
380
381 ## Setup Stripe Webhooks
382
383 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.
384
385 ### Webhook URL
386
387 Medusa has a `{server_url}/hooks/payment/{provider_id}` API route that you can use to register webhooks in Stripe, where:
388
389 - `{server_url}` is the URL to your deployed Medusa application in server mode.
390 - `{provider_id}` is the ID of the provider as explained in the [Stripe Payment Provider IDs](#stripe-payment-provider-ids) section, without the `pp_` prefix.
391
392 The Stripe Module Provider supports the following payment types, and the webhook endpoint URL is different for each:
393
394 <Table>
395 <Table.Header>
396 <Table.Row>
397 <Table.HeaderCell>
398 Stripe Payment Type
399 </Table.HeaderCell>
400 <Table.HeaderCell>
401 Webhook Endpoint URL
402 </Table.HeaderCell>
403 </Table.Row>
404 </Table.Header>
405 <Table.Body>
406 <Table.Row>
407 <Table.Cell>
408
409 Basic Stripe Payment
410
411 </Table.Cell>
412 <Table.Cell>
413
414 `{server_url}/hooks/payment/stripe_stripe`
415
416 </Table.Cell>
417 </Table.Row>
418 <Table.Row>
419 <Table.Cell>
420
421 Bancontact Payments
422
423 </Table.Cell>
424 <Table.Cell>
425
426 `{server_url}/hooks/payment/stripe-bancontact_stripe`
427
428 </Table.Cell>
429 </Table.Row>
430 <Table.Row>
431 <Table.Cell>
432
433 BLIK Payments
434
435 </Table.Cell>
436 <Table.Cell>
437
438 `{server_url}/hooks/payment/stripe-blik_stripe`
439
440 </Table.Cell>
441 </Table.Row>
442 <Table.Row>
443 <Table.Cell>
444
445 giropay Payments
446
447 </Table.Cell>
448 <Table.Cell>
449
450 `{server_url}/hooks/payment/stripe-giropay_stripe`
451
452 </Table.Cell>
453 </Table.Row>
454 <Table.Row>
455 <Table.Cell>
456
457 iDEAL Payments
458
459 </Table.Cell>
460 <Table.Cell>
461
462 `{server_url}/hooks/payment/stripe-ideal_stripe`
463
464 </Table.Cell>
465 </Table.Row>
466 <Table.Row>
467 <Table.Cell>
468
469 Przelewy24 Payments
470
471 </Table.Cell>
472 <Table.Cell>
473
474 `{server_url}/hooks/payment/stripe-przelewy24_stripe`
475
476 </Table.Cell>
477 </Table.Row>
478 <Table.Row>
479 <Table.Cell>
480
481 PromptPay Payments
482
483 </Table.Cell>
484 <Table.Cell>
485
486 `{server_url}/hooks/payment/stripe-promptpay_stripe`
487
488 </Table.Cell>
489 </Table.Row>
490 <Table.Row>
491 <Table.Cell>
492
493 OXXO Payments (Available since [Medusa v2.12.0](https://github.com/medusajs/medusa/releases/tag/v2.12.0))
494
495 </Table.Cell>
496 <Table.Cell>
497
498 `{server_url}/hooks/payment/stripe-oxxo_stripe`
499
500 </Table.Cell>
501 </Table.Row>
502 </Table.Body>
503 </Table>
504
505 ### Webhook Events
506
507 When you set up the webhook in Stripe, choose the following events to listen to:
508
509 - `payment_intent.amount_capturable_updated`
510 - `payment_intent.succeeded`
511 - `payment_intent.payment_failed`
512 - `payment_intent.partially_funded` (Since [v2.8.5](https://github.com/medusajs/medusa/releases/tag/v2.8.5))
513
514 ---
515
516 ## Useful Guides
517
518 - [Storefront guide: Add Stripe payment method during checkout](../../../../storefront-development/checkout/payment/stripe/page.mdx).
519 - [Integrate in Next.js Starter](../../../../nextjs-starter/page.mdx#stripe-integration).
520 - [Customize Stripe Integration in Next.js Starter](../../../../nextjs-starter/guides/customize-stripe/page.mdx).
521 - [Add Saved Payment Methods with Stripe](../../../../how-to-tutorials/tutorials/saved-payment-methods/page.mdx).