LiqPay driver for the Omnipay Laravel payment processing library
Omnipay is a framework agnostic, multi-gateway payment processing library for PHP 5.5+. This package implements LiqPay support for Omnipay.
Omnipay is installed via Composer. To install, simply add it
to your composer.json
file:
{
"require": {
"ucraft-com/omnipay-liqpay": "v1.0.0"
}
}
And run composer to update your dependencies:
composer update
Or you can simply run
composer require ucraft-com/omnipay-liqpay
- Use Omnipay gateway class:
use Omnipay\Omnipay;
- Initialize LiqPay gateway:
$gateway = Omnipay::create('LiqPay');
$gateway->setPublicKey(env('LIQPAY_PUBLIC_KEY'));
$gateway->setPrivateKey(env('LIQPAY_PRIVATE_KEY'));
- Call purchase, pass all necessary data and call sendData. It will return Response object which will contain all necessary data for form submission.
$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());
- Create a webhook controller to handle the callback request at your
LIQPAY_RETURN_URL
and catch the webhook as follows
$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');
For general usage instructions, please see the main Omnipay repository.
If you are having general issues with Omnipay, we suggest posting on Stack Overflow. Be sure to add the omnipay tag, so it can be easily found.
If you want to keep up to date with release announcements, discuss ideas for the project, or ask more detailed questions, there is also a mailing list which you can subscribe to.
If you believe you have found a bug, please report it using the GitHub issue tracker, or better yet, fork the library and submit a pull request.