Search for a command to run...
In this guide, you'll learn how to install and configure the Stripe payment provider for Medusa, set up its webhook and the domains for wallets, and switch from Medusa's built-in Stripe provider.
yarn add @gorgo/medusa-integration @gorgo/medusa-payment-stripeAdd the configurations of the Integration Module provider and of the Medusa Payment Module in your file of the Medusa Admin application:
medusa-config.ts1// ...2const STRIPE_INTEGRATION_ID = "stripe-1"34module.exports = defineConfig({5 // ...6 plugins: [7 // ...8 {9 resolve: "@gorgo/medusa-integration",10 options: {11 encryptionKey: process.env.INTEGRATION_ENCRYPTION_KEY,12 providers: [13 {14 resolve: "@gorgo/medusa-payment-stripe/providers/integration-stripe",15 id: STRIPE_INTEGRATION_ID,16 options: {},17 },18 ],19 },20 },21 {22 resolve: "@gorgo/medusa-payment-stripe",23 options: {},24 },25 ],26 modules: [27 // ...28 {29 resolve: "@medusajs/medusa/payment",30 options: {31 providers: [32 {33 resolve: "@gorgo/medusa-payment-stripe/providers/payment-stripe",34 id: "stripe",35 options: {36 id: STRIPE_INTEGRATION_ID37 }38 },39 ],40 },41 },42 ],43})
The payment provider registered this way gets the id , and its webhook route is .
Add environment variables with your secret :
.envINTEGRATION_ENCRYPTION_KEY=supersecret
The secret key, the publishable key and the other Stripe settings are not provider options. You enter them in Medusa Admin, as described in Manage Stripe Settings in Medusa Admin.
To properly handle payment notifications from Stripe, add a webhook endpoint for your store in the Stripe Dashboard:
Open Webhooks in the Stripe Dashboard, in the test or live mode that matches your keys.
Add an endpoint with the URL in the following format:
Webhook URLhttps://{YOUR_MEDUSA_DOMAIN}/hooks/payment/stripe_stripe
Change with your medusa store domain.
Select the and events, and save the endpoint.
Reveal the endpoint's signing secret, which starts with , and enter it in the Webhook signing secret field of the Stripe settings in Medusa Admin. Test connection then checks that an enabled endpoint whose URL contains exists in that mode and sends both events.
During development, the Stripe CLI forwards the events to your local backend and prints the signing secret to use:
stripe listen --forward-to localhost:9000/hooks/payment/stripe_stripe
Apple Pay, Google Pay and Link appear only on domains registered with Stripe. Register every domain and subdomain that shows the checkout, as described in Stripe's guide to registering payment method domains. A domain registered in live mode is registered in test mode too.
Until the domain is registered, the wallets stay hidden, and the express checkout row shows no Stripe button.
The plugin registers under the same provider id and webhook URL as Medusa's built-in , so it replaces it without a data migration. The payments, the sessions and the saved cards the built-in provider created stay in the database, and the plugin captures, refunds and cancels those payments.
To switch:
Replace in the of the Payment Module with , keeping , and register the integration provider as shown in Configuration. Keep only one of the two providers with .
Enter the keys in Medusa Admin. The built-in provider read and from , and the plugin reads them from its settings.
Set Payment capture in the settings. The built-in provider only authorizes by default, and its option matches Capture right away.
Keep the webhook endpoint you already have in the Stripe Dashboard, since the URL stays , and enter its signing secret in the settings.
The built-in provider also registered a provider per payment method, such as or . The plugin has one provider, and the Payment Element shows the methods your Stripe account or the payment method configuration enables, iDEAL and Bancontact included. Stripe does not offer BLIK on a PaymentIntent created at payment time, as its guide to collecting payment details before creating an Intent notes, so BLIK is not available.