PHP code example of nutandc / nepal-payment-gateway

1. Go to this page and download the library: Download nutandc/nepal-payment-gateway 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/ */

    

nutandc / nepal-payment-gateway example snippets


use Nutandc\NepalPaymentSuite\Services\GatewayManager;

$gateway = app(GatewayManager::class)->esewa();

$payment = $gateway->payment([
    'amount' => '1000',
    'tax_amount' => '0',
    'total_amount' => '1000',
    'transaction_uuid' => 'txn_123',
    'product_code' => 'YOUR_PRODUCT_CODE',
    'success_url' => route('esewa.success'),
    'failure_url' => route('esewa.failure'),
]);

// Auto-submit HTML form:
echo $payment->redirectForm();

$verify = $gateway->verify([
    'transaction_uuid' => 'txn_123',
    'total_amount' => '1000',
    'product_code' => 'YOUR_PRODUCT_CODE',
]);

if ($verify->isSuccess()) {
    // handle success
}

use Nutandc\NepalPaymentSuite\Services\GatewayManager;

$gateway = app(GatewayManager::class)->khalti();

$payment = $gateway->payment([
    'return_url' => route('khalti.return'),
    'website_url' => config('app.url'),
    'amount' => 1000,
    'purchase_order_id' => 'order_123',
    'purchase_order_name' => 'Order #123',
]);

return redirect()->away($payment->redirectUrl());

$verify = $gateway->verify([
    'pidx' => 'pidx_123',
]);

use Nutandc\NepalPaymentSuite\Services\GatewayManager;

$gateway = app(GatewayManager::class)->connectIps();

$payment = $gateway->payment([
    'transaction_id' => 'txn_123',
    'transaction_amount' => 1000,
    'remarks' => 'Order payment',
    'particulars' => 'Order #123',
    'reference_id' => 'ref_123',
    'success_url' => route('connectips.success'),
    'failure_url' => route('connectips.failure'),
]);

echo $payment->redirectForm();

$verify = $gateway->verify([
    'reference_id' => 'ref_123',
    'transaction_amount' => 1000,
]);

use Nutandc\NepalPaymentSuite\Services\GatewayManager;

$gateway = app(GatewayManager::class)->stripe();

$payment = $gateway->payment([
    'amount' => 1500,
    'currency' => 'usd',
    'product_name' => 'Subscription',
    'success_url' => route('stripe.success'),
    'cancel_url' => route('stripe.cancel'),
]);

return redirect()->away($payment->redirectUrl());

$gateway->payment($payload, 'order-123');
bash
composer