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
- Visit Braintree: Go to Braintree and click Sign Up to create a new merchant account or Log In if you already have one.
- Account Creation: Select a business account and provide your email, password, and business details (e.g., company name, country, website URL).
- Email Verification: Check your inbox for a verification email from Braintree and click the link to activate your account.
- 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:
-
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.
-
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.
-
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.
-
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:
- Log in to the Sandbox or Production Dashboard at sandbox.braintreegateway.com or www.braintreegateway.com.
- Go to Settings > API.
- Under API Keys, you’ll find:
- Public Key and Private Key (click View to reveal the Private Key).
- Merchant ID (listed at the top).
- Generate Client Token: Use your server-side code to generate a Client Token via the Braintree SDK (required for client-side integrations).
- Key Security: Keep Private Keys and Client Tokens confidential—use them only server-side. Copy all credentials and store them securely.
- 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:
- Go to Settings > Processing > Payment Methods in the Dashboard.
- 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).
- Enable desired methods by toggling them on. Some (e.g., ACH, Venmo) require additional setup or approval from Braintree support at support@braintreepayments.com.
- 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):
- In the Braintree Dashboard, go to Settings > Webhooks.
- Click Create New Webhook.
- 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.
- Enter the URL from your application (e.g.,
- Events: Select events to subscribe to, such as:
transaction_settled
: Payment completed.transaction_declined
: Payment failed.subscription_charged_successfully
: Recurring payment processed.
- Save the webhook. Braintree will provide a Webhook ID for reference.
- 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:
- Log in to your application’s Admin Panel.
- Navigate to System Settings > Payment Gateways > Braintree.
- Fill out the configuration form:
-
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).
-
Click Submit to save. Your Braintree gateway is now configured.
Step 7: Test the Integration
Test your setup in Sandbox Mode:
- 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.
- Simulate Payments:
- Use Braintree’s test cards:
- Success:
4111 1111 1111 1111
, expiry12/25
, CVV123
. - Decline:
4000 1111 1111 1111
, expiry12/25
, CVV123
.
- Success:
- Test PayPal, ACH, or Venmo with Sandbox accounts (create test accounts in the Sandbox Dashboard).
- Use Braintree’s test cards:
- 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”).
- Check your server logs for webhook events (e.g.,
- 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:
- Braintree Dashboard:
- Ensure your account is verified and ready for live transactions.
- Log in to www.braintreegateway.com.
- 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.
- Webhook Confirmation: Verify the webhook URL is updated in the Production Dashboard.
Step 9: Go Live
Launch your Braintree integration:
- Start Accepting Payments:
- Customers can now pay using enabled methods at checkout.
- Monitor initial transactions closely for issues.
- 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).
- Troubleshooting:
- If payments fail, review error logs in the Dashboard or contact support@braintreepayments.com.
- Ensure your webhook endpoint remains active.
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!