softon/indipay

Laravel 5 适用于印度支付网关的包。目前支持的网关:CCAvenue、PayUMoney、EBS、CitrusPay、InstaMojo、ZapakPay、Mocker

v1.2.4 2020-09-23 09:46 UTC

README

Laravel 5+ 适用于印度支付网关的包。目前支持的网关: CCAvenuePayUMoneyEBSCitrusPayZapakPay (Mobikwik),PaytmMocker

点击此处查看 Laravel 4.2 包

安装

步骤 1: 使用 composer 安装包

    composer require softon/indipay

步骤 2: 将服务提供者添加到 Laravel 的 config/app.php 文件中(Laravel 5.5+ 可选)


    Softon\Indipay\IndipayServiceProvider::class,

步骤 3: 将外观别名添加到 Laravel 的 config/app.php 文件中(Laravel 5.5+ 可选)


    'Indipay' => Softon\Indipay\Facades\Indipay::class,

步骤 4: 在终端中运行以发布配置和中间件


    php artisan vendor:publish --provider="Softon\Indipay\IndipayServiceProvider" 

步骤 5: 修改 app\Http\Kernel.php 以使用新的中间件。这是必要的,以便在来自支付网关的响应 URL 上避免 CSRF 验证。 您可以根据需要调整 config/indipay.php 文件中的路由以在网关响应路由上禁用 CSRF。

注意:您还可以使用新的 VerifyCsrfToken 中间件,并将路由添加到 $except 数组中。

App\Http\Middleware\VerifyCsrfToken::class,

to

App\Http\Middleware\VerifyCsrfMiddleware::class,

使用方法

编辑 config/indipay.php。设置适当的网关参数。还要在配置文件中设置默认网关以使用,通过在配置文件中设置 gateway 键。然后在您的代码中...

 use Softon\Indipay\Facades\Indipay;  

使用默认网关启动购买请求并重定向:

      /* All Required Parameters by your Gateway will differ from gateway to gateway refer the gate manual */
      
      $parameters = [
        'transaction_no' => '1233221223322',
        'amount' => '1200.00',
        'name' => 'Jon Doe',
        'email' => 'jon@doe.com'
      ];
      
      $order = Indipay::prepare($parameters);
      return Indipay::process($order);

请检查您网关手册中所需参数。此包中有一个基本的验证来检查它。

您还可以使用多个网关:

      // gateway = CCAvenue / PayUMoney / EBS / Citrus / InstaMojo / ZapakPay / Paytm / Mocker
      
      $order = Indipay::gateway('Paytm')->prepare($parameters);
      return Indipay::process($order);

从网关获取响应(将代码添加到配置文件中设置的跳转 URL。还要将响应路由添加到移除_csrf_check 配置项,以在这些路由上移除 CSRF 检查。):

 
    public function response(Request $request)
    
    {
        // For default Gateway
        $response = Indipay::response($request);
        
        // For Otherthan Default Gateway
        $response = Indipay::gateway('NameOfGatewayUsedDuringRequest')->response($request);

        dd($response);
    
    }  

Indipay::response 将负责检查响应的有效性,因为大多数网关都会添加一个校验和来检测数据的任何篡改。

需要注意的是,在继续到网关之前,将交易信息存储到持久数据库中,以便稍后验证状态。

支付验证

从版本 v1.0.12 开始,Indipay 开始在部分网关中实施验证方法,以便开发者在待处理支付等情况中验证支付。

    $order = Indipay::verify([
        'transaction_no' => '3322344231223'
    ]);

要传递的参数再次取决于使用的网关。

当前支持验证功能的网关:Paytm,Mocker