webtoucher / omnipay-payonline
PayOnline driver for the Omnipay payment processing library
Installs: 2 656
Dependents: 0
Suggesters: 0
Security: 0
Stars: 3
Watchers: 2
Forks: 0
Open Issues: 0
Requires
- php: >=5.4.0
- omnipay/common: ~2.0
Requires (Dev)
- omnipay/tests: ~2.0
This package is auto-updated.
Last update: 2024-12-23 20:59:29 UTC
README
PayOnline payment processing driver for the Omnipay PHP payment processing library.
Installation
The preferred way to install this library is through composer.
Either run
$ php composer.phar require webtoucher/omnipay-payonline "*"
or add
"webtoucher/omnipay-payonline": "*"
to the require
section of your composer.json
file.
Configure your PayOnline MID
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
Usage
The following gateways are provided by this package:
- PayOnline
$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).
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.
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.
$cardNumber = $request->getCardNumber(); $token = $request->getToken(); // Your logic
Use rebill request for recurring payments.
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.
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.
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.
If you believe you have found a bug, please report it using the GitHub issue tracker.