Stripe Module Provider

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

Register the Stripe Module Provider#

Add the module to the array of providers passed to the Payment Module:

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

-


Use Provider#

To use the Stripe provider, create a payment session for the provider:

Code
1const paymentSession =2  await paymentModuleService.createPaymentSession(3    "pay_col_123",4    {5      provider_id: "stripe-usd",6      amount: 5000,7      currency_code: "usd",8      data: {9        // any necessary data10        // to pass to stripe11      },12    }13  )

Stripe Webhook Endpoint URLs#

As mentioned in the prerequisites, when you set up a webhook in Stripe, you set the webhook endpoint URL to {medusa_url}/hooks/payment/stripe_stripe. This endpoint URL is for basic payments with Stripe.

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

Stripe Payment TypeWebhook Endpoint URL

Basic Stripe Payment

{medusa_url}/hooks/payment/stripe_stripe

Bancontact Payments

{medusa_url}/hooks/payment/stripe-bancontact_stripe

BLIK Payments

{medusa_url}/hooks/payment/stripe-blik_stripe

giropay Payments

{medusa_url}/hooks/payment/stripe-giropay_stripe

iDEAL Payments

{medusa_url}/hooks/payment/stripe-ideal_stripe

Przelewy24 Payments

{medusa_url}/hooks/payment/stripe-przelewy24_stripe

PromptPay Payments

{medusa_url}/hooks/payment/stripe-promptpay_stripe


Useful Guides#

Was this page helpful?
Edit this page