PHP code example of keops007 / omnipay-payu-romania

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

    

keops007 / omnipay-payu-romania example snippets


    use Omnipay\Omnipay;

    $gateway = Omnipay::create('PayU');
    $gateway->setMerchantName(env('MERCHANT_NAME'));
    $gateway->setSecretKey(env('SECRET_KEY'));

    $purchase = $gateway->purchase([
            'amount' => 100,
            'transactionId' => 1,
            'orderDate' => date('Y-m-d H:i:s'),
            'items' => [
                new \Omnipay\PayU\Item([
                    'name' => 'Item',
                    'code' => 'ItemCode',
                    'price' => '100',
                    'priceType' => 'NET',
                    'quantity' => 1,
                    'vat' => 0,
                ]),
            ]
        ])->send();
    
    $purchase->redirect();

    $gateway = Omnipay::create('PayU');
    $gateway->setMerchantName(env('MERCHANT_NAME'));
    $gateway->setSecretKey(env('SECRET_KEY'));
    
    $purchase = $gateway->completePurchase()->send();
    
    if ($purchase->isSuccessful()) {
        // Your logic
        
        return $purchase->completeResponse();
    }