laragear/transbank
Laravel integration for Transbank, Chile's payment gateway. Process Webpay Plus, Oneclick, and other Transbank transactions through a clean, fluent API with built-in support for payment confirmations, refunds, and Laravel-friendly configuration.
composer require laragear/transbank
php artisan vendor:publish --tag=transbank-config
php artisan vendor:publish --tag=transbank-migrations
php artisan migrate
If the tags differ in your version, use php artisan vendor:publish and select the Laragear\Transbank provider..env:
TRANBANK_ENVIRONMENT=integration
TRANBANK_COMMERCE_CODE=your-commerce-code
TRANBANK_API_KEY=your-api-key
Use the integration credentials from Transbank while developing; production credentials are separate.use Laragear\Transbank\Facades\Transbank;
$response = Transbank::webpay()->create(
buyOrder: 'order-'.Str::uuid(),
sessionId: $request->session()->getId(),
amount: 19990,
returnUrl: route('transbank.webpay.return'),
);
return redirect()->away($response->url);
On return, the package return route commits the token, or your controller calls Transbank::webpay()->commit($request->input('token_ws')). Inspect the resulting transaction with isSuccessful() and persist the link to your own order.config/transbank.php, the Transbank facade, Laragear\Transbank\Models\Transaction, package events, and the published routes/controllers.Transbank::webpay(), Transbank::webpayMall(), Transbank::oneclick(), and Transbank::patpass() where available. Keep product-specific code in small action classes rather than controllers.charge($username, $buyOrder, $amount). Treat the stored username as a payment credential reference, not as a secret.Transbank::fake() if the package version provides it; otherwise use Laravel’s Http::fake() because the package uses the Laravel HTTP client. Assert outgoing URLs and methods, and generate unique buy orders per test.config/transbank.php. Do not add Boost as a production dependency solely for this package.token_ws is present on a successful Webpay return. Cancellations/aborts may return TBK_TOKEN or related fields instead; handle that path before calling commit().TRANBANK_ENVIRONMENT or credentials, clear cached config with php artisan config:clear.buyOrder values and retried Oneclick charges can be rejected or cause double-charge risk. Enforce uniqueness in your application and make retries idempotent at the order level.How can I help you explore Laravel packages today?