PHP code example of webtoucher / omnipay-payonline
1. Go to this page and download the library: Download webtoucher/omnipay-payonline 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-payonline example snippets
$gateway = \Omnipay\Omnipay::create('PayOnline');
$gateway->setMerchantId('[MERCHANT_ID]');
$gateway->setApiKey('[API_PRIVATE_KEY]');
$gateway->setLanguage('ru'); // default - en
try {
$request = $this->gateway->purchase([
'order_id' => 123,
'amount' => 10,
'currency' => 'EUR',
'description' => 'Test payment',
'user' => 1234,
'email' => '[email protected]',
'return_url' => 'https://your.domain.com/your-callback/?result=1',
'cancel_url' => 'https://your.domain.com/your-callback/?result=0',,
]);
$response = $request->send();
if ($response->isSuccessful()) {
$url = $response->getUrl();
// Use this url as iframe source or for redirect
}
} catch (\Omnipay\Common\Exception\OmnipayException $e) {
// Your handler
}