PHP code example of arm092 / omnipay-ameriabank

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

    

arm092 / omnipay-ameriabank example snippets


    use Omnipay\Omnipay;


    $gateway = Omnipay::create('Ameria');
    $gateway->setClientId(env('AMERIA_CLIENT_ID')); // Merchant ID - Provided by bank
    $gateway->setUsername(env('AMERIA_USERNAME')); // Username - Provided by bank
    $gateway->setPassword(env('AMERIA_PASSWORD')); // Password - Provided by bank
    $purchase = $gateway->purchase(); // Creating purchase request
    $purchase->setReturnUrl(env('AMERIA_RETURN_URL')); // Return url, that should be point to your arca webhook route
    $purchase->setAmount(10); // Amount to charge - should be decimal - use only 10 AMD if you are in test mode
    $purchase->setTransactionId(XXXX); // Transaction ID from your system
    $purchase->setTestMode(true); // For enabling test mode
    $purchase->setOpaque(json_encode(['email' => '[email protected]'])); // Is not mandatory field and used as additional information during information exchange 



    $purchaseResponse = $purchase->send();
    if ($purchaseResponse->isSuccessfull()) {
        $purchaseResponse->setLanguage(\App::getLocale()); // Interface language ('am', 'ru', 'en')
        $purchaseResponse->setTestMode(true); // For enabling test mode
        $purchaseResponse->redirect();
    }



    $gateway = Omnipay::create('Ameria');
    $gateway->setClientId(env('AMERIA_CLIENT_ID'));
    $gateway->setUsername(env('AMERIA_USERNAME'));
    $gateway->setPassword(env('AMERIA_PASSWORD'));
    
    $purchaseCompleteRequest = $gateway->completePurchase();
    $purchaseCompleteRequest->setTransactionId(request()->get('paymentID'));
    $purchaseCompleteResponse = $purchaseCompleteRequest->send();
    
    // Do the rest with $purchase and response with 'OK'
    if ($purchaseCompleteResponse->isSuccessful()) {
        
        // Your logic
        
    }
    
    return new Response('OK');