Skip to main content

Documentation 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.

iLeben includes a complete multi-gateway payment system built on Laravel 12 and Filament 5. Three gateways are supported out of the box — Transbank Webpay (Chile card payments), Mercado Pago (LATAM), and Manual (bank transfer/offline) — all exposed through a single PaymentGateway facade that hides driver-specific details from calling code.

Supported Gateways

GatewayProviderSupported RegionFlow Type
transbankTransbank Webpay Plus / MallChile (CLP)Synchronous redirect — POST return
mercadopagoMercado PagoLATAM (multi-currency)Async webhook + redirect
manualBank transfer / offlineAnyAdmin-approval workflow

Architecture

The payment system is organized around three core components:
  • PaymentGatewayInterface — The shared contract every gateway driver must implement (createTransaction, confirmTransaction, getTransactionStatus, refundTransaction, processWebhook, isEnabled, getName, validateConfiguration).
  • PaymentGatewayManager — A factory service registered as payment.gateway in the container. It resolves and caches driver instances, reads gateway configuration from config/payments.php, and exposes driver(), forPayment(), available(), and isAvailable() helpers.
  • PaymentGateway Facade — The primary entry point for application code. All gateway operations can be performed through this facade without injecting services directly.

Directory structure

app/
├── Contracts/PaymentGatewayInterface.php  # Interface común
├── Enums/
│   ├── PaymentGateway.php                 # Enum: transbank|mercadopago|manual
│   └── PaymentStatus.php                  # Enum: pending|completed|failed|etc
├── Facades/PaymentGateway.php             # Facade principal
├── Services/Payment/
│   ├── PaymentGatewayManager.php          # Factory
│   ├── TransbankService.php               # SDK Transbank
│   ├── MercadoPagoService.php             # SDK Mercado Pago
│   └── ManualPaymentService.php           # Pagos manuales
├── Http/Controllers/
│   └── PaymentWebhookController.php       # Retornos y webhooks
└── Models/Payment.php                      # Modelo con enums

Enums

PaymentGateway

Identifies which payment driver to use. Values match the string keys used in config/payments.php and in API requests.
CaseValue
TRANSBANKtransbank
MERCADOPAGOmercadopago
MANUALmanual

PaymentStatus

Tracks the lifecycle of every payment record.
CaseValueDescription
PENDINGpendingCreated, awaiting gateway action
PROCESSINGprocessingGateway is actively processing
AUTHORIZEDauthorizedAuthorized but not yet settled
COMPLETEDcompletedPayment successful and settled
FAILEDfailedGateway reported a failure
CANCELLEDcancelledCancelled by user or gateway
REFUNDEDrefundedFully refunded
PARTIALLY_REFUNDEDpartially_refundedPartially refunded
EXPIREDexpiredSession or token expired
PENDING_APPROVALpending_approvalManual gateway — awaiting admin review

Facade Usage

All gateway operations go through the PaymentGateway facade. Import it with use App\Facades\PaymentGateway;.
use App\Facades\PaymentGateway;

// Select a specific driver and initiate a transaction
$transaction = PaymentGateway::driver('transbank')->createTransaction([
    'amount'     => 50000,
    'buy_order'  => 'ORDER-' . time(),
    'session_id' => 'session-' . $payment->id,
]);

// List all enabled gateways
$available = PaymentGateway::available();
// Returns: ['transbank', 'mercadopago', 'manual']

// Resolve the driver from an existing Payment model
PaymentGateway::forPayment($payment)->confirmTransaction($token);

// Check whether a gateway is enabled
if (PaymentGateway::isAvailable('transbank')) {
    // gateway is configured and enabled
}

Payment Model Scopes

The Payment Eloquent model ships with query scopes for common filtering needs:
use App\Models\Payment;
use App\Enums\PaymentGateway;

Payment::completed()->get();           // status: completed or authorized
Payment::pending()->get();             // status: pending, processing, or pending_approval
Payment::failed()->get();              // status: failed, cancelled, or expired
Payment::byGateway(PaymentGateway::TRANSBANK)->get();
Instance helpers are also available:
$payment->isCompleted();   // bool
$payment->isPending();     // bool
$payment->isFailed();      // bool
$payment->canBeRefunded(); // bool
$payment->canBeApproved(); // bool — true only for manual gateway

Plant Availability

The public plant catalogue derives availability from two sources: plant_reservations and payments. A plant is considered unavailable when any of the following is true:
  • An active or completed plant_reservation exists for the plant.
  • A payment linked via plant_id has status completed or authorized.
Payments in pending, processing, or pending_approval status — without an already-completed reservation — do not block a plant from appearing as available.
When a payment transitions to completed or authorized, the linked plant is automatically treated as sold in all public API responses. No separate action is required.

Gateway Pages

Transbank

Webpay Plus and Mall mode for Chilean card payments. Includes test cards, environment setup, and return flow.

Mercado Pago

Preference-based redirect flow for LATAM markets with async webhook verification.

Manual Payments

Bank transfer and offline payments with admin-approval workflow and proof upload.

Build docs developers (and LLMs) love