Set Up Braintree Payments
If you already have a Braintree account, with negotiated rates and a merchant account for each currency, moving to another processor for WooCommerce means giving that up.
The Braintree module adds Braintree (Stackless) with your own keys. Buyers enter their card on your checkout in Braintree’s secure fields with 3-D Secure, and refunds, voids and disputes sync back. You stay the seller, so tax stays yours.
Run a test payment before you take live ones. This gateway hasn’t taken a sandbox or real Braintree payment.
What Each Edition Includes
| Feature | Stackless Lite for WooCommerce | Stackless for WooCommerce |
|---|---|---|
| One-time payments, refunds, voids and disputes | Yes | Yes |
| Saved cards at checkout | Yes | Yes |
| Subscriptions, free trials and automatic renewals | No | Yes, with Subscriptions on |
| Post-purchase Offers | No | Yes. With 3-D Secure on, the buyer confirms on the payment page |
Before You Start
- A Braintree account, and a sandbox account for testing.
- An active merchant account for each currency you sell in.
- 3-D Secure switched on by Braintree for those merchant accounts. European and UK cards need it.
- An API user that can view merchant accounts and disputes.
- A public HTTPS site for the webhook, and working WordPress scheduled actions.
Turn On the Gateway
- Switch on the Braintree module under Stackless → Dashboard.
- Go to WooCommerce → Settings → Payments → Braintree (Stackless).
- Fill in the keys below, tick Enable (Accept cards with Braintree) and save.
Connect Your Braintree Account
- Click Open the production Control Panel or Open the sandbox Control Panel. Open the gear icon, then API.
- Copy the Merchant ID, public key and private key into the Production or Sandbox fields.
- Save. Stackless checks the keys and reads your merchant accounts. Sandbox is on by default.
To keep credentials out of the database, define them in wp-config.php. Use SANDBOX in place of LIVE for the sandbox. A defined value wins and hides its field:
define('STACKLESS_BRAINTREE_LIVE_MERCHANT_ID', '...');
define('STACKLESS_BRAINTREE_LIVE_PUBLIC_KEY', '...');
define('STACKLESS_BRAINTREE_LIVE_PRIVATE_KEY', '...');
define('STACKLESS_BRAINTREE_LIVE_MERCHANT_ACCOUNTS', 'EUR:store_eur, GBP:store_gbp');
Match Merchant Accounts to Currencies
A Braintree merchant account takes one currency. Stackless charges each order through the account for its currency.
- With one active account in a currency, that account is used.
- With several, the default one is used if it’s among them.
- To choose, fill in Production merchant accounts or Sandbox merchant accounts, for example
EUR:store_eur, GBP:store_gbp. - A chosen account that isn’t active in that currency hides Braintree for the currency, and saving says so.
Choose the Checkout Settings
| Setting | Default | What it does |
|---|---|---|
| 3-D Secure | Required | Refuses failed or skipped bank checks. Strict takes only payments with a liability shift. Off skips the check. |
| Saved cards | On | Lets signed-in customers save cards. Subscription orders that renew automatically always save the card. |
| Fraud tools | Off | Sends device data and loads PayPal’s device script at checkout. Turn it on if your account uses Advanced Fraud Tools or Fraud Protection. |
The 3-D Secure result is checked on your server with Braintree, so it can’t be skipped from the browser.
Connect the Webhook
Stackless doesn’t create this webhook. In each Control Panel, open API → Webhooks, create one with this URL and select the notifications below. Braintree’s webhook guide has the details.
https://yoursite.com/wp-json/stackless/v1/braintree/webhook
dispute_opened
dispute_lost
dispute_won
dispute_accepted
dispute_auto_accepted
dispute_disputed
dispute_expired
dispute_under_review
transaction_settlement_declined
transaction_reviewed
refund_failed
- Use Check URL in the Control Panel to confirm delivery.
- The keys verify each notification, so there’s no separate secret to paste.
- Card payments, refunds and voids send no webhook. Stackless asks Braintree about refunds, voids, declined settlements and disputes every six hours.
Run a Test Payment
- Keep Sandbox on, with the sandbox keys saved.
- Place an order with a Braintree test card, including one that asks for 3-D Secure, and check that it turns paid.
- Refund the whole order before it settles and check that it’s voided.
- If you sell subscriptions, start one and use Process renewal now on the subscription to check that the saved card is charged.
- Untick Sandbox, then make one small real payment and refund it in full.
Sandbox doesn’t pause live renewals: a card saved in production is still charged for real.
Renewal charges don’t run on a site Stackless treats as a copy of your live store, so test them on a separate install with no real customers. Don’t confirm a copy that holds real customers as the live store just to test: its saved cards would be charged.
What Buyers See
- The default title is Credit or debit card, with “Pay securely with your card through Braintree.” Both are editable.
- Card fields show on classic and block checkout, the order payment page and Add payment method.
- Signed-in customers can pick a saved card or Use a new card. With 3-D Secure on, a saved card is checked too.
- If Braintree doesn’t answer, the order goes on hold and Stackless looks the charge up before anything is charged again. The buyer is stopped from paying that order another way meanwhile.
Subscriptions and Renewals
These need Stackless for WooCommerce. Stackless runs the schedule, so no subscription is created at Braintree.
- A subscription that renews automatically saves the card. A free trial verifies and saves it without a charge.
- Renewals charge the saved card as merchant-initiated. If Braintree returns no saved card with a paid first order, renewals are invoiced.
- A renewal without a clear answer stays pending and is looked up before any retry.
- A declined renewal records Braintree’s reason, and your retry settings take over. See Renewals, Failed Payments and Retries.
- When a customer removes a saved card, the live store deletes it from the Braintree vault too, which can’t be undone.
Refunds, Voids and Disputes
- A payment that hasn’t settled can only be refunded whole, which voids it and can’t be undone. Settlement usually takes a day or two.
- A settled payment can be refunded in full or in part from the WooCommerce order screen.
- If Braintree doesn’t confirm a refund, refund the same amount again. The customer is refunded once.
- Refunds and voids made in the Control Panel are recorded on the order at the next six-hour check.
- A chargeback, pre-arbitration or declined settlement puts the order on hold. Other dispute updates add a note. Release the order yourself.
Payments to Review
- An extra payment, or one that arrived too late for its order, gets a note naming the transaction to refund in the Control Panel.
- A payment that doesn’t match, or was refunded before it was confirmed, puts the unpaid order on hold. It won’t be charged again while that payment stands.
- In the paid edition, Billing Health lists extra payments, charges unresolved for over an hour, setup problems and failed webhooks.
Currencies
Braintree shows only where one of your active merchant accounts takes the currency, and tells Currency-Aware Payment Gateways that list. In currencies without decimals, such as JPY, a total with a fraction is refused instead of rounded, so set your store’s decimals to 0.
What Data Is Sent
- With a payment: the amount, currency, an order reference, and the buyer’s name, email and billing address.
- When a card is saved: a Braintree customer with the buyer’s name and email.
- With Fraud tools on: data about the buyer’s device.
- Kept on your site: Braintree’s references and, for saved cards, the brand, last four digits and expiry. Card numbers go straight to Braintree.
Stackless adds suggested Braintree wording to the WordPress privacy policy guide.
Limits
- The gateway hasn’t taken a sandbox or real payment. Test a payment, a refund and any renewal on your own account first.
- It takes cards only. PayPal and wallets aren’t offered through it.
- Braintree can’t be duplicated for a second account.
- Saved cards belong to the Braintree merchant and mode they were saved in. After five tries to add a card from My Account, a customer waits an hour.
- A copy of your store doesn’t charge renewals or one-click offers, but it still sends refunds and takes real checkout payments, saved cards included, when it has production keys. Keep only sandbox keys on copies.
- Debug log writes to WooCommerce → Status → Logs (
stackless-braintree_gateway). Keys, tokens and card data are never logged.
For Developers
stackless_braintree_gateway_webhook runs after each verified notification is applied, with the type, the event and the mode:
add_action('stackless_braintree_gateway_webhook', function ($type, $event, $mode) {
if ($type === 'dispute_opened' && $mode === 'live') {
// Tell your team.
}
}, 10, 3);
Copy templates/braintree_gateway/payment-fields.php to yourtheme/stackless/braintree_gateway/payment-fields.php to change the card form.