PHP code example of integrify / epoint

1. Go to this page and download the library: Download integrify/epoint library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

integrify / epoint example snippets


use Integrify\EPoint\EPointClient;
use Integrify\EPoint\EPointConfig;

// Environment-dən
$client = new EPointClient(EPointConfig::fromEnvironment());

// Və ya açıq şəkildə — konfiqurasiya dəyişməz value object-dir, qlobal state yoxdur
$client = new EPointClient(new EPointConfig(
    publicKey: 'i000000001',
    privateKey: 'secret',
    successRedirectUrl: 'https://shop.az/ok',
    errorRedirectUrl: 'https://shop.az/fail',
));

$result = $client->pay(amount: 100, currency: 'AZN', orderId: 'order-1');

if (!$result->isSuccessful()) {
    // $result->status, $result->message
    return;
}

// Müştərini bura yönləndirin
return redirect($result->redirectUrl);

use Integrify\EPoint\Callback;
use Integrify\EPoint\Exception\SignatureMismatch;

$callback = new Callback(EPointConfig::fromEnvironment());

try {
    $data = $callback->decode($rawRequestBody);
} catch (SignatureMismatch) {
    // Bu sorğu EPoint-dən gəlmir
    return response('', 403);
}

if ($data->isSuccessful()) {
    // $data->orderId sizin göndərdiyiniz IDdir — sifarişi bununla tapın
}

// 1. Kartı qeyd edin (ödəniş olmadan)
$registration = $client->saveCard();
// müştərini $registration->redirectUrl-ə yönləndirin; təsdiq callback ilə gəlir

// 2. Callback gəldikdən sonra kartla ödəniş edin — müştəri iştirakı olmadan
$result = $client->payWithSavedCard(
    amount: 100,
    currency: 'AZN',
    orderId: 'order-2',
    cardId: $cardId,
);

$result->isSuccessful();
$result->rrn;            // yalnız uğurlu əməliyyatda
$result->cardMask;       // 123456******1234
$result->codeMessage();  // bankın kodunun izahı

$result = $client->splitPay(
    amount: 100,
    currency: 'AZN',
    orderId: 'order-3',
    splitUserId: 'epoint_user_id',  // ikinci EPoint istifadəçisi
    splitAmount: 50,
);

$client->refund('texxxxxx', 'AZN');       // tam
$client->refund('texxxxxx', 'AZN', 50);   // yarımçıq

$status = $client->getTransactionStatus('texxxxxx');

$status->isSuccessful();  // sorğu alındımı (yalnız `server_error` = false)
$status->isPaid();        // tranzaksiya uğurlu oldumu
$status->isReturned();    // geri qaytarılıbmı

$client->pay(100, ...);        // "100"
$client->pay('10.50', ...);    // "10.50"  — sonda sıfır qorunur
$client->pay(10.55, ...);      // "10.55"

$result->status;          // xam sətir — EPoint yeni dəyər əlavə etsə də sınmır
$result->status();        // TransactionStatus|null
$result->code;            // bankın xam kodu, məs. '000'
$result->codeMessage();   // 'Təsdiq edildi', tanınmayan kod üçün null

use Integrify\Http\RecordingTransport;
use Integrify\Response;

$transport = new RecordingTransport();
$client = new EPointClient($config, $transport);

$transport->queue(Response::json(['status' => 'success', 'redirect_url' => 'https://epoint.az/']));

$client->pay(100, 'AZN', 'order-1');

// Zərfi açıb payload-a baxın
$body = $transport->lastRequest()->body;
$payload = json_decode(base64_decode($body['data']), true);