|
| 1 | +# Omnipay: eSewa |
| 2 | + |
| 3 | +**eSewa driver for the Omnipay PHP payment processing library** |
| 4 | + |
| 5 | +[Omnipay](https://github.com/thephpleague/omnipay) is a framework agnostic, multi-gateway payment |
| 6 | +processing library for PHP. This package implements eSewa support for Omnipay. |
| 7 | + |
| 8 | +[](https://github.styleci.io/repos/75586885) |
| 9 | +[](https://packagist.org/packages/sudiptpa/omnipay-esewa) |
| 10 | +[](https://packagist.org/packages/sudiptpa/omnipay-esewa) |
| 11 | +[](https://raw.githubusercontent.com/sudiptpa/esewa/master/LICENSE) |
| 12 | + |
| 13 | +## Installation |
| 14 | + |
| 15 | +Omnipay is installed via [Composer](http://getcomposer.org/). To install, simply require `league/omnipay` and `sudiptpa/omnipay-esewa` with Composer: |
| 16 | + |
| 17 | +``` |
| 18 | +composer require league/omnipay sudiptpa/omnipay-esewa |
| 19 | +``` |
| 20 | + |
| 21 | +## Basic Usage |
| 22 | + |
| 23 | +### Purchase |
| 24 | + |
| 25 | +```php |
| 26 | + use Omnipay\Omnipay; |
| 27 | + use Exception; |
| 28 | + |
| 29 | + $gateway = Omnipay::create('Esewa_Secure'); |
| 30 | + |
| 31 | + $gateway->setMerchantCode('epay_payment'); |
| 32 | + $gateway->setTestMode(true); |
| 33 | + |
| 34 | + try { |
| 35 | + $response = $gateway->purchase([ |
| 36 | + 'amount' => 100, |
| 37 | + 'deliveryCharge' => 0, |
| 38 | + 'serviceCharge' => 0, |
| 39 | + 'taxAmount' => 0, |
| 40 | + 'totalAmount' => 100, |
| 41 | + 'productCode' => 'ABAC2098', |
| 42 | + 'returnUrl' => 'https://merchant.com/payment/1/complete', |
| 43 | + 'failedUrl' => 'https://merchant.com/payment/1/failed', |
| 44 | + ])->send(); |
| 45 | + |
| 46 | + if ($response->isRedirect()) { |
| 47 | + $response->redirect(); |
| 48 | + } |
| 49 | + } catch (Exception $e) { |
| 50 | + return $e->getMessage(); |
| 51 | + } |
| 52 | +``` |
| 53 | + |
| 54 | +After successful payment and redirect back to merchant site, you need to now verify the payment with another API request. |
| 55 | + |
| 56 | +### Verify Payment |
| 57 | + |
| 58 | +```php |
| 59 | + $gateway = Omnipay::create('Esewa_Secure'); |
| 60 | + |
| 61 | + $gateway->setMerchantCode('epay_payment'); |
| 62 | + $gateway->setTestMode(true); |
| 63 | + |
| 64 | + $response = $gateway->verifyPayment([ |
| 65 | + 'amount' => 100, |
| 66 | + 'referenceNumber' => 'GDFG89', |
| 67 | + 'productCode' => 'gadfg-gadf', |
| 68 | + ])->send(); |
| 69 | + |
| 70 | + if ($response->isSuccessful()) { |
| 71 | + // Success |
| 72 | + } |
| 73 | + |
| 74 | + // Failed |
| 75 | +``` |
| 76 | + |
| 77 | +## Laravel Integration |
| 78 | + |
| 79 | +Please follow the [eSewa Online Payment Gateway Integration](https://sujipthapa.com/blog/esewa-online-payment-gateway-integration-with-php) and follow step by step guidlines. |
| 80 | + |
| 81 | +## Official Doc |
| 82 | + |
| 83 | +Please follow the [Official Doc](https://developer.esewa.com.np) to understand about the parameters and their descriptions. |
| 84 | + |
| 85 | +## Contributing |
| 86 | + |
| 87 | +Contributions are **welcome** and will be fully **credited**. |
| 88 | + |
| 89 | +Contributions can be made via a Pull Request on [Github](https://github.com/sudiptpa/esewa). |
| 90 | + |
| 91 | +## Support |
| 92 | + |
| 93 | +If you are having general issues with Omnipay Esewa, drop an email to [email protected] for quick support. |
| 94 | + |
| 95 | +If you believe you have found a bug, please report it using the [GitHub issue tracker](https://github.com/sudiptpa/esewa/issues), |
| 96 | +or better yet, fork the library and submit a pull request. |
| 97 | + |
| 98 | +## License |
| 99 | + |
| 100 | +This package is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT). |
0 commit comments