ib/ib-wallet

适用于尼泊尔所有类型支付网关的完整包

1.4.0 2024-09-25 11:29 UTC

This package is not auto-updated.

Last update: 2024-09-25 12:25:40 UTC


README

此Laravel包方便创建跨多个尼泊尔钱包(如Khalti、eSewa等)的支付,提供尼泊尔多样的支付选项。支持任何包的最新版本

如何贡献

如果您想为此项目做出贡献。

支持的钱包

  • Khalti:正常工作
  • Esewa:正常工作
  • Parbhu Pay:即将推出
  • Ime Pay:即将推出
  • My Pay:即将推出

使用示例

使用Composer

composer require ib/ib-wallet

发布供应商文件

php artisan vendor:publish --provider="Ib\IbWallet\IbWalletServiceProvider"

php artisan vendor:publish

使用

use IbWallet;

粘贴到控制器中

对于Khalti

设置环境文件(以下为示例)

  • 模式0用于开发
  • 模式1用于生产
KHALTI_CALLBACK_URL=http://127.0.0.1:8000/khalti-callback 
KHALTI_MODE=0
KHALTI_SECRET_KEY=

对于Khalti商家

 // if you have amount in rs, then you can use IbWallet::Khaltiamount('amount in rs'), this will response in paisa.
$payload = [
'amount' => 1000, // in paisa
'purchase_order_id' => '123456710', // most in unique
'purchase_order_name'=> 'test prod', // unique but not mendotary
'name'=> 'test bahadur', 
'phone'=> '01912345678',
'email'=> 'test@gmail.com',
'callback_url' => "http://127.0.0.1:8000/khalti-callback" // optional if you wnat to redirect custom url
];
// initate the payment to process the khalti payment
$initate_payment = IbWallet::khalti($payload);
// after initate payment. call checkout method to hit the checkout method
$checkout = IbWallet::KhaltiCheckout($initate_payment);
// this will redirect to khalti checkout section to fullfill the payment 
return $checkout;
//if your payment success then you auto redirect in callback url which you already set in env file.

如果您有rs货币的金额,则可以使用IbWallet::Khaltiamount('rs货币的金额'),这将响应以paisa为单位。

$amount = IbWallet::Khaltiamount('amount in rs');

支付成功并重定向到您已在环境文件中设置的回调URL。然后,您可以使用get方法打印响应或ib钱包提供该功能。用于打印响应

   //print khalti response after redirect success payment. 
   // here you can autometic redirect
   $response = IbWallet::KhaltiResponse();

对于Esewa

设置环境文件如上所示

  • 模式0用于开发
  • 模式1用于生产
  • 此密钥和产品代码仅用于开发,对于生产,您需要联系Esewa
ESEWA_PRODUCT_CODE=EPAYTEST
ESEWA_MODE=0
ESEWA_FAILURE_URL=http://127.0.0.1:8000/esewa-fail
ESEWA_SUCCESS_URL=http://127.0.0.1:8000/esewa-success
ESEWA_SECRET_KEY=8gBm/:&EnhH.1/q

在控制器中

  • 不要更改签名字段。
$paylod =[
       'amount' => 1000, // in amount 
       'product_delivery_charge' => 0,
       'product_service_charge' => 0,
       'signed_field_names' =>"total_amount,transaction_uuid,product_code", // set signature field name, signature field auto generate
       'tax_amount' =>0,
       'total_amount' => 1000,
       // 'failure_url' =>"http://127.0.0.1:8000/esewa-fail" , // optional if you want to redirect to other page
       // 'success_url' =>"http://127.0.0.1:8000/esewa-success", // optional if you want to redirect to other page
       'transaction_uuid' => Str::random(20), // must be unique
   ];
return IbWallet::Esewa($paylod);

支付成功和失败后,您将自动重定向到在.env文件中设置的失败和成功URL。定义方法如下

public function esewa_success(Request $request){
    // print your response
    // save your work on database or continue your work
    //dd($request->all());
     $response = IbWallet::EsewaResponse($request->all());
        // dd($response);
       print_r($response);
}

public function esewa_fail(Request $request){
    // print your response
    dd($request->all());
}

许可证

MIT

作者

  • Indra Basnet

支持和反馈

邮箱:basnetindra342@gmail.com