Download the PHP package jwn25/php-esewa without Composer

On this page you can find all versions of the php package jwn25/php-esewa. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package php-esewa

Php Esewa

php-esewa is a package which is developed to implement esewa support for Omnipay. Omnipay is a payment processing library for PHP.

Installation

As this package is esewa support for Omnipay, installation of omnipay library is must.

composer require league/omnipay

composer require jwn25/php-esewa

Laravel Usage

Config

Add following lines on config/services.php

'esewa' => [  
  'merchant_code' => env('ESEWA_MERCHANT_CODE', 'epay_payment'),  
  'test_mode' => env('ESEWA_TEST_MODE', true)  
]

ENV

Update your .env with credentials provided by esewa.

ESEWA_MERCHANT_CODE=YOUR_MERCHANT_CODE
ESEWA_TEST_MODE=false

Routes

Route::post('/order/{order_id}/payment-process', 'PaymentController@processPayment');

Route::get('/order/{order_id}/payment-failed', 'PaymentController@paymentFailed')->name('payment-failed');  

Route::get('/order/{order_id}/payment-completed', 'PaymentController@paymentCompleted')->name('payment-completed');

Controller

<?php  

namespace App\Http\Controllers;  

use Illuminate\Http\Request;  
use Omnipay\Omnipay;  

class PaymentController extends Controller {
  protected $payment_gateway;

  public function __construct() {
    $this->payment_gateway = Omnipay::create('PhpEsewa_Secure');
    $this->payment_gateway->setScd(config('services.esewa.merchant_code'));
    $this->payment_gateway->setTestMode(config('services.esewa.test_mode'));
  }

  public function processPayment($order_id) {
    try {  
      $response = $this->payment_gateway->purchase([  
          'amt' => 100,  
          'txAmt' => 0,  
          'psc' => 0,  
          'pdc' => 0,  
          'tAmt' => 100,  
          'pid' => rand(10, 10000), //Your Purchase Unique ID
          'su' => route('payment-completed', $order_id),  
          'fu' => route('payment-failed', $order_id),  
      ])->send();  
    } catch (Exception $e) {  
      //return back with some proper payment somehow failed message.
    }
    if ($response->isRedirect()) {  
      $response->redirect();  
    } else {  
      //return back with some proper payment somehow failed message.
    }
  }

  public function paymentCompleted($order_id, Request $request)  
  {  
    $response = $this->payment_gateway->verifyPayment([  
      'amt' => $request->get(amt),  
      'rid' => $request->get('refId'),  
      'pid' => $request->get('oid'),  
     ])->send();  

    if ($response->isSuccessful()) {
       // Update your order payment status using $order_id
       //redirect users to show some congratulations message (To make them feel good)
     } else {
       //IF SOMEHOW SOMETHING WENT WRONG INTERNALLY. Redirect users to route with proper message.
       // return redirect()->route('YOUR_ROUTE')->with('message', 'Your payment has been declined. Please retry.')
     }
    }

  public function paymentFailed($order_id) {  
    //Redirect user back with payment failed message  
  }
}  

Simple PHP Usage

Making Purchase

use Omnipay\Omnipay;
use Exception;

$payment_gateway = Omnipay::create('PhpEsewa_Secure');

$payment_gateway->setScd('MERCHANT_CODE');
$payment_gateway->setTestMode(true); //set it false if you want live mode.

try {
    $resp = $payment_gateway->purchase([
      'amt' => 100,  
      'txAmt' => 0,  
      'psc' => 0,  
      'pdc' => 0,  
      'tAmt' => 100,  
      'pid' => rand(10,10000),  //Your Purchase Unique ID
      'su' => 'https://yoursite.com/payment/success,  
      'fu' => 'https://yoursite.com/payment/failed',
    ])->send();

    if ($resp->isRedirect()) {
        $resp->redirect();
    }
} catch (Exception $e) {
    return $e->getMessage();
}

Payment Verification

$payment_gateway = Omnipay::create('PhpEsewa_Secure');

$payment_gateway->setScd('MERCHANT_CODE');
$payment_gateway->setTestMode(true); //set it false if you want live mode.

$resp = $payment_gateway->verifyPayment([
    'amt' => '100',  
    'rid' => 'ABCD', //rid from url (attached by esewa) 
    'pid' => '1234-5678', //pid from url (attached by esewa)
])->send();

if($resp->isSuccessful()) {
 //DO WHATEVER YOU WANT AFTER PAYMENT SUCCESS
}
//DO SOMETHING IF FAILED

ESEWA Documentation

Visit and go through Esewa Offical Developer's Guide to know about parameters and payment processes in detail.

Confusion?

Feel free to contact me on [email protected] if you are confused.


All versions of php-esewa with dependencies

PHP Build Version
Package Version
Requires omnipay/common Version ^3
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package jwn25/php-esewa contains the following files

Loading the files please wait ....