laravel/cashier-braintree
Laravel Cashier driver for Braintree: a simple subscription billing integration for Laravel apps. Manage customers, plans, subscriptions, coupons/discounts, and webhooks with an expressive API built on top of the Braintree PHP SDK.
Pros:
invoice.succeeded, subscription.cancelled) via Laravel’s event system, enabling reactive workflows (e.g., notifications, analytics).tenant_id in subscriptions table).Cons:
illuminate/support (e.g., Str::camel() changes).createAsPending() → create()).braintree/braintree_php (v3.x). Ensure the SDK version aligns with Braintree’s current API (v4.x may introduce breaking changes).subscriptions table (Cashier’s default). Custom schemas may need migration adjustments.user_id, braintree_id, plan, status, trial_ends_at, etc.| Risk Area | Severity | Mitigation Strategy |
|---|---|---|
| Laravel Version Mismatch | High | Test with Laravel 10 in a staging environment; use laravel-shift or manual patches. |
| Braintree API Drift | Medium | Monitor Braintree’s changelog; implement webhook validation. |
| Webhook Handling | Medium | Verify event signatures; log unhandled events. |
| Deprecated Methods | Low | Override Cashier traits or use adapter pattern. |
| Multi-Environment Config | Low | Use Laravel’s .env for Braintree credentials. |
spatie/cashier)?subscription->onFailedPayment()) and customer notifications.--ignore-platform-reqs if PHP version conflicts):
composer require laravel/cashier-braintree
php artisan vendor:publish --provider="Laravel\Cashier\CashierServiceProvider"
php artisan migrate
.env:
BRAINTREE_ENVIRONMENT=sandbox
BRAINTREE_MERCHANT_ID=your_id
BRAINTREE_PUBLIC_KEY=your_key
BRAINTREE_PRIVATE_KEY=your_key
/braintree/webhook) in Braintree dashboard.use Laravel\Cashier\Billable;
class User extends Authenticatable implements Billable { ... }
$user->newSubscription('monthly', 'plan_123')->create($paymentMethodNonce);
EventServiceProvider):
Braintree_Webhook::listen('invoice.succeeded', function ($payload) {
// Handle successful invoice
});
subscription()->cancel()).invoice.succeeded, subscription.cancelled).braintree/braintree_php to avoid compatibility drift.createAsPending).debug mode for Cashier/Braintree logs:
CASHIER_LOG_LEVEL=debug
How can I help you explore Laravel packages today?