• Модуль интеграций
  • Сообщество
  • Блог
Документация
Плагины и интеграцииВсе расширения для Medusa от сообществаСтартерыЗапускайте проекты быстрее с готовыми решениями
ЭкспертыПодберите специалиста для разработки и развития вашего проекта на MedusaКейсыПосмотрите примеры Medusa в продакшене и успешные внедрения
Представляем готовый к продакшену Medusa DTC Starter от Gorgo

26 августа 2026 г. · Продукт

Gorgo снижает затраты на адаптацию Medusa к локальным рынкам.

Мы разрабатываем плагины интеграции, осуществляем поддержку и развиваем сообщество разработчиков на Medusa в Telegram.

  • Ресурсы Medusa
  • Плагины и интеграции
  • Модуль интеграций
  • Стартеры
  • Эксперты
  • Кейсы
  • Medusa Чат в Telegram
  • Medusa Новости в Telegram
  • Документация Gorgo
  • Связаться с нами
  • TelegramGitHub
Плагины
B

Braintree

Плагин платёжного провайдера Braintree для Medusa v2. Приём кредитных и дебетовых карт и ACH Direct Debit с 3D Secure, сохранением карт, возвратами и обновлением статусов платежей через вебхуки.

npm install @easypayment/medusa-payment-braintree
Категория
Платежи
Создано
Easypayment
Версия
0.0.5
Последнее обновление
1 неделю назад
Ежемесячные загрузки
Загрузка данных
Звезды на Github
0
npmNPMGitHubGithub

Braintree Payments for Medusa v2

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).

Table of Contents

  • Highlights
  • Payment Methods
  • Requirements
  • Installation
  • Configuration
  • Provider Options
  • ACH Direct Debit
  • 3D Secure
  • Webhooks
  • Custom Fields
  • Imported Payments Provider
  • Sandbox & Testing
  • Debug Logging
  • Support
  • Contributing
  • Security
  • License

Highlights

  • Two payment methods — Credit / Debit Card and ACH Direct Debit (US bank accounts), each exposed as its own Medusa payment provider so your checkout can offer them side by side.
  • Full payment lifecycle — initiate, authorize, capture (manual or automatic), refund, void, and cancel, mapped cleanly onto Braintree transaction states.
  • 3D Secure — opt-in strong customer authentication via a single config flag.
  • Vaulting — save customer payment methods in the Braintree Vault for one-click repeat purchases.
  • Webhook validation — Braintree webhook signatures are verified before any payment state changes are applied.
  • Client-token caching — client tokens are cached per customer through Medusa's cache module, cutting redundant gateway calls.
  • Imported payments — a second provider () for orders migrated from another platform, with safe refund/void handling against the original Braintree transactions.
  • Actionable errors — processor declines, gateway rejections, and validation errors surface with their Braintree codes instead of generic failures.
  • Typed end to end — written in strict TypeScript against the official Braintree SDK and Medusa v2 provider interfaces, with a Jest test suite covering the payment flows.

Payment Methods

The plugin registers three Medusa payment provider services from one module:

Provider idPayment methodNotes
Credit / Debit CardCards tokenized by the Braintree client SDK; supports 3D Secure and vaulting.
ACH Direct DebitUS bank accounts tokenized by the Braintree client SDK; bank-account verification and (optionally) a dedicated ACH merchant account.
Imported paymentsFor 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.

Requirements

  • Node.js
  • Medusa
  • A Braintree account (sandbox or production) with API credentials

Installation

Configuration

1. Environment variables

Add your Braintree credentials to :

2. Register the provider

Add the provider to the module in :

This single entry registers all three provider services (, , and ) — they share the same options.

3. Restart your Medusa server

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.

Provider Options

OptionTypeDefaultDescription
— (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.

ACH Direct Debit

The provider accepts US bank account payments through Braintree's ACH Direct Debit rails:

  • Client side — tokenize the customer's bank account details (routing/account number or bank login) with the Braintree client SDK's US bank account component to obtain a nonce, exactly as you would for a card. See the Braintree ACH guide.
  • Verification — the provider sends (default , configurable via ) with every sale and vaulting request, so bank accounts are verified as part of the transaction.
  • Settlement — Braintree requires ACH transactions to be submitted for settlement immediately; the provider enforces this regardless of . Note that ACH settlement is not instant — funds typically clear in a few business days, and the / webhooks are how your store learns the outcome, so configure webhooks.
  • Merchant account — ACH must be enabled on your Braintree account. If it runs through a dedicated merchant account, set .
  • 3D Secure — does not apply to bank accounts; the ACH provider never requests it, even when is on.

3D Secure

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.

Webhooks

Braintree notifies your store when transactions settle or are declined at settlement:

  1. In the Braintree control panel, go to Settings → Webhooks.
  2. Add a webhook pointing at your Medusa server's payment webhook endpoint, e.g. .
  3. Incoming notifications are parsed and signature-verified with your gateway credentials; invalid payloads are rejected.

Handled notification kinds:

Braintree notificationMedusa action
Payment marked successful
Payment marked failed
anything elseIgnored ()

Webhook correlation relies on the custom field — see below.

Custom Fields

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 nameAPI namePurpose
Medusa Payment Session IdWebhook correlation back to the Medusa payment session
Cart IdTraceability
Customer IdTraceability

Example authorize call shape:

Only fields that exist in your Braintree dashboard are accepted, and values must be strings.

Imported Payments Provider

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:

  • Sessions are keyed by the original Braintree .
  • Refunds and cancellations are executed against the real Braintree transaction — voided while /, refunded once /.
  • Orders imported as already refunded () record refunds locally without touching Braintree.
  • With , refunding a transaction that was already refunded upstream logs a warning and records the refund locally instead of failing the operation.

Register it with the same options under the id if you need it.

Sandbox & Testing

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:

Debug Logging

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.

Support

  • Step-by-step setup help (non-technical friendly): Complete Setup Guide
  • Checkout/frontend integration: Storefront Integration Guide
  • Bug reports and feature requests: GitHub Issues
  • Braintree platform documentation: developer.paypal.com/braintree

Contributing

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.

Security

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.

License

MIT © EasyPayment — see LICENSE for the full notice.

Еще в этой категории

Посмотреть все
Платежи
Braintree logo

Braintree

От Lambda Curry

Поддержка платежей и 3D Secure через Braintree

Загрузка данных
GitHubnpm
Платежи
Pay. logo

Pay.

От Webbers

Принимайте кредитные карты, цифровые платежи и купи сейчас, плати потом

Загрузка данных
GitHubnpm
Платежи
Mollie logo

Mollie

От Variable Vic

Легко принимайте мультивалютные платежи через Mollie

Загрузка данных
GitHubnpm

Еще от этого автора

Посмотреть все
Платежи
P

Paypal

От Easypayment

Интеграция PayPal для Medusa v2

Загрузка данных
GitHubnpm
1npm install @easypayment/medusa-payment-braintree
2# or
3yarn add @easypayment/medusa-payment-braintree
1BRAINTREE_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=sandbox
6BRAINTREE_ENABLE_3D_SECURE=false
7BRAINTREE_LOGGING=false
1import { 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 Debit
24 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=sandbox
2TEST_FORCE_SETTLED=true
1npm install
2npm run typecheck
3npm test