> ## Documentation Index
> Fetch the complete documentation index at: https://docs.subscribd.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Braintree

> Configure Braintree as your payment gateway

# Braintree

The Braintree gateway supports card payments, PayPal via Braintree, and Venmo in markets where available. It is a separate package dependency — install `braintree/braintree_php` to use it.

## Install the Braintree SDK

```bash theme={null}
composer require braintree/braintree_php:"^6.32"
```

## Configuration

```php theme={null}
// config/subscribd.php
'gateways' => [
    'braintree' => [
        'driver'      => \Pixelworxio\Subscribd\Gateways\BraintreeGateway::class,
        'environment' => env('BRAINTREE_ENV', 'production'),
        'merchant_id' => env('BRAINTREE_MERCHANT_ID'),
        'public_key'  => env('BRAINTREE_PUBLIC_KEY'),
        'private_key' => env('BRAINTREE_PRIVATE_KEY'),
    ],
],
```

## Environment variables

```env theme={null}
BRAINTREE_ENV=production
BRAINTREE_MERCHANT_ID=...
BRAINTREE_PUBLIC_KEY=...
BRAINTREE_PRIVATE_KEY=...
```

Set `BRAINTREE_ENV=sandbox` for development and testing.

## Webhooks

Register `https://yourapp.com/subscribd/webhook/braintree` as a webhook endpoint in the Braintree Control Panel. Enable:

* `subscription_charged_successfully`
* `subscription_charged_unsuccessfully`
* `subscription_canceled`
* `subscription_expired`
* `subscription_trial_ended`
* `subscription_went_past_due`
* `subscription_went_active`

## Limitations

* `interval_count` must be `1`. Braintree does not support billing cycles with `interval_count > 1`. Subscribd throws `SubscriptionException` if you attempt to create a subscription on a plan with `interval_count > 1` using this gateway.
* Trial extension is not supported natively. `ExtendTrial` updates the local `trial_ends_at` only.
* Proration is handled by Subscribd's built-in `ProrationEngine`.
* Pausing is not supported natively. Subscribd updates the local status only; billing at Braintree continues until the subscription is canceled.

## Next steps

* **[Paddle](/gateways/paddle)** — Merchant of Record gateway
* **[Webhooks](/advanced/webhooks)** — Full webhook reference
