@easypayment/medusa-payment-paypal

中文文档
1.3.3发布于 2026/11/05MITTypeScriptESM + CJS零依赖近 30 天下载 2995

PayPal & credit card payments for Medusa v2 — PayPal Buttons, hosted card fields, 3D Secure, and an admin dashboard. Built by a PayPal Partner.

原始使用文档
文档目录13 节
  1. ✨ What you get
  2. ✅ Requirements
  3. 🚀 Installation
  4. ⚙️ Setup — 5 steps
  5. 1. Add the plugin to medusa-config.ts
  6. 2. Run database migrations
  7. 3. Connect your PayPal account
  8. 4. Turn PayPal on in your region
  9. 5. Add PayPal to your storefront
  10. 🎨 Customize (optional)
  11. 🔐 Going live — two things we recommend
  12. 💬 Support
  13. 📄 License

PayPal for Medusa

Accept PayPal and credit card payments in your Medusa v2 store — built by an official PayPal Partner.

npm version npm downloads License: MIT Medusa v2 PayPal PPCP


✨ What you get

FeatureDetails
🔵 PayPal ButtonsOne-click PayPal checkout for your customers
💳 Card PaymentsSecure credit & debit card fields, hosted by PayPal (PCI compliant)
🛠 Admin DashboardConnect your PayPal account and manage everything from Medusa Admin
🌍 Test & Live modesTry everything safely in Sandbox before going live
🔐 3D SecureExtra card security, configurable in one click
🔄 Reliable by designPayments are verified with PayPal at every step — webhooks, retries, and safety nets are handled for you

✅ Requirements

  • Medusa v2.12+
  • Node.js 20+
  • PostgreSQL

🚀 Installation

In your Medusa backend folder, run:

npm install @easypayment/medusa-payment-paypal

⚙️ Setup — 5 steps

1. Add the plugin to medusa-config.ts

import { 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: {},
    },
  ],

  modules: [
    {
      resolve: "@medusajs/medusa/payment",
      options: {
        providers: [
          {
            // PayPal Buttons
            resolve: "@easypayment/medusa-payment-paypal/providers/paypal",
            id: "paypal",
            options: {},
            dependencies: ["paypal_onboarding"],
          },
          {
            // Card payments
            resolve: "@easypayment/medusa-payment-paypal/providers/paypal_card",
            id: "paypal_card",
            options: {},
            dependencies: ["paypal_onboarding"],
          },
        ],
      },
    },
  ],
})

2. Run database migrations

npx medusa db:migrate

3. Connect your PayPal account

  1. Start your Medusa server
  2. Open Medusa Admin → Settings → PayPal
  3. Choose Sandbox (testing) or Live (real payments)
  4. Click Connect to PayPal and follow the steps

That's it — your credentials are saved automatically. Webhooks are registered for you too.

💡 Prefer manual setup? Click Insert credentials manually and paste your Client ID and Secret from developer.paypal.com.

4. Turn PayPal on in your region

Go to Medusa Admin → Settings → Regions → your region and enable:

Payment providerWhat it is
pp_paypal_paypalPayPal Buttons
pp_paypal_card_paypal_cardCard payments

5. Add PayPal to your storefront

The checkout UI comes as a separate package — install it in your storefront project:

📦 @easypayment/medusa-paypal-ui — ready-made PayPal components for Next.js storefronts, with a step-by-step guide.


🎨 Customize (optional)

Everything is managed in Medusa Admin → Settings → PayPal — changes apply instantly, no restart needed:

  • PayPal Settings — turn PayPal on/off, button color, shape, and label
  • Advanced Card Payments — turn card payments on/off, 3D Secure mode
  • Additional Settings — capture vs. authorize, brand name shown at PayPal, invoice prefix

🔐 Going live — two things we recommend

  1. PAYPAL_ENCRYPTION_KEY — set this to any long random text in your server's environment. Your PayPal credentials are then stored encrypted in the database. Keep the key safe: if it's lost, just reconnect PayPal.
  2. MEDUSA_BACKEND_URL — set this to your backend's public address (e.g. https://api.mystore.com) so PayPal can reach your store for payment notifications.
Advanced options (for developers — everything works without these)
VariableDefaultWhat it does
STOREFRONT_URL(request origin, if listed in STORE_CORS)Storefront address used for PayPal return/cancel pages (can also be set in Admin)
PAYPAL_ENCRYPTION_STRICTfalsetrue = refuse to save credentials unencrypted
PAYPAL_SELLER_NONCE(partner service nonce)Only change this if you also run your own PAYPAL_PARTNER_SERVICE_URL; it must match the nonce that service puts in its onboarding links
PAYPAL_ADMIN_ORIGINfirst ADMIN_CORS entryRestricts the onboarding popup to your admin URL
PAYPAL_WEBHOOK_COMPLETE_CARTtrueSafety net that finishes an order when the payment succeeded but the buyer's browser closed. false disables it
PAYPAL_RATE_LIMIT_MAX / PAYPAL_RATE_LIMIT_WINDOW_MS(off) / 60000Optional request limit for the public checkout routes
PAYPAL_WEBHOOK_RATE_LIMIT_MAX / PAYPAL_WEBHOOK_RATE_LIMIT_WINDOW_MS(off) / 60000Optional request limit for the webhook endpoint (separate from the above)
PAYPAL_WEBHOOK_REPLAY_WINDOW_MINUTES60Rejects webhook deliveries older than this
PAYPAL_WEBHOOK_STALE_PROCESSING_MS300000When the retry job re-picks-up interrupted webhook events
PAYPAL_WEBHOOK_ID_LIVE / PAYPAL_WEBHOOK_ID_SANDBOX(auto)Manual webhook-id override (normally automatic)
PAYPAL_HTTP_TIMEOUT_MS30000Timeout for calls to PayPal
PAYPAL_CURRENCYEURFallback currency if none is configured
PAYPAL_ALERT_WEBHOOK_URLS(unset)Comma-separated URLs that receive operational alerts (including dead-lettered webhook events)
PAYPAL_SETTINGS_CACHE_MS15000In-process cache for plugin settings reads; 0 disables
PAYPAL_SEND_SHIPPING_ADDRESSfalsetrue sends the cart's shipping address on PayPal orders (SET_PROVIDED_ADDRESS) — improves PayPal Seller Protection eligibility
PAYPAL_PARTNER_SERVICE_URL(built-in)Override the partner onboarding service used by the connect flow
PAYPAL_PARTNER_MERCHANT_ID_SANDBOX / PAYPAL_PARTNER_MERCHANT_ID_LIVE(built-in)Override the partner merchant ids used for onboarding

Declined cards: when PayPal declines a capture, /store/paypal/capture-order responds 402 with a buyer-friendly message plus a structured decline object — { code, message, retryable, avs_code?, cvv_code? } — so storefronts can show "insufficient funds, try another card" and decide whether to offer a retry.

Monitoring: operational counters live in the paypal_metric table; every webhook is recorded in paypal_webhook_event with automatic retries (events that exhaust retries are dead-lettered and pushed to PAYPAL_ALERT_WEBHOOK_URLS); audit events are logged as JSON lines tagged "log":"paypal_audit" (secrets redacted).


💬 Support


📄 License

MIT © Easy Payment

版本与发布记录

@easypayment/medusa-payment-paypal 共发布 63 个版本,首次发布于 2026/03/26;过去 12 个月发布了 63 个版本。

版本发布日期距今
1.3.3latest2026/11/058 天前
1.3.22026/10/071 个月前
1.3.12026/10/061 个月前
1.3.02026/10/061 个月前
1.2.82026/09/281 个月前
1.2.72026/09/231 个月前

关于 @easypayment/medusa-payment-paypal 的常见问题

@easypayment/medusa-payment-paypal 是什么?

PayPal & credit card payments for Medusa v2 — PayPal Buttons, hosted card fields, 3D Secure, and an admin dashboard. Built by a PayPal Partner.

如何安装 @easypayment/medusa-payment-paypal?

在项目目录运行 npm install @easypayment/medusa-payment-paypal,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@medusajs/medusa(^2.12.0)、@medusajs/framework(^2.12.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@easypayment/medusa-payment-paypal 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@easypayment/medusa-payment-paypal 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@easypayment/medusa-payment-paypal 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=20。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@easypayment/medusa-payment-paypal 可以商用吗?

@easypayment/medusa-payment-paypal 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@easypayment/medusa-payment-paypal 的下载量有多少?

根据 npm 官方下载统计,@easypayment/medusa-payment-paypal 在 2026/10/13 – 2026/11/11 这 30 天内被下载 2,995 次,日均约 100 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@easypayment/medusa-payment-paypal 还在维护吗?

最新版本 1.3.3 发布于 2026/11/05(8 天前);至今共发布 63 个版本,其中过去 12 个月发布了 63 个;首次发布于 2026/03/26。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。