EFL

Quickstart

End-to-end minimal integration example for the EFL Leasing PHP SDK.

Goal

This quickstart shows a minimal, realistic backend flow for offering EFL Leasing as a payment method:

  1. Configure the SDK and HTTP client.
  2. Obtain an authentication token.
  3. Start a leasing process.
  4. Calculate a basic offer for a basket of assets.

It intentionally focuses on the happy path. Error handling and edge cases are covered in dedicated sections.

1. Prepare configuration and HTTP client

use GuzzleHttp\Client as GuzzleClient;
use Imoli\EflLeasingSdk\Config;
use Imoli\EflLeasingSdk\EflClient;
use Imoli\EflLeasingSdk\Http\Adapter\GuzzleHttpAdapter;

// 1. Configuration (sandbox)
$config = Config::sandbox(
    apiKey: 'your-sandbox-api-key',
    baseUrl: 'https://leasingonlineapi-sandbox.efl.com.pl'
);

// 2. HTTP client (Guzzle)
$guzzle = new GuzzleClient([
    'timeout' => 30,
    'connect_timeout' => 10,
]);

$httpClient = new GuzzleHttpAdapter($guzzle);

// 3. Main SDK client
$client = new EflClient($config, $httpClient);

2. Authenticate and start a process

// Typically configured in your application
$partnerId = 'your-partner-id';
$successUrl = 'https://example.com/efl/success';
$failureUrl = 'https://example.com/efl/failure';

// 1) Obtain authentication token
// Bearer token returned by getAuthToken(), reused in subsequent calls
$token = $client->getAuthToken($partnerId);

// 2) Start the leasing process
$process = $client->startProcess(
    positiveReturnUrl: $successUrl,
    negativeReturnUrl: $failureUrl,
    token: $token
);

// The returned process object contains IDs and URLs needed for the next steps.

3. Build a basket and calculate a basic offer

use Imoli\EflLeasingSdk\Model\Calculation\AssetToCalculation;
use Imoli\EflLeasingSdk\Model\Calculation\OfferItem;
use Imoli\EflLeasingSdk\Model\Calculation\ItemDetail;

// Example basket: a single asset with basic details
$itemDetail = new ItemDetail(
    guid: 'item-guid-1',
    description: 'Example asset',
    // ... additional required fields as defined by the model
);

$offerItem = OfferItem::builder('offer-item-guid-1')
    ->withItemDetail($itemDetail)
    // configure other financial parameters as needed
    ->build();

$basket = AssetToCalculation::builder('basket-guid-1')
    ->addOfferItem($offerItem)
    ->build();

// Calculate a basic offer for the basket
$offerResponse = $client->calculateBasicOffer($basket, $token);

// $offerResponse is an EsbCalculateBasicOfferRestReturn value object with offer variants.

4. What is next?

In a typical backend:

  1. You show available variants from $offerResponse to the user.
  2. After the user selects an offer, you collect customer data and statements.
  3. You submit customer data and proceed to identity verification / pay‑by‑link.

The following sections provide more detail:

  • API → EflClient – see the EflClient overview for a complete list of available methods on the main client.
  • API → Models – see the models overview for details on calculation, customer and other models.
  • Guides – see the Guides section for full end‑to‑end flows, including identity verification, leads and process restoration.