1. Go to this page and download the library: Download neputertech/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/ */
neputertech / khalti example snippets
...
use Neputer\Facades\Khalti;
use Illuminate\Support\Facades\Redirect;
class PaymentController extends Controller {
...
public function pay() {
$return_url = "http://example.com/verify";
$purchase_order_id = "your_transaction_id"; // example 123567;
$purchase_order_name = "your_order_name"; // example Transaction: 1234,
$amount = 1000; // Your total amount in paisa Rs 1 = 100 paisa
$response = Khalti::initiate($return_url, $purchase_order_id, $purchase_order_name, $amount);
// Custom handle of khalti response
return Redirect::to($response->payment_url);
}
public function verify(Request $request) {
$pidx = $request->get('pidx');
return Khalti::lookup($pidx);
}
}
return [
'debug' => env('KHALTI_DEBUG', true), // set false to run on live khalti url
'website_url' => 'https://example.com', // your website url
'public_key' => env('KHALTI_PUBLIC_KEY', ''), // public key from khalti
'secret_key' => env('KHALTI_SECRET_KEY', ''), // secret key from khalti
];