pearlorganisation/laravel-ccavenue

Laravel 5.8+ 包用于集成最新的 CCAvenue 支付网关(支持 PHP 7+)

dev-master / 1.0.x-dev 2020-01-09 13:19 UTC

This package is auto-updated.

Last update: 2024-09-09 23:41:51 UTC


README

Laravel 5.x 的 CCAvenue 支付网关集成(支持 PHP 7.3)

Latest Version on Packagist Software License Total Downloads

此包旨在将 CCAvenue 支付网关集成到您的 Laravel 项目中,虽然也考虑了其他支付网关,但在发布时仅限于 ccavenue。

重要

代码最初是 softon/indipay 的类似包的分支。但由于旧 SDK 不支持该版本,因此此包使用 CCAvenue 为 php 7.1 发布的最新 SDK。

安装

步骤 1: 使用 composer 安装包

$ composer require pearlorganisation/laravel-ccavenue

步骤 2: 将服务提供者添加到 Laravel 中的 config/app.php 文件

 Appnings\Payment\PaymentServiceProvider::class,

步骤 3: 将 Facade 的别名添加到 Laravel 中的 config/app.php 文件

 'Payment' => Appnings\Payment\Facades\Payment::class 

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

  php artisan vendor:publish

上述步骤创建

  • config/payment.php
  • app/Http/Middlewares/VerifyCsrfToken.php
  • resources/views/vendor/payment/ccavenue.blade.php

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

   'App\Http\Middleware\VerifyCsrfToken',

   'App\Http\Middleware\VerifyCsrfMiddleware', 

使用方法

编辑 config/payment.php。设置适当的网关及其参数。然后在您的代码中...

    use Appnings\Payment\Facades\Payment;  

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

      /* All Required Parameters by your Gateway */
      $parameters = [
        'tid' => '1233221223322',
        'order_id' => '1232212',
        'amount' => '1200.00',
      ];
      
      $order = Payment::prepare($parameters);
      return Payment::process($order);

使用配置的任何网关启动购买请求并重定向:

      /* All Required Parameters by your Gateway */
      
      $parameters = [
        'tid' => '1233221223322',
        'order_id' => '1232212',
        'amount' => '1200.00',
      ];
      // gateway = CCAvenue / others
      
      $order = Payment::gateway('NameOfGateway')->prepare($parameters);
      return Payment::process($order);

从网关获取响应(将代码添加到配置文件中设置的重定向 URL。还请将响应路由添加到 remove_csrf_check 配置项以在这些路由上移除 CSRF 检查。):-

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

变更日志

请参阅 CHANGELOG 了解最近的变化信息。

测试

$ composer test

贡献

请参阅 CONTRIBUTINGCODE_OF_CONDUCT 了解详细信息。

安全

如果您发现任何安全相关的问题,请通过电子邮件 prashant@pearlorganisation.com 而不是使用问题跟踪器。

鸣谢

许可证

MIT 许可证(MIT)。请参阅 许可证文件 了解更多信息。