PHP code example of ekoindia / eps-sdk

1. Go to this page and download the library: Download ekoindia/eps-sdk 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/ */

    

ekoindia / eps-sdk example snippets


use Eko\Eps\EpsIndeterminateException;

try {
    $client->call('bbps-pay-bill', [/* … */]);
} catch (EpsIndeterminateException $e) {
    // $e->clientRefId — persist it; $e->statusCheck['data']['tx_status']:
    // "0" success, "1" fail, "2" awaited. Inquire again later with
    // $client->call('transaction-inquiry', ['client_ref_id' => $e->clientRefId]);
}


use Eko\Eps\EpsClient;

$client = new EpsClient(
    developerKey: getenv('EPS_DEVELOPER_KEY'),
    accessKey: getenv('EPS_ACCESS_KEY'), // server-side secret
    initiatorId: '9962981729',           // your registered mobile; injected into every call
    environment: 'sandbox'               // or 'production'
);

// Call an endpoint by its slug; params fill path tokens and the request body.
// initiator_id / user_code are supplied from the client config above.
$result = $client->call('dmt-get-sender', [
    'customer_id' => '9123456789',
]);

print_r($result);

use Eko\Eps\EpsHttpException;

try {
    $result = $client->call('pan-lite', [/* … */]);
} catch (EpsHttpException $e) {
    error_log("HTTP {$e->status}");
    print_r($e->body); // decoded envelope, or null when the body was not JSON
}

$result = $client->call('activate-aeps-fingpay', [
    'user_code' => '20810200',
    'modelname' => 'Morpho 1300E3',
    'devicenumber' => 'SN1234567890',
    'account' => '38759149196',
    'ifsc' => 'SBIN0007515',
    'office_address' => ['line' => 'Shop 5', 'city' => 'Patna', 'state' => 'Bihar', 'pincode' => '800001'],
    'address_as_per_proof' => ['line' => 'Shop 5', 'city' => 'Patna', 'state' => 'Bihar', 'pincode' => '800001'],
    'pan_card' => '/path/to/pan_card.jpg',                  // path string…
    'aadhar_front' => new \CURLFile('/path/to/front.jpg'),  // …or a CURLFile
    'aadhar_back' => '/path/to/back.jpg',
]);

// 1.x — an error envelope was indistinguishable from success
$result = $client->call($slug, $params);
if (($result['status'] ?? null) !== 0) handleFailure($result);

// 2.x
use Eko\Eps\EpsHttpException;
try {
    $result = $client->call($slug, $params);
} catch (EpsHttpException $e) {
    handleFailure($e->body, $e->status);
}