PHP code example of riwash / khalti

1. Go to this page and download the library: Download riwash/khalti 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 / khalti example snippets



 public function khalti()
    {
        $payment = new RiwashKhalti;
        $data = [
            'amount' => '1000',
            'purchase_order_id' => 'Order01',
            'purchase_order_name' => 'test',
            'customer_info' => [
                'name' => 'Riwash',
                'email' => '[email protected]',
                'phone' => '9800000001',
            ]
        ];
        return $payment->khaltiCheckout($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());

    }