iLeben integrates with Transbank Webpay Plus (single commerce code) and Webpay Mall (multiple commerce codes per project) using the officialDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/scooller/Leben-site/llms.txt
Use this file to discover all available pages before exploring further.
transbank/transbank-sdk v5.x PHP package. Transbank is the primary payment method for Chilean buyers and processes both debit and credit cards through a hosted payment page. The integration follows a redirect-and-confirm pattern: the SDK generates a one-time token and URL, the user completes payment on Transbank’s page, and the platform confirms the transaction on return.
Configuration
Set the following variables in your.env file before enabling the gateway:
Transbank Mall Mode
When a single Salesforce project needs its own commerce code, enable Mall mode and supply a JSON map of project keys to store codes:In
integration mode, the SDK automatically applies Transbank’s official test credentials. The values of TRANSBANK_COMMERCE_CODE and TRANSBANK_API_KEY in .env are ignored and only take effect when TRANSBANK_ENVIRONMENT=production.Payment Flow
Initiate checkout
The frontend calls
POST /api/v1/checkout with gateway: "transbank" in the request body. The API creates a Payment record with status pending and calls TransbankService::createTransaction().Receive redirect token
The API responds with a
redirect_url and a token_ws. Both are needed to send the user to Transbank’s hosted payment page.Redirect the user
The frontend redirects the user to
redirect_url?token_ws={token}. Transbank presents the card-entry form.User completes payment
Transbank processes the card and sends the user back to the configured return URL via an HTTP POST.
Return POST received
PaymentWebhookController@transbankReturn handles the GET|POST /payments/transbank/return route. The controller extracts token_ws (or TBK_TOKEN on cancellation) from the incoming request.Confirm with SDK
The service calls
confirmTransaction($token) against the Transbank API. The SDK returns response_code, amount, authorization_code, and card_detail.Update payment status
The
Payment record is updated based on response_code: 0 maps to completed; any other code maps to failed.PHP Example
The following snippet shows the full Transbank flow as used internally. ImportPaymentGatewayFacade to keep the driver abstraction:
SDK Methods
| Method | Signature | Description |
|---|---|---|
createTransaction | createTransaction(array $data): array | Initiates a new Webpay transaction; returns token and url |
confirmTransaction | confirmTransaction(string $token): array | Confirms the transaction after the user returns; returns authorization details |
getTransactionStatus | getTransactionStatus(string $token): array | Queries the current state of a transaction by its token |
refundTransaction | refundTransaction(string $token, ?float $amount = null): array | Issues a full or partial refund for a completed transaction |
Test Cards
Use these cards inintegration mode. Any future expiry date and CVV 123 are accepted.
| Type | Card Number | Expected Result |
|---|---|---|
| Debit (success) | 4051 8856 0000 0002 | Approved |
| Credit (success) | 4051 8860 0000 0001 | Approved |
| Rejected | 4051 8842 3993 7763 | Declined |
Web Routes
| Method | Route | Handler | Description |
|---|---|---|---|
GET | /payments/transbank/redirect | PaymentWebhookController | Bridge endpoint for POST redirect to Webpay |
GET|POST | /payments/transbank/return | PaymentWebhookController@transbankReturn | Receives the user return and token from Transbank |
Error Reference
| Error Message | Cause | Resolution |
|---|---|---|
Invalid commerce code | TRANSBANK_ENVIRONMENT=production but integration credentials are in .env, or vice versa | Ensure TRANSBANK_ENVIRONMENT matches the actual credential set. In integration mode the SDK ignores .env credentials entirely. |
Transaction not found | The token_ws has expired — Transbank tokens are only valid for 15 minutes | Create a new transaction by restarting the checkout flow. |
Log Sanitization
All Transbank service calls are logged tostorage/logs/laravel.log. Tokens (token_ws, TBK_TOKEN) and raw SDK payloads are sanitized before writing to prevent PII or secret leakage in log storage.