eSewa driver for the Omnipay PHP payment processing library
Omnipay is a framework agnostic, multi-gateway payment processing library for PHP. This package implements eSewa support for Omnipay.
Omnipay is installed via Composer. To install, simply require league/omnipay
and sudiptpa/omnipay-esewa
with Composer:
composer require league/omnipay sudiptpa/omnipay-esewa
use Omnipay\Omnipay;
use Exception;
$gateway = Omnipay::create('Esewa_Secure');
$gateway->setMerchantCode('epay_payment');
$gateway->setTestMode(true);
try {
$response = $gateway->purchase([
'amount' => 100,
'deliveryCharge' => 0,
'serviceCharge' => 0,
'taxAmount' => 0,
'totalAmount' => 100,
'productCode' => 'ABAC2098',
'returnUrl' => 'https://merchant.com/payment/1/complete',
'failedUrl' => 'https://merchant.com/payment/1/failed',
])->send();
if ($response->isRedirect()) {
$response->redirect();
}
} catch (Exception $e) {
return $e->getMessage();
}
After successful payment and redirect back to merchant site, you need to now verify the payment with another API request.
$gateway = Omnipay::create('Esewa_Secure');
$gateway->setMerchantCode('epay_payment');
$gateway->setTestMode(true);
$response = $gateway->verifyPayment([
'amount' => 100,
'referenceNumber' => 'GDFG89',
'productCode' => 'gadfg-gadf',
])->send();
if ($response->isSuccessful()) {
// Success
}
// Failed
Please follow the eSewa Online Payment Gateway Integration and follow step by step guidlines.
Please follow the Official Doc to understand about the parameters and their descriptions.
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 Esewa, drop an email to [email protected] for quick support.
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.
This package is open-sourced software licensed under the MIT license.