PHP code example of taron96 / omnipay-liqpay
1. Go to this page and download the library: Download taron96/omnipay-liqpay 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/ */
taron96 / omnipay-liqpay example snippets
use Omnipay\Omnipay;
$gateway = Omnipay::create('LiqPay');
$gateway->setPublicKey(env('LIQPAY_PUBLIC_KEY'));
$gateway->setPrivateKey(env('LIQPAY_PRIVATE_KEY'));
$request = $gateway->purchase();
$request->setAmount(10);
$request->setCurrency('USD');
$request->setDescription('Product payment.');
$request->setOrderId(XXXX);
$request->setResultUrl(env('LIQPAY_RETURN_URL'));
$response = $request->sendData($request->getData());
$gateway = Omnipay::create('LiqPay');
$gateway->setPublicKey(env('LIQPAY_PUBLIC_KEY'));
$gateway->setPrivateKey(env('LIQPAY_PRIVATE_KEY'));
$request = $this->gateway->fetchTransaction();
$request->setOrderId(XXXX);
$purchase = $request->send();
// Do the rest with $purchase and response with 'OK'
if ($purchase->isSuccessful()) {
// Your logic
}
return new Response('OK');