Search for a command to run...
In this guide, you'll learn how to install and configure the PayPal payment provider for Medusa.
yarn add @gorgo/medusa-integration @gorgo/medusa-payment-paypalAdd 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 PAYPAL_INTEGRATION_ID = "paypal-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-paypal/providers/integration-paypal",15 id: PAYPAL_INTEGRATION_ID,16 options: {},17 },18 ],19 },20 },21 {22 resolve: "@gorgo/medusa-payment-paypal",23 options: {},24 },25 ],26 modules: [27 // ...28 {29 resolve: "@medusajs/medusa/payment",30 options: {31 providers: [32 {33 resolve: "@gorgo/medusa-payment-paypal/providers/payment-paypal",34 id: "paypal",35 options: {36 id: PAYPAL_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 client ID, the secret key and the other PayPal settings are not provider options. You enter them in Medusa Admin, as described in Manage PayPal Settings in Medusa Admin.
To properly handle payment notifications from PayPal, configure the webhook URL in your PayPal app as following:
Open your app under Apps & Credentials, with the Sandbox or Live environment that matches the plugin's settings.
In the Webhooks section, click Add Webhook.
Add a new webhook URL in the following format:
Webhook URLhttps://{YOUR_MEDUSA_DOMAIN}/hooks/payment/paypal_paypal
Change with your medusa store domain.
Subscribe the webhook to the and events, and save it.
Copy the webhook ID and enter it in the Webhook ID field of the PayPal settings in Medusa Admin. Test connection then checks that the webhook exists in that environment and is subscribed to both events.