Guides
Example payment flow
Step-by-step example of a full EFL Leasing payment flow in a backend.
Overview
This guide walks through a simplified but realistic backend flow:
- Configure the SDK.
- Obtain auth token and start a process.
- Calculate an offer.
- Submit customer data.
- Initialise identity verification.
Error handling and retry logic are omitted for clarity.
1. Configure the SDK
use GuzzleHttp\Client as GuzzleClient;
use Imoli\EflLeasingSdk\Config;
use Imoli\EflLeasingSdk\EflClient;
use Imoli\EflLeasingSdk\Http\Adapter\GuzzleHttpAdapter;
$config = Config::sandbox(
apiKey: getenv('EFL_API_KEY'),
baseUrl: 'https://leasingonlineapi-sandbox.efl.com.pl'
);
$guzzle = new GuzzleClient([
'timeout' => 30,
'connect_timeout' => 10,
]);
$httpClient = new GuzzleHttpAdapter($guzzle);
$client = new EflClient($config, $httpClient);
2. Authenticate and start process
$partnerId = getenv('EFL_PARTNER_ID');
// Bearer token returned by getAuthToken(), reused in subsequent calls
$token = $client->getAuthToken($partnerId);
$process = $client->startProcess(
positiveReturnUrl: 'https://example.com/efl/success',
negativeReturnUrl: 'https://example.com/efl/failure',
token: $token
);
Persist identifiers from $process to your database; you will need them later.
3. Calculate offer
use Imoli\EflLeasingSdk\Model\Calculation\AssetToCalculation;
use Imoli\EflLeasingSdk\Model\Calculation\OfferItem;
use Imoli\EflLeasingSdk\Model\Calculation\ItemDetail;
$itemDetail = new ItemDetail(
guid: 'item-guid-1',
description: 'Example asset'
// ... additional fields as required
);
$offerItem = OfferItem::builder('offer-item-guid-1')
->withItemDetail($itemDetail)
->build();
$basket = AssetToCalculation::builder('basket-guid-1')
->addOfferItem($offerItem)
->build();
$offerResponse = $client->calculateBasicOffer($basket, $token);
Use $offerResponse to present available variants to the customer.
4. Submit customer data
use Imoli\EflLeasingSdk\Model\Customer\Address;
use Imoli\EflLeasingSdk\Model\Customer\Company;
use Imoli\EflLeasingSdk\Model\Customer\CustomerData;
use Imoli\EflLeasingSdk\Model\Customer\CustomerDataStatement;
use Imoli\EflLeasingSdk\Model\Customer\EmailAddress;
use Imoli\EflLeasingSdk\Model\Customer\Phone;
$company = Company::builder('company-guid', '1234567890')
->addEmail(new EmailAddress('email-guid', 'contact@example.com', 'work'))
->addPhone(new Phone('phone-guid', '+48', '123456789', 'mobile', 'mobile'))
->addAddress(new Address('addr-guid', 'Headquarters', 'registered_office', 'Warsaw', 'Main St', '1', '00-001', 'PL'))
->addStatement(new CustomerDataStatement('stmt-guid', true, 'gdpr'))
->build();
$customerData = CustomerData::builder('tx-1', 42)
->withCompany($company)
->build();
$client->submitCustomerData($customerData, $token);
5. Initialise identity verification
use Imoli\EflLeasingSdk\Model\Verification\VerificationInitializationParams;
$params = VerificationInitializationParams::builder('order-uuid')
// configure as required by EFL documentation
->build();
$verificationResult = $client->initializeIdentityVerification(
$processTransactionId,
$params,
$token
);
$redirectUrl = $verificationResult->getRedirectUrl();
Redirect the customer to $redirectUrl and handle status updates using the verification status endpoints or clients.
6. High-level flow diagram
flowchart LR
backend["Backend"] --> eflClient["EflClient"]
eflClient -->|"getAuthToken"| eflApiAuth["EFL_API_auth"]
eflClient -->|"startProcess"| eflApiProcess["EFL_API_process"]
eflClient -->|"calculateBasicOffer"| eflApiCalc["EFL_API_calculation"]
eflClient -->|"submitCustomerData"| eflApiCustomer["EFL_API_customer"]
eflClient -->|"initializeIdentityVerification"| eflApiVerification["EFL_API_verification"]
backend <-.-> frontend["Shop_frontend"]
frontend -->|"redirect_customer"| eflPortal["EFL_leasing_flow"]
eflPortal -->|"return_to_shop"| frontend