PayPal
Integrate with PayPal, built by an official PayPal Partner.
PayPal for Medusa
Accept PayPal and advanced credit card payments in your Medusa v2 store β built by an official PayPal Partner.
π Table of Contents
- π¦ What's included
- β Requirements
- π Installation
- βοΈ Setup
- Step 1 β Configure medusa-config.ts
- Step 2 β Run database migrations
- Step 3 β Connect your PayPal account
- Step 4 β Enable providers in your region
- Step 5 β Configure settings
- Step 6 β Add PayPal to your storefront
- π License
π¦ What's included
Feature Details π΅ PayPal Smart Buttons One-click wallet checkout via PayPal π³ Advanced Card Fields Hosted, PCI-compliant advanced credit card inputs π Admin Dashboard Connect, configure, and switch environments from Medusa Admin π Sandbox & Live Toggle between test and production without restarting β‘ Webhooks Automatically registered and verified with built-in retry support π 3D Secure Configurable SCA/3DS per transaction
β Requirements
- Medusa v2
- Node.js 18+
- PostgreSQL
π Installation
In your Medusa backend directory, run:
1npm install @easypayment/medusa-payment-paypal
βοΈ Setup
Step 1 β Configure Copy to clipboardmedusa-config.ts
Add the plugin and both payment providers to your existing Copy to clipboardmedusa-config.ts:
1234567891011121314151617181920import { loadEnv, defineConfig } from "@medusajs/framework/utils"loadEnv(process.env.NODE_ENV || "development", process.cwd())export default defineConfig({projectConfig: {databaseUrl: process.env.DATABASE_URL,http: {storeCors: process.env.STORE_CORS!,adminCors: process.env.ADMIN_CORS!,authCors: process.env.AUTH_CORS!,jwtSecret: process.env.JWT_SECRET || "supersecret",cookieSecret: process.env.COOKIE_SECRET || "supersecret",},},plugins: [{resolve: "@easypayment/medusa-payment-paypal",options: {},
Step 2 β Run database migrations
1npx medusa db:migrate
Step 3 β Connect your PayPal account
- Start your Medusa server
- Open Medusa Admin β Settings β PayPal β PayPal Connection
- Choose Sandbox (testing) or Live (production)
- Click Connect to PayPal and complete the onboarding flow
Credentials are saved automatically. Prefer manual setup? Click Insert credentials manually and paste your Client ID and Secret from developer.paypal.com.
π Encrypt secrets at rest (recommended for production). Set Copy to clipboardPAYPAL_ENCRYPTION_KEYto any strong random string. The seller client secret and PayPal app access token are then stored AESβ256βGCMβencrypted in the database; without it they are stored in plaintext (the previous default). Encryption is transparent β existing plaintext credentials keep working and are upgraded to ciphertext the next time they are saved/refreshed.
Keep this key safe and backed up: if it is lost, stored credentials cannot be decrypted and you must reconnect PayPal. Rotating the key requires reβsaving credentials.
Step 4 β Enable providers in your region
- Go to Medusa Admin β Settings β Regions β [your region]
- Under Payment Providers, enable:
Provider ID Description Copy to clipboardpp_paypal_paypal PayPal Smart Buttons (wallet) Copy to clipboardpp_paypal_card_paypal_card Advanced Card Fields (card)
Step 5 β Configure settings (optional)
All settings live in Medusa Admin β Settings β PayPal and apply immediately β no server restart needed.
Tab What you can configure PayPal Settings Enable/disable, button color, shape, label Advanced Card Payments Enable/disable, 3D Secure mode Additional Settings Payment action (capture / authorize), brand name, invoice prefix
Step 6 β Add PayPal to your storefront
The checkout UI is shipped as a separate package β install it inside your storefront project, not in this backend.
π¦ @easypayment/medusa-paypal-ui β React components, hooks, and a drop-in payment step adapter for Next.js App Router storefronts.
See the storefront integration & testing guide β
π Observability
- Metrics β operational counters (e.g. Copy to clipboard
create_order_success, Copy to clipboardcapture_order_failed, Copy to clipboardwebhook_success, Copy to clipboardwebhook_dead_letter) are persisted in the Copy to clipboardpaypal_metrictable. - Audit trail β security/lifecycle events (credential changes, environment switches, webhook registration, capture/refund failures, alerts) are emitted as structured JSON log lines tagged Copy to clipboard
"log":"paypal_audit". In production, ship stdout to your log aggregator and filter on that tag. Sensitive fields (secrets, tokens) are redacted before logging. - Webhooks β every received event is recorded in Copy to clipboard
paypal_webhook_eventwith status (Copy to clipboardprocessed/ Copy to clipboardfailed/ Copy to clipboarddead_letter/ Copy to clipboardignored), attempt count, and last error; failures are retried by the Copy to clipboardpaypal-webhook-retryjob.
π License
MIT Β© Easy Payment

