PHP code example of webtoucher / omnipay-anymoney

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

    

webtoucher / omnipay-anymoney example snippets


    $gateway = \Omnipay\Omnipay::create('AnyMoney');
    $gateway->setMerchantId('[MERCHANT_ID]');
    $gateway->setPrivateKey('[PRIVATE_KEY]');
    $this->gateway->setLogger(function ($message, $level = 'info') {
        // Your log handler
    });

    $request = $gateway->purchase([
        'amount' => 100.5,
        'currency' => 'UAH',
        'transactionId' => '100500',
        'isMultiPay' => false,
        'payway' => 'visamc_m',
        'email' => '[email protected]',
        'notifyUrl' => 'https://notify.url',
        'returnUrl' => 'https://return.url?order=100500',
    ]);
    $response = $request->send();
    if ($response->isRedirect()) {
        $response->redirect();
    }

    $request = $gateway->completePurchase($_POST);
    $response = $request->send();
    $orderId = $response->getTransactionId(); // You can check this order and mark it as paid or failed.
    if ($response->isSuccessful()) {
        // Your handler
    } else {
        // Your handler
    }

    $request = $gateway->status([
        'transactionId' => $order,
    ]);
    $response = $request->send();
    if ($response->isSuccessful()) {
        // Your handler
        // Maybe you need to check here the status of the order on your side
    } else {
        // Your handler
    }

$ php composer.phar