hardevine / payment
Laravel 5.3 包,用于集成最新的 CCAvenue 支付网关,支持 PHP 7.1(最近发布)
Requires
- php: >=7.0
- illuminate/support: ~5.0|~6.0|~7.0|~8.0|~9.0|~10.0|~11.0
Requires (Dev)
- phpunit/phpunit: >=5.4.3
- squizlabs/php_codesniffer: ^2.3
README
此包旨在将 CCAvenue 支付网关集成到您的 Laravel 项目中,虽然也考虑了其他支付网关,但最初只针对 ccavenue 进行了集成。
重要
代码最初是 softon/indipay 的类似包的分支。但由于 CCAvenue 的旧 SDK 不支持该版本,因此此包使用了 CCAvenue 为 php 7.x/8.x
发布的最新 SDK。
安装
步骤 1: 使用 composer 安装包
$ composer require hardevine/payment
步骤 2: 将服务提供者添加到 Laravel 的 config/app.php
文件中
Appnings\Payment\PaymentServiceProvider::class,
步骤 3: 将外观别名添加到 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
贡献
请参阅 CONTRIBUTING 和 CODE_OF_CONDUCT 以获取详细信息。
安全
如果您发现任何安全相关的问题,请通过电子邮件发送到 c4gopal@gmail.com
,而不是使用问题跟踪器。
鸣谢
许可证
MIT 许可证(MIT)。请参阅 许可证文件 以获取更多信息。