Download the PHP package zeevx/laravel-bachs without Composer
On this page you can find all versions of the php package zeevx/laravel-bachs. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download zeevx/laravel-bachs
More information about zeevx/laravel-bachs
Files in zeevx/laravel-bachs
Package laravel-bachs
Short Description Laravel integration for the Bachs API.
License MIT
Homepage https://github.com/zeevx/laravel-bachs
Informations about the package laravel-bachs
Bachs for Laravel
Laravel integration for zeevx/php-bachs. It provides automatic package discovery, container bindings, a facade, publishable configuration, signature verification, a webhook route, and a framework event while leaving billing tables and business rules in your application.
Requirements
- PHP 8.2 or newer
- Laravel 11, 12, or 13
zeevx/php-bachs1.x
Installation
Laravel discovers Zeevx\LaravelBachs\BachsServiceProvider automatically.
Environment
Use https://api.bachs.io for production. Keep the API key and webhook secret server-side and never expose them to browser JavaScript.
Configuration
The published config/bachs.php contains:
Disable the included webhook route when your application needs to register a custom controller or route group.
Resolving the client
Use dependency injection:
Or use the facade:
All SDK resources are available:
See the PHP SDK documentation for response objects, exceptions, and complete examples.
Webhooks
By default, the package registers:
The VerifyWebhookSignature middleware:
- Reads the exact raw request body.
- Requires
X-Bachs-TimestampandX-Bachs-Signature. - Rejects requests outside the configured tolerance.
- Verifies the HMAC SHA-256 signature with
BACHS_WEBHOOK_SECRET. - Parses the verified payload into a typed
WebhookEvent.
Invalid requests receive a generic HTTP 400 response. Valid requests dispatch Zeevx\LaravelBachs\Events\WebhookReceived and receive HTTP 204.
If the route uses Laravel's web middleware, exempt the configured path from CSRF protection in your application bootstrap:
Handling events
Register a listener in your application:
A queued listener keeps webhook responses fast:
Bachs delivers webhooks at least once. Store the event ID under a unique constraint and make handlers idempotent before granting credits, activating subscriptions, or changing entitlements.
Application responsibilities
This package intentionally does not provide models, migrations, plan configuration, or a Cashier-style billing schema. Your application should own:
- Bachs customer IDs associated with local users or teams
- Provider-neutral subscription records and statuses
- Product-to-plan mappings and feature entitlements
- Currency policy and allowed payment methods
- Checkout references and metadata
- Webhook event idempotency and retry state
- One-time purchase fulfilment and ledgers
- Subscription migration from a previous provider
Keeping those rules outside the integration package makes the package reusable and prevents provider details from becoming your application domain model.
Testing
The package's Testbench suite verifies container registration, webhook signatures, event dispatch, and invalid-request handling.
In an application test, fake the framework event:
For API client tests, inject or replace the Zeevx\Bachs\Bachs binding with a client configured with Guzzle's MockHandler.
Development
The package uses Pest, Orchestra Testbench, PHPStan level 8, Laravel Pint, strict types, and GitHub Actions across supported PHP and Laravel versions.
License
The MIT License. See LICENSE.
All versions of laravel-bachs with dependencies
illuminate/contracts Version ^11.0 || ^12.0 || ^13.0
illuminate/http Version ^11.0 || ^12.0 || ^13.0
illuminate/routing Version ^11.0 || ^12.0 || ^13.0
illuminate/support Version ^11.0 || ^12.0 || ^13.0
zeevx/php-bachs Version ^0.1