aimensasi / fpx
FPX支付服务的Laravel实现
1.0.3-beta
2021-06-16 06:32 UTC
Requires
- php: ^7.4|^8.0
- illuminate/support: ^8.0
Requires (Dev)
- orchestra/testbench: ^6.0
- phpunit/phpunit: ^9.3.3
This package is auto-updated.
Last update: 2024-09-16 13:48:20 UTC
README
此包提供了laravel对Paynet FPX服务的实现。
安装
您可以通过composer安装此包
composer require aimensasi/fpx
然后运行发布命令以发布配置文件和支持控制器
php artisan vendor:publish --provider="Aimensasi\FPX\FPXServiceProvider"
这将生成以下文件
- 配置文件,包含默认设置,您可以根据需要进行覆盖
fpx.php
- 将接收支付响应和任何主机到主机事件的控制器
Http/Controllers/FPX/Controller.php
设置
- 将您的重定向URL以及您的卖家和交换ID添加到
.env
文件中。
FPX_INDIRECT_URL=https://app.test/payments/fpx/callback FPX_INDIRECT_PATH=payments/fpx/callback FPX_DIRECT_URL=https://app.test/payments/fpx/direct-callback FPX_DIRECT_PATH=payments/fpx/direct-callback FPX_EXCHANGE_ID= FPX_SELLER_ID=
- 在生成您的证书后,将它们添加到您的应用程序中。默认情况下,我们会在以下指令中寻找证书。
'certificates' => [ 'uat' => [ 'disk' => 'local', // S3 or Local. Don't put your certificate in public disk 'dir' => '/certificates/uat', ], 'production' => [ 'disk' => 'local', // S3 or Local. Don't put your certificate in public disk 'dir' => '/certificates/prod', ] ],
您可以通过更新配置文件来覆盖默认设置。
- 运行迁移以添加银行表
php artisan migrate
用法
- 首先运行以下命令以播种银行列表。
php artisan fpx:banks
您应该安排fpx:banks Artisan命令每天运行
$schedule->command('fpx:banks')->daily();
- 添加具有以下属性的
x-fpx-pay
组件
<x-fpx-pay :reference-id="$invoice->id" :datetime="$invoice->created_at->format('Ymdhms')" :amount="$invoice->total" :customer-name="$company->name" :customer-email="$company->owner->email" product-description="Salary Invoice">
在测试期间,您可以使用test-mode
属性来覆盖提供的金额为'MYR 1.00'
<x-fpx-pay :reference-id="$invoice->id" :datetime="$invoice->created_at->format('Ymdhms')" :amount="$invoice->total" :customer-name="$company->name" :customer-email="$company->owner->email" product-description="Salary Invoice" test-mode>
- 在
Http/Controllers/FPX/Controller.php
中处理支付响应
/** * This will be called after the user approve the payment * on the bank side * * @param Request $request * @return Response */ public function callback(Request $request) { $response = $request->handle(); // Update your order status } /** * This will handle any direct call from FPX * * @param Request $request * @return string */ public function webhook(Request $request) { $response = $request->handle(); // Update your order status return 'OK'; }
变更日志
有关最近更改的更多信息,请参阅CHANGELOG。
贡献
有关详细信息,请参阅CONTRIBUTING。
安全性
如果您发现任何与安全性相关的问题,请通过电子邮件aimensasi@icloud.com而不是使用问题跟踪器。
鸣谢
许可证
MIT许可证(MIT)。有关更多信息,请参阅许可证文件。
Laravel包模板
此包是用Laravel包模板生成的。