uisits/ipay

Ipay支付网关的包

dev-master 2020-04-08 17:15 UTC

README

Build Status downloads Issues Release

关于

uisits/ipay是ipay支付网关的包。请参考部门间iPay参考指南以获取更多详细信息。

iPAY部门参考指南

安装指南

  • 注意
    • 在安装此包之前,请确保已安装以下包
    1. nesbot/carbon
      composer require nesbot/carbon
      
    2. guzzlehttp\guzzle
      composer require guzzlehttp/guzzle
      

安装步骤

  1. 运行

    composer require uisits/ipay
    
  2. 将服务提供者添加到您的config/app.php配置文件

    uisits\ipay\IpayServiceProvider::class,
    

    或者,将外观添加到config/app.php配置文件(在别名数组下)

    'Ipay' => uisits\ipay\app\Facade\IpayFacade::class,
    
  3. 发布资源

    php artisan vendor:publish
    
  4. 迁移数据库

    php artisan migrate
    
  5. 编辑config/ipay.php文件

  6. 在您的控制器中发送支付时,编写以下代码

    use uisits\ipay\app\Http\Controllers\IpayController as ipay;
    
    $ipay = new ipay();
    $redirect_url = $ipay->initiatePayment($amount);
    
    If you need to save the transaction details in another table you can fetch the latest transaction from the Ipay table and insert the records in the new table.
    
    Validate Url then send redirect away
    
    For Ex:
    if(\filter_var($redirect_url,FILTER_VALIDATE_URL)){
        return redirect()->away($redirect_url);
    }
    
    

    或者使用外观

    use Ipay;
    
    $redirect_url = Ipay::initiatePayment($amount);
    
    Validate Url then send redirect away
    
    If you need to save the transaction details in another table you can fetch the latest transaction from the Ipay table and insert the records in the new table.
    
    For Ex:
    if(\filter_var($redirect_url,FILTER_VALIDATE_URL)){
        return redirect()->away($redirect_url);
    }
    
  7. 要捕获支付,从映射到您的应用程序的ipay服务器发送请求

    $ipay->capturePayment($request);
    

    或者使用外观

    Ipay::capturePayment($request);
    

    capturePayment() 函数返回 true 或抛出错误。

文档

  1. initiatePayment()

    信息:使用Ipay服务器初始化支付请求 参数:float $amount 返回:重定向到Ipay服务器进行支付表单的URL字符串

  2. capturePayment()

    信息:向Ipay服务器发送捕获请求 参数:带有从iPay服务器获得的TOKEN的HTTP $request 返回:布尔值 true 成功交易 | 对失败交易抛出错误

运行测试

注意: 1. 您需要一个包含iPay运行所需所有参数的.env.example文件。这些参数可以在上述部门间Ipay指南中找到。请将.env.example文件复制到vendor/uisits/ipay/.env.example路径。2. 请运行composer install以安装所有依赖项,包括--dev依赖项。3. 导航到vendor/uisits/ipay并运行phpunit。

待办事项

  • 用户可以选择是否将交易保存到数据库
  • 添加到表中的费用