PHP code example of hovakimyannn / omnipay-epg

1. Go to this page and download the library: Download hovakimyannn/omnipay-epg 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/ */

    

hovakimyannn / omnipay-epg example snippets


use Omnipay\Omnipay;

$gateway = Omnipay::create('Epg\Arca');
$gateway->setUsername('your_username');
$gateway->setPassword('your_password');
// $gateway->setTestMode(true); // use ipaytest.arca.am

use Omnipay\Epg\Gateway;

$gateway = new Gateway();
$gateway->setEndpoint('https://epg.yourbank.am/payment/rest');
$gateway->setTestEndpoint('https://epg-test.yourbank.am/payment/rest');
$gateway->setUsername('your_username');
$gateway->setPassword('your_password');

$response = $gateway->purchase([
    'transactionId' => 'ORDER-001',       // your order number
    'amount'        => '10.00',
    'currency'      => 'AMD',
    'returnUrl'     => 'https://yoursite.com/payment/success',
    'failUrl'       => 'https://yoursite.com/payment/fail',  // optional
    'description'   => 'Order #001',                         // optional
    'language'      => 'en',                                 // optional
    'features'      => 'FORCE_TDS',                          // optional: FORCE_SSL | FORCE_TDS
])->send();

if ($response->isRedirect()) {
    // Store $response->getTransactionReference() (EPG orderId) for later status check
    $orderId = $response->getTransactionReference();

    $response->redirect(); // redirects customer to bank payment page
}

$response = $gateway->completePurchase([
    'transactionId' => $orderId, // the EPG orderId saved during purchase
])->send();

if ($response->isSuccessful()) {
    // Payment confirmed — fulfill the order
} else {
    echo $response->getMessage();
}

$response = $gateway->registerPreAuth([
    'transactionId' => 'ORDER-002',
    'amount'        => '50.00',
    'currency'      => 'AMD',
    'returnUrl'     => 'https://yoursite.com/payment/success',
])->send();

$orderId = $response->getTransactionReference();

$response = $gateway->deposit([
    'transactionId' => $orderId,
    'amount'        => '50.00',
])->send();

$response = $gateway->reverse([
    'transactionId' => $orderId,
])->send();

$response = $gateway->refund([
    'transactionId' => $orderId,
    'amount'        => '10.00',
])->send();

// Basic status
$response = $gateway->getOrderStatus([
    'transactionId' => $orderId,
])->send();

// Extended status (tus();        // 0–6 (EPG status code)
echo $response->getTransactionReference();
print_r($response->getCardAuthInfo());

$response = $gateway->verifyEnrollment([
    'pan' => '4111111111111111',
])->send();

$response = $gateway->bindingPayment([
    'transactionReference' => $orderId,  // mdOrder
    'bindingId'            => $bindingId,
    'language'             => 'en',
])->send();

$response = $gateway->getBindings([
    'clientId' => 'customer-123',
])->send();