PHP code example of novalnet / omnipay

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

    

novalnet / omnipay example snippets



use Novalnet\Omnipay\Gateway;

             'first_name' => 'novalnet',
                'last_name' => 'tester',
                'email' => '[email protected]',
                'customer_no' => '147',
                'billing' => [
                    'street' => 'Feringastraße',
                    'house_no' => '4',
                    'city' => 'Unterföhring',
                    'zip' => '85774',
                    'country_code' => 'DE',
                ]
            ];
        $data['transaction'] = [
                'test_mode' => 1,
                'payment_type' => 'DIRECT_DEBIT_SEPA',
                'amount' => '1500',
                'currency' => 'EUR',
                'order_no' => '123456',
                'payment_data' => [
                    'account_holder' => '###ACCOUNT_HOLDER###',
                    'iban' => '###IBAN###',
                ]
            ];
        $data['custom'] = [
                'lang' => 'EN'
            ];            

    $gateway = new Gateway();
    $gateway->setPaymentAccessKey('###YOUR_PAYMENT_ACCESS_KEY###'); // Merchant need to provide the payment access key
    $gateway->setSignature('###YOUR_API_SIGNATURE###'); // Merchant need to provide the Product activation key
    $gateway->setTariff('###YOUR_TARIFF_ID###'); // Merchant need to provide the tariff id

    $response = $gateway->authorize($data)->send();
        
    if ($response->isSuccessful()) {
        print_r($response->getData());
    } elseif ($response->isRedirect()) {
        $response->redirect();
    } else {
        echo $response->getMessage();
    }
} catch (\Exception $e) {
    throw $e;
}


use Novalnet\Omnipay\Gateway;

             'first_name' => 'novalnet',
                'last_name' => 'tester',
                'email' => '[email protected]',
                'customer_no' => '147',
                'billing' => [
                    'street' => 'Feringastraße',
                    'house_no' => '4',
                    'city' => 'Unterföhring',
                    'zip' => '85774',
                    'country_code' => 'DE',
                ]
            ];
        $data['transaction'] = [
                'test_mode' => 1,
                'payment_type' => 'CREDITCARD',
                'amount' => '1500',
                'currency' => 'EUR',
                'order_no' => '123456',
		'return_url' => 'https://omnipay.novalnet.de/samples/payment/purchase.php',  // Adapt your own return url (only for 3D secure)
                'payment_data' => [
                    'pan_hash'  => '###PAN_HASH###', // To store Novalnet's unique identifier for the given payment data
		    'unique_id' => '###UNIQUE_ID###' // To store the random id which belongs to a particular pan_hash
                ]
            ];
        $data['custom'] = [
                'lang' => 'EN'
            ];            

    $gateway = new Gateway();
    $gateway->setPaymentAccessKey('###YOUR_PAYMENT_ACCESS_KEY###'); // Merchant need to provide the payment access key
    $gateway->setSignature('###YOUR_API_SIGNATURE###'); // Merchant need to provide the Product activation key
    $gateway->setTariff('###YOUR_TARIFF_ID###'); // Merchant need to provide the tariff id

    $response = empty($_REQUEST['tid'])
        ? $gateway->authorize($data)->send()
        : $gateway->completeAuthorize($_REQUEST)->send();
		
    if ($response->isSuccessful()) {
        print_r($response->getData());
    } elseif ($response->isRedirect()) {
        $response->redirect();
    } else {
        echo $response->getMessage();
    }
} catch (\Exception $e) {
    throw $e;
}


use Novalnet\Omnipay\Gateway;

             'first_name' => 'novalnet',
                'last_name' => 'tester',
                'email' => '[email protected]',
                'customer_no' => '147',
                'billing' => [
                    'street' => 'Feringastraße',
                    'house_no' => '4',
                    'city' => 'Unterföhring',
                    'zip' => '85774',
                    'country_code' => 'DE',
                ]
            ];
        $data['transaction'] = [
                'test_mode' => 1,
                'payment_type' => 'ONLINE_BANK_TRANSFER',
                'amount' => '1500',
                'currency' => 'EUR',
                'order_no' => '123456',
                'return_url' => 'https://omnipay.novalnet.de/samples/payment/purchase.php',  // Adapt your own return url
            ];
        $data['custom'] = [
                'lang' => 'EN'
            ];            

    $gateway = new Gateway();
    $gateway->setPaymentAccessKey('###YOUR_PAYMENT_ACCESS_KEY###'); // Merchant need to provide the payment access key
    $gateway->setSignature('###YOUR_API_SIGNATURE###'); // Merchant need to provide the Product activation key
    $gateway->setTariff('###YOUR_TARIFF_ID###'); // Merchant need to provide the tariff id

    $response = empty($_REQUEST['tid'])
        ? $gateway->purchase($data)->send()
        : $gateway->completePurchase($_REQUEST)->send();

    if ($response->isSuccessful()) {
        print_r($response->getData());
    } elseif ($response->isRedirect()) {
        $response->redirect();
    } else {
        echo $response->getMessage();
    }
} catch (\Exception $e) {
    throw $e;
}




use Novalnet\Omnipay\Gateway;

           'tid' => '14597800007520313',
            'amount' => '100',
            'reason' => ''
        ];

    $data['custom'] = [
            'lang' => 'EN'
        ];

    $gateway = new Gateway();
    $gateway->setPaymentAccessKey('###YOUR_PAYMENT_ACCESS_KEY###'); // Merchant need to provide the payment access key

    $response = $gateway->refund($data)->send();

    if ($response->isSuccessful()) {
        print_r($response->getData());
    } else {
        echo $response->getMessage();
    }

} catch (\Exception $e) {
    throw $e;
}




use Novalnet\Omnipay\Gateway;

    $gateway->setPaymentAccessKey('###YOUR_PAYMENT_ACCESS_KEY###'); // Merchant need to provide the payment access key
    $gateway->setTestMode(false);
    $gateway->handleWebhookNotification();
} catch (\Exception $e) {
    throw $e;
}