Skip to main content

Braintree Payment Gateway Integration

Braintree, a PayPal service, is a full-stack payment platform designed to simplify online and mobile payments for businesses worldwide. It supports a wide range of payment methods, including credit/debit cards (Visa, MasterCard, American Express), digital wallets (PayPal, Venmo, Apple Pay, Google Pay), and ACH Direct Debit, with availability in over 45 countries and support for 130+ currencies. Braintree offers features like fraud protection, recurring billing, and seamless integrations via its robust API and SDKs, making it a popular choice for e-commerce businesses of all sizes.

This guide walks you through integrating Braintree into your application, from account creation to live deployment.


Step 1: Log in or Sign Up

  1. Visit Braintree: Go to Braintree and click Sign Up to create a new merchant account or Log In if you already have one.
  2. Account Creation: Select a business account and provide your email, password, and business details (e.g., company name, country, website URL).
  3. Email Verification: Check your inbox for a verification email from Braintree and click the link to activate your account.
  4. Sandbox Access: Upon signup, you’ll automatically get a Sandbox account for testing. Log in to the Braintree Sandbox at sandbox.braintreegateway.com to explore features before going live.

Step 2: Set Up Your Account

Before processing live payments, configure your Braintree account:

  1. Complete Your Profile:

    • In the Braintree Dashboard, go to Settings > Business.
    • Enter your business details: legal name, address, phone number, and website URL (required for live transactions).
    • For individuals, provide personal details instead.
  2. Business Verification (Required for Live Mode):

    • Navigate to Settings > Processing > Underwriting.
    • Submit documents such as a business license, ID, and bank account details (requirements vary by country).
    • Verification typically takes 1-2 business days. You’ll receive an email once approved.
  3. Add a Settlement Bank:

    • Go to Settings > Processing > Bank Accounts.
    • Add your bank details (e.g., IBAN or routing/account number) for payouts.
    • Braintree may send a small test deposit to verify the account.
  4. Sandbox Mode: Use the Sandbox immediately for testing without verification. Live mode requires approval.


Step 3: Obtain API Credentials

Braintree provides several credentials for integration:

  • Merchant ID: Unique identifier for your account.
  • Public Key: Used in client-side code (e.g., checkout forms).
  • Private Key: Used in server-side code for secure API calls.
  • Client Token: Generated server-side for client-side authorization (preferred for Drop-in UI).
How to Get Your Credentials:
  1. Log in to the Sandbox or Production Dashboard at sandbox.braintreegateway.com or www.braintreegateway.com.
  2. Go to Settings > API.
  3. Under API Keys, you’ll find:
    • Public Key and Private Key (click View to reveal the Private Key).
    • Merchant ID (listed at the top).
  4. Generate Client Token: Use your server-side code to generate a Client Token via the Braintree SDK (required for client-side integrations).
  5. Key Security: Keep Private Keys and Client Tokens confidential—use them only server-side. Copy all credentials and store them securely.
  6. Add these to your application’s Admin Panel under System Settings > Payment Gateways > Braintree.

Step 4: Configure Payment Methods

Braintree supports multiple payment methods, some of which require activation:

  1. Go to Settings > Processing > Payment Methods in the Dashboard.
  2. Available methods include:
    • Cards: Visa, MasterCard, AmExpress (enabled by default).
    • Digital Wallets: PayPal, Venmo (US-only), Apple Pay, Google Pay (enable via settings).
    • ACH Direct Debit: US-only (request activation).
    • Local Methods: Varies by region (e.g., Sofort in Europe—contact support).
  3. Enable desired methods by toggling them on. Some (e.g., ACH, Venmo) require additional setup or approval from Braintree support at support@braintreepayments.com.
  4. These methods will appear in your checkout flow once integrated.

Step 5: Set Up Webhooks

Webhooks notify your server of payment events (e.g., transaction success):

  1. In the Braintree Dashboard, go to Settings > Webhooks.
  2. Click Create New Webhook.
  3. Webhook URL:
    • Enter the URL from your application (e.g., https://yourwebsite.com/webhooks/braintree).
    • Find this URL in your Admin Panel under Braintree settings.
    • Ensure your endpoint accepts POST requests and returns a 200 OK response.
  4. Events: Select events to subscribe to, such as:
    • transaction_settled: Payment completed.
    • transaction_declined: Payment failed.
    • subscription_charged_successfully: Recurring payment processed.
  5. Save the webhook. Braintree will provide a Webhook ID for reference.
  6. Testing: Use the Test Webhook feature to send a sample notification and verify your endpoint.

Step 6: Set Up Credentials in Our Dashboard

Integrate Braintree into your application:

  1. Log in to your application’s Admin Panel.
  2. Navigate to System Settings > Payment Gateways > Braintree.

Braintree API Keys

  1. Fill out the configuration form:

Braintree API Keys

  1. Detailed Fields:

    • Supported Currencies: Select currencies (e.g., USD, EUR, AUD) enabled on your Braintree account. Each Merchant ID supports one currency—create additional Merchant IDs for multi-currency support.
    • Active: Toggle “On” to enable Braintree payments.
    • Live Mode: Toggle “Off” for Sandbox, “On” for live transactions.
    • Merchant ID: Enter your Braintree Merchant ID.
    • Public Key: Enter your Public Key (e.g., abc123xyz).
    • Private Key: Enter your Private Key (e.g., xyz789abc).
    • Webhook URL: Copy this URL and paste it into the Braintree Dashboard’s webhook settings.
    • Minimum Amount: Set a floor (e.g., $1.00) to prevent micro-transactions.
    • Maximum Amount: Set a ceiling (e.g., $10,000) based on your needs.
    • Fixed Charge: Add a flat fee (e.g., $0.50) per transaction, if applicable.
    • Percentage Charge: Add a percentage fee (e.g., 2%) on top of Braintree’s fees (2.59% + $0.49 per card transaction).
  2. Click Submit to save. Your Braintree gateway is now configured.


Step 7: Test the Integration

Test your setup in Sandbox Mode:

  1. Enable Sandbox Mode:
    • In your Admin Panel, ensure Live Mode is off and use Sandbox credentials.
    • Log in to sandbox.braintreegateway.com to monitor test transactions.
  2. Simulate Payments:
    • Use Braintree’s test cards:
      • Success: 4111 1111 1111 1111, expiry 12/25, CVV 123.
      • Decline: 4000 1111 1111 1111, expiry 12/25, CVV 123.
    • Test PayPal, ACH, or Venmo with Sandbox accounts (create test accounts in the Sandbox Dashboard).
  3. Verify Webhooks:
    • Check your server logs for webhook events (e.g., transaction_settled).
    • Ensure payment statuses update in your Admin Panel (e.g., “Paid,” “Declined”).
  4. Debugging: If issues occur, check the Sandbox Dashboard’s Transactions tab for error codes (e.g., “Processor Declined”).

Step 8: Enable Live Mode

After successful testing:

  1. Braintree Dashboard:
  2. Admin Panel:
    • Go to System Settings > Payment Gateways > Braintree.
    • Toggle Live Mode to “On”.
    • Confirm your Merchant ID, Public Key, and Private Key match your production credentials.
    • Save the changes.
  3. Webhook Confirmation: Verify the webhook URL is updated in the Production Dashboard.

Step 9: Go Live

Launch your Braintree integration:

  1. Start Accepting Payments:
    • Customers can now pay using enabled methods at checkout.
    • Monitor initial transactions closely for issues.
  2. Live Verification:
    • In the Production Dashboard, go to Transactions to track payments in real-time.
    • Confirm funds settle into your bank account (typically 2-3 business days).
  3. Troubleshooting:

Additional Tips

  • Braintree Fees: Standard rate is 2.59% + $0.49 per card transaction; ACH is 0.75% (capped at $5). Check pricing for details and adjust your charges.
  • Documentation: Explore the Braintree Developer Docs for advanced features like recurring billing or 3D Secure.
  • Support: Contact Braintree via support@braintreepayments.com or the Dashboard’s help section.

Note:

If you need further assistance, our support team is available 24/7. Reach out at softivus@gmail.com or through the Admin Panel. Let’s get your Braintree integration live and thriving!