Stripe Module Provider

In this document, you’ll learn about the Stripe Module Provider and how to configure it in the Payment Module.

Register the Stripe Module Provider#

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:

medusa-config.ts
1import { Modules } from "@medusajs/framework/utils"2
3// ...4
5module.exports = defineConfig({6  // ...7  modules: [8    {9      resolve: "@medusajs/medusa/payment",10      options: {11        providers: [12          {13            resolve: "@medusajs/medusa/payment-stripe",14            id: "stripe",15            options: {16              apiKey: process.env.STRIPE_API_KEY,17            },18          },19        ],20      },21    },22  ],23})

Environment Variables#

Make sure to add the necessary environment variables for the above options in .env:

Terminal
STRIPE_API_KEY=<YOUR_STRIPE_API_KEY>

Module Options#

OptionDescriptionRequiredDefault

apiKey

A string indicating the Stripe Secret API key.

Yes

-

webhookSecret

A string indicating the Stripe webhook secret. This is only useful for deployed Medusa applications.

Yes

-

capture

Whether to automatically capture payment after authorization.

No

false

automatic_payment_methods

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.

No

false

payment_description

A string used as the default description of a payment if none is available in cart.context.payment_description.

No

-


Setup Stripe Webhooks#

For production applications, you must set up webhooks in Stripe that inform Medusa of changes and updates to payments. Refer to Stripe's documentation on how to setup webhooks.

Webhook URL#

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

  • {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 the following payment types, and the webhook endpoint URL is different for each:

Stripe Payment TypeWebhook Endpoint URL

Basic Stripe Payment

{server_url}/hooks/payment/stripe_stripe

Bancontact Payments

{server_url}/hooks/payment/stripe-bancontact_stripe

BLIK Payments

{server_url}/hooks/payment/stripe-blik_stripe

giropay Payments

{server_url}/hooks/payment/stripe-giropay_stripe

iDEAL Payments

{server_url}/hooks/payment/stripe-ideal_stripe

Przelewy24 Payments

{server_url}/hooks/payment/stripe-przelewy24_stripe

PromptPay Payments

{server_url}/hooks/payment/stripe-promptpay_stripe

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#

Was this page helpful?
Edit this page