项目作者: sudiptpa

项目描述 :
eSewa API driver with Omnipay PHP payment processing library - eSewa-Nepal First Online Payment Gateway
高级语言: PHP
项目地址: git://github.com/sudiptpa/esewa.git
创建时间: 2016-12-05T03:55:54Z
项目社区:https://github.com/sudiptpa/esewa

开源协议:MIT License

下载


Omnipay: eSewa

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.

StyleCI
Latest Stable Version
Total Downloads
GitHub license

Installation

Omnipay is installed via Composer. To install, simply require league/omnipay and sudiptpa/omnipay-esewa with Composer:

  1. composer require league/omnipay sudiptpa/omnipay-esewa

Looking for ePay v1? Check this documentation for installation instructions.

Basic Usage

Purchase

  1. use Omnipay\Omnipay;
  2. use Exception;
  3. $gateway = Omnipay::create('Esewa_Secure');
  4. $gateway->setMerchantCode('epay_payment');
  5. $gateway->setSecretKey('secret_key_provided_by_esewa');
  6. $gateway->setTestMode(true);
  7. try {
  8. $response = $gateway->purchase([
  9. 'amount' => 100,
  10. 'deliveryCharge' => 0,
  11. 'serviceCharge' => 0,
  12. 'taxAmount' => 0,
  13. 'totalAmount' => 100,
  14. 'productCode' => 'ABAC2098',
  15. 'returnUrl' => 'https://merchant.com/payment/1/complete',
  16. 'failedUrl' => 'https://merchant.com/payment/1/failed',
  17. ])->send();
  18. if ($response->isRedirect()) {
  19. $response->redirect();
  20. }
  21. } catch (Exception $e) {
  22. return $e->getMessage();
  23. }

After successful payment and redirect back to merchant site, you need to verify the payment response.

Verify Payment

  1. $gateway = Omnipay::create('Esewa_Secure');
  2. $gateway->setMerchantCode('epay_payment');
  3. $gateway->setSecretKey('secret_key_provided_by_esewa');
  4. $gateway->setTestMode(true);
  5. $payload = json_decode(base64_decode($_GET['data']), true);
  6. $signature = $gateway->generateSignature(generateSignature($payload));
  7. if ($signature === $payload['signature']) {
  8. // Verified
  9. } else {
  10. // Unverified
  11. }

You can also check the status of payment if no any response is received when redirected back to merchant’s site.

Check Status

  1. $gateway = Omnipay::create('Esewa_Secure');
  2. $gateway->setMerchantCode('epay_payment');
  3. $gateway->setSecretKey('secret_key_provided_by_esewa');
  4. $gateway->setTestMode(true);
  5. $payload = [
  6. 'totalAmount' => 100,
  7. 'productCode' => 'ABAC2098',
  8. ];
  9. $response = $gateway->checkStatus($payload)->send();
  10. if ($response->isSuccessful()) {
  11. // Success
  12. }

Working Example

Want to see working examples before integrating them into your project? View the examples here

Laravel Integration

Please follow the eSewa Online Payment Gateway Integration and follow step by step guidlines.

Official Doc

Please follow the Official Doc to understand about the parameters and their descriptions.

Contributing

Contributions are welcome and will be fully credited.

Contributions can be made via a Pull Request on Github.

Support

If you are having general issues with Omnipay Esewa, drop an email to sudiptpa@gmail.com 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.

License

This package is open-sourced software licensed under the MIT license.