gopal-g / payment
Laravel 5.3 包用于集成最新的 CCAvenue 支付网关,支持 PHP 7.1(最近发布)
Requires
- php: >=7.0
- illuminate/support: ~5.0|~6.0
Requires (Dev)
- phpunit/phpunit: >=5.4.3
- squizlabs/php_codesniffer: ^2.3
This package is not auto-updated.
Last update: 2024-09-15 04:47:22 UTC
README
Laravel 5.x 版本的 CCAvenue 支付网关集成(支持 PHP 7.1)
本包旨在将 CCAvenue 支付网关集成到您的 Laravel 项目中,虽然也考虑了其他支付网关,但在发布时仅限于 ccavenue。
重要
代码最初是 softon/indipay 项目的分支,但这个包使用了 CCAvenue 为 php 7.1
发布的最新 SDK,因为他们的旧 SDK 不支持这个版本。
安装
步骤 1: 使用 composer 安装包
$ composer require gopal-g/payment
步骤 2: 将服务提供者添加到 Laravel 中的 config/app.php
文件
Appnings\Payment\PaymentServiceProvider::class,
步骤 3: 在 Laravel 的 config/app.php
文件中为 Facade 添加别名
'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
贡献
请参阅 CONTRIBUTING 和 CODE_OF_CONDUCT 了解详细信息。
安全
如果您发现任何安全相关的问题,请通过电子邮件 c4gopal@gmail.com
而不是使用问题跟踪器。
致谢
许可证
MIT 许可证 (MIT)。请参阅 许可证文件 了解更多信息。