cart53 / ccavenue
Laravel 5.x 付款网关集成包,支持 PHP 7+
Requires
- php: >=8.0
- illuminate/support: *
Requires (Dev)
README
Laravel 5.x 的 CCAvenue 付款网关集成(支持 PHP 7.3)
本包旨在将 CCAvenue 付款网关集成到您的 Laravel 项目中,尽管也考虑了其他付款网关,但在发布时仅限于 ccavenue。
重要
代码最初是类似包 softon/indipay 的分支。但本包使用 CCAvenue 为 php 7.1
发布的最新 SDK,因为他们的旧 SDK 不支持该版本。
安装
步骤 1: 使用 composer 安装包
$ composer require cart53/ccavenue
步骤 2: 将服务提供者添加到 Laravel 的 config/app.php
文件中
Cart53\Payment\PaymentServiceProvider::class,
步骤 3: 在 Laravel 的 config/app.php
文件中添加 Facade 的别名
'Payment' => Cart53\Payment\Facades\Payment::class
步骤 4: 在终端中运行以发布配置、中间件和视图
php artisan vendor:publish
以上步骤会创建
config/payment.php
app/Http/Middleware/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 Cart53\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
贡献
请参阅 CONTRIBUTING 和 CODE_OF_CONDUCT 了解详细信息。
安全
如果您发现任何安全相关的问题,请发送电子邮件到 prashant@cart53.com
而不是使用问题跟踪器。
鸣谢
许可证
MIT 许可证(MIT)。请参阅 许可证文件 了解更多信息。