Braintree payment provider plugin for Medusa v2 — accept credit/debit cards and ACH Direct Debit with 3D Secure, vaulting, refunds, and webhook-driven payment updates.
Accept Credit / Debit Cards and ACH Direct Debit in your Medusa store
with the full Braintree payment lifecycle — by EasyPayment.
Installation · Configuration · Provider Options · Setup Guide · Storefront Guide · Changelog
is a production-grade Braintree (a PayPal service) payment provider for Medusa v2. It gives your Medusa store two customer-facing payment methods — Credit / Debit Card and ACH Direct Debit — with the full Braintree payment lifecycle: client-token generation, authorization, capture, refunds, voids, vaulted payment methods, 3D Secure, and webhook-driven status updates, all behind Medusa's standard payment provider interface.
Built and maintained by EasyPayment.
New to Medusa or not a developer? Follow the Complete Setup Guide — a plain-language, step-by-step walkthrough from creating a Braintree account to your first live payment, written for store owners as well as developers.
Building the checkout? The Storefront Integration Guide shows step by step how to display the Card and ACH payment methods in your checkout's payment list and wire up the full payment flow (Drop-in, ACH, 3D Secure, Next.js starter).
The plugin registers three Medusa payment provider services from one module:
| Provider id | Payment method | Notes |
|---|---|---|
| Credit / Debit Card | Cards tokenized by the Braintree client SDK; supports 3D Secure and vaulting. | |
| ACH Direct Debit | US bank accounts tokenized by the Braintree client SDK; bank-account verification and (optionally) a dedicated ACH merchant account. | |
| Imported payments | For orders migrated from another platform — see Imported Payments Provider. |
Enable each method per region in the Medusa admin like any other payment provider, and your storefront presents "Credit Card" and "ACH / Bank Debit" as separate options at checkout.
Add your Braintree credentials to :
Add the provider to the module in :
This single entry registers all three provider services (, , and ) — they share the same options.
The providers register themselves with Medusa's payment module on boot. Enable Credit Card () and ACH Direct Debit () for your regions in the Medusa admin.
| Option | Type | Default | Description |
|---|---|---|---|
| — (required) | Braintree gateway environment. | ||
| — (required) | Braintree merchant ID. | ||
| — (required) | Braintree public key. | ||
| — (required) | Braintree private key. | ||
| — (required) | Secret used when validating incoming Braintree webhooks. | ||
| Optional default currency code. | |||
| Require 3D Secure verification on transactions. | |||
| Store payment methods in the Braintree Vault on success. | |||
| Submit transactions for settlement immediately after authorization. ACH transactions are always submitted for settlement regardless of this flag (a Braintree requirement). | |||
| Merchant account to route ACH transactions and bank-account verifications through. Set this when your default merchant account does not support ACH. | |||
| How Braintree verifies US bank accounts for ACH. | |||
| Imported provider only: record refunds locally (with a warning) when the Braintree transaction was already refunded upstream. | |||
| Verbose debug logging through Medusa's logger. Keep off in production unless actively debugging. |
The provider accepts US bank account payments through Braintree's ACH Direct Debit rails:
Set to require 3D Secure on every transaction. Your storefront must complete the 3DS challenge flow when requesting the payment method nonce — see the Braintree 3D Secure guide for the client-side setup.
Braintree notifies your store when transactions settle or are declined at settlement:
Handled notification kinds:
| Braintree notification | Medusa action |
|---|---|
| Payment marked successful | |
| Payment marked failed | |
| anything else | Ignored () |
Webhook correlation relies on the custom field — see below.
The provider forwards to Braintree's on the sale request. Fields must first be created in the Braintree control panel (Account Settings → Transactions → Custom Fields, option "Store and Pass back"; API names must be lowercase).
Recommended fields:
| Field name | API name | Purpose |
|---|---|---|
| Medusa Payment Session Id | Webhook correlation back to the Medusa payment session | |
| Cart Id | Traceability | |
| Customer Id | Traceability |
Example authorize call shape:
Only fields that exist in your Braintree dashboard are accepted, and values must be strings.
Alongside the main provider, the plugin ships an provider for orders migrated from another platform whose payments already live in Braintree. It lets migrated orders participate in Medusa's payment flows without re-charging anyone:
Register it with the same options under the id if you need it.
In the Braintree sandbox, transactions tend to sit in or , which exercises the void path on refund. To exercise the true refund path (settled transactions) without waiting for settlement:
With both set, the provider settles the transaction through Braintree's sandbox testing API before refunding. This switch is sandbox-only — outside the sandbox environment it is ignored and a warning is logged. Never enable it in production.
Run the plugin's own test suite from a checkout of this repository:
Set (or with the config shown above) to log operation context for every payment flow — initiate, authorize, capture, refund, void, webhooks — plus expanded Braintree failure details (validation errors, processor response codes) through Medusa's logger with an prefix. Logs are emitted at level, so make sure Medusa's includes to see them.
Contributions are welcome! Please read the Contributing Guide for the development workflow and pull-request checklist. In short: keep changes focused, add tests for behavior changes, and make sure , , and all pass.
This plugin handles payment flows, so security reports are taken seriously. Please do not open public issues for vulnerabilities — report them privately as described in the Security Policy. Card data never touches your server: Braintree's client SDK tokenizes it in the browser, and webhook payloads are signature-verified before any payment state changes.
1npm install @easypayment/medusa-payment-braintree2# or3yarn add @easypayment/medusa-payment-braintree1BRAINTREE_MERCHANT_ID=<your_merchant_id>2BRAINTREE_PUBLIC_KEY=<your_public_key>3BRAINTREE_PRIVATE_KEY=<your_private_key>4BRAINTREE_WEBHOOK_SECRET=<your_webhook_secret>5BRAINTREE_ENVIRONMENT=sandbox6BRAINTREE_ENABLE_3D_SECURE=false7BRAINTREE_LOGGING=false1import { Modules } from '@medusajs/framework/utils';2
3// ...4{5 resolve: '@medusajs/medusa/payment',6 dependencies: [Modules.CACHE],7 options: {8 providers: [9 {10 resolve: '@easypayment/medusa-payment-braintree/providers/easypayment-braintree',11 id: 'braintree',12 options: {13 environment: process.env.BRAINTREE_ENVIRONMENT ?? 'sandbox',14 merchantId: process.env.BRAINTREE_MERCHANT_ID,15 publicKey: process.env.BRAINTREE_PUBLIC_KEY,16 privateKey: process.env.BRAINTREE_PRIVATE_KEY,17 webhookSecret: process.env.BRAINTREE_WEBHOOK_SECRET,18 defaultCurrencyCode: 'USD',19 enable3DSecure: process.env.BRAINTREE_ENABLE_3D_SECURE === 'true',20 savePaymentMethod: true,21 autoCapture: true,22 allowRefundOnRefunded: false,23 // ACH Direct Debit24 achMerchantAccountId: process.env.BRAINTREE_ACH_MERCHANT_ACCOUNT_ID,25 achVerificationMethod: 'network_check',26 logging: process.env.BRAINTREE_LOGGING === 'true',27 },28 },29 ],30 },31}1await provider.authorizePayment({2 data: {3 amount: 10, // standard currency units — converted to "10.00"4 currency_code: 'USD',5 payment_method_nonce: '<client-side-nonce>',6 },7 context: {8 idempotency_key: 'sess_123',9 customer: { id: 'cust_123', email: 'customer@example.com' },10 custom_fields: {11 medusa_payment_session_id: 'sess_123',12 cart_id: 'cart_123',13 customer_id: 'cust_123',14 },15 },16});1BRAINTREE_ENVIRONMENT=sandbox2TEST_FORCE_SETTLED=true1npm install2npm run typecheck3npm test