PHP code example of riwash / esewa

1. Go to this page and download the library: Download riwash/esewa library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

riwash / esewa example snippets



  

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Riwash\Esewa\RiwashEsewa;
use Illuminate\Support\Facades\Http;

class PaymentTestController extends Controller
{
    public function esewa()
    {
        $tuid = now()->timestamp;
        $data = [
            "amount" => "100",
            "product_delivery_charge" => "0",
            "product_service_charge" => "0",
            "product_code" => "EPAYTEST",
            "tax_amount" => "10",
            "total_amount" => "110",
            "transaction_uuid" => $tuid
        ];

        $payment = new RiwashEsewa();

        return $payment->esewaCheckout($data);

    }
    public function success(Request $request)
    {
        //write your after payment success  code here
        dd($request->all());
    }

    public function fail(Request $request)
    {
        // write if payment failed response here
        dd($request->all());

    }

}