Omnipay: PayOnline
PayOnline payment processing driver for the Omnipay PHP payment processing library., (*1)
, (*2)
Installation
The preferred way to install this library is through composer., (*3)
Either run, (*4)
$ php composer.phar require webtoucher/omnipay-payonline "*"
or add, (*5)
"webtoucher/omnipay-payonline": "*"
to the require
section of your composer.json
file., (*6)
Ask PayOnline support for switching off ok/fail page if you need it. So you will be redirected to your return/fail URL immediately.
Then check your MID settings:
- CallbackUrl method: POST
- Callback Url for approved transactions: https://your.domain.com/your-callback/?result=1
- Callback Url for declined transactions: https://your.domain.com/your-callback/?result=0
- Enable Callback on approved transactions: ON
- Enable Callback on declined transactions: ON, (*7)
Usage
The following gateways are provided by this package:, (*8)
$gateway = \Omnipay\Omnipay::create('PayOnline');
$gateway->setMerchantId('[MERCHANT_ID]');
$gateway->setApiKey('[API_PRIVATE_KEY]');
$gateway->setLanguage('ru'); // default - en
Then you should create payment url (for redirecting or using iframe)., (*9)
try {
$request = $this->gateway->purchase([
'order_id' => 123,
'amount' => 10,
'currency' => 'EUR',
'description' => 'Test payment',
'user' => 1234,
'email' => 'test@test.com',
'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
}
Create controller's action for catching PayOnline callbacks. Remember that you must use the same action for successful/unsuccessful callbacks (POST-requests) and as return/fail URL (GET-requests). Check type of request to know what should you do., (*10)
if (/* is post request */) {
try {
$request = $this->gateway->completePurchase([
'result' => $result,
'datetime' => $DateTime,
'transaction_id' => $TransactionID,
'order_id' => $OrderId,
'amount' => $Amount,
'currency' => $Currency,
'token' => $RebillAnchor,
'card_number' => $CardNumber,
'user' => $User,
'error_code' => isset($Code) ? $Code : $ErrorCode,
]);
$response = $request->send();
$success = $response->isSuccessful();
} catch (\Omnipay\Common\Exception\OmnipayException $e) {
$success = false;
// Your handler
}
// Your logic
} else {
// Your logic for return/fail URL
}
Remember that PayOnline send rebill tokens for ssl-connection only. You can extract masked card number and token and save these into your system., (*11)
$cardNumber = $request->getCardNumber();
$token = $request->getToken();
// Your logic
Use rebill request for recurring payments., (*12)
try {
$request = $this->gateway->rebill([
'token' => $token,
'order_id' => 124,
'amount' => 10,
'currency' => 'EUR',
]);
$response = $request->send();
$success = $response->isSuccessful();
} catch (\Omnipay\Common\Exception\OmnipayException $e) {
$success = false;
// Your handler
}
For general usage instructions, please see the main Omnipay
repository., (*13)
Support
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., (*14)
If you want to keep up to date with release anouncements, discuss ideas for the project,
or ask more detailed questions, there is also a mailing list which
you can subscribe to., (*15)
If you believe you have found a bug, please report it using the GitHub issue tracker., (*16)