Openpay driver for the Omnipay PHP payment processing library
Omnipay is a framework agnostic, multi-gateway payment processing library for PHP. This package implements Openpay support for Omnipay.
Omnipay is installed via Composer. To install, simply require league/omnipay
and sudiptpa/omnipay-openpay
with Composer:
composer require league/omnipay sudiptpa/omnipay-openpay
use Omnipay\Omnipay;
$gateway = Omnipay::create('Openpay_Shared');
$gateway->setMerchantId('xxxxxxx|xxxxxxx-xxx-xxxx');
$gateway->setAuthToken('xxxxxxxx');
$gateway->setTestMode(true);
try {
$response = $gateway->order([
'purchasePrice' => '409.50',
])->send();
$planID = $response->getPlanID();
$response = $gateway->purchase([
'firstName' => 'Sujip',
'lastName' => 'Thapa',
'returnUrl' => 'https://example.com/payment/1/complete',
'cancelUrl' => 'https://example.com/payment/1/cancel',
'failedUrl' => 'https://example.com/payment/1/failed',
'retailerOrderNo' => '145000112',
'email' => 'buy@example.com',
'postCode' => '1234',
'city' => 'Test',
'address1' => 'Test City',
'state' => 'ABCD',
'phone' => '99987765555',
'purchasePrice' => '409.50',
'planID' => $planID,
])->send();
if ($response->isRedirect()) {
$response->redirect();
}
} catch (Exception $e) {
return $e->getMessage();
}
// Complete Purchase
$response = $gateway->orderStatus([
'planID' => $order->transaction_id,
])->send();
if ($response->isApproved()) {
// success
}
For general usage instructions, please see the main Omnipay repository.
Contributions are welcome and will be fully credited.
Contributions can be made via a Pull Request on Github.
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.