Benefit gateway driver for the Omnipay PHP payment processing library
Omnipay is a framework agnostic, multi-gateway payment processing library for PHP 5.3+. This package implements Benefit gateway support for Omnipay.
Omnipay is installed via Composer.
For most uses, you will need to require league/omnipay
and an individual gateway:
composer require league/omnipay:^3 akalati/omanipay-benefitgateway
If you want to use your own HTTP Client instead of Guzzle (which is the default for league/omnipay
),
you can require league/common
and any php-http/client-implementation
(see PHP Http)
composer require league/common:^3 akalati/omanipay-benefitgateway php-http/buzz-adapter
The following methods are provided by this package:
- purchase
- completePurchase
Use purchase request to construct the redirect link and redirect the customer to benefit gateway payment page
$gateway = Omnipay::create('BenefitGateway');
$gateway->setTestMode(true); //call setTestMode(true) to use benefit gateway test endpoint https://www.test.benefit-gateway.bh/payment/PaymentHTTP.htm?param=paymentInit
$gateway->setId(""); //Tranportal ID
$gateway->setPassword(""); // Tranportal Password
$gateway->setResourceKey(""); // Terminal Resourcekey
$response = $gateway->purchase([
'amount' => 20.5, //Amount in BHD
'transactionId' => 1, //Order or transaction reference from your system
'returnUrl' => "https://www.example.com/return", //return url
'cancelUrl' => "https://www.example.com/error" //error and cancel url
])->send();
$response->redirect();
use completePurchase in your return callback to handle the request sent by the gateway to your system
$gateway = Omnipay::create('BenefitGateway');
$gateway->setResourceKey(""); // Terminal Resourcekey
$response = $gateway->completePurchase()->send();
if ($response->isSuccessful()) {
$transactionId = $response->getTransactionId(); //transaction id set in the purchase request
$transactionReference = $response->getTransactionReference(); //transaction reference set by the gateway
$responseData = $response->getData(); //response received from benefit gateway
// mark order as complete
} else {
$response->getMessage();
// display error message to customer
}
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 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, or better yet, fork the library and submit a pull request.