susutawar/laravel-duitku
Composer 安装命令:
composer require susutawar/laravel-duitku
包简介
DuitKu Api implementation for laravel
README 文档
README
DuitKu API implementation in laravel. Initially made for personal use, so it’s a bit biased.
Installation
composer install susutawar/duitku-laravel
php artisan vendor:publish --tag="duitku"
Configuring
add the following to your .env file.
DUITKU_MERCHANT_ID= DUITKU_API_KEY= DUITKU_SANDBOX_MODE= DUITKU_RETURN_URL=
- Fill out
DUITKU_MERCHANT_ID,DUITKU_API_KEYwith credentials you obtain from duitku. - Set
DUITKU_SANDBOX_MODEto1to use DuitKu in sandbox mode, or0to use it in production mode. - Setup
DUITKU_RETURN_URLto any route you have configured. this will be used by DuitKu (see documentation). The value can be a route name or a URL.
You can check config/duitku.php for more setting/information.
Usage
Get Payments
Get available payment methods from DuitKu. see documentation
use SusuTawar\Facade\Duitku; // ... // the result is a Laravel Collection $paymentMethods = Duitku::getPayments($paymentAmount);
Make Transaction
Start a transaction using DuitKu. see documentation
use SusuTawar\Facade\Duitku; // ... $paymentMethods = Duitku::makeTransaction(/* params */);
The resulting object contains trx, url, qr, and va:
trx: The transaction number generated by DuitKu. Save this to your system.url: A link to the transaction page on DuitKu.qr: A string representing QRIS. You must generate QR images from this string yourself.va: The virtual account number for payment methods that support it.
Check Transaction
Check the status of a transaction using your transaction ID. see documentation
use SusuTawar\Facade\Duitku; // ... $checkResult = Duitku::check($yourTransactionId);
Error Handling
Instead of returning false or null, when something unexpected occurred we will throw an Exception instead.
You can catch the exception by its specific type or catch all exceptions with Exception, then use the provided message.
DuitKuAuthException: Occurs when the provided authentication credentials cannot be authenticated by DuitKu.DuitKuBadRequestException: Occurs when the provided parameters are not valid according to DuitKu.DuitKuNotFoundException: Occurs when the specified resource is not available in DuitKu.DuitKuPaymentException: Occurs when something goes wrong with the payment.
Callback Routing
We automatically register the callback route.
To handle the incoming callback, create a class implementing SusuTawar\Interfaces\DuitKuCallbackInterface,
and register it in config/duitku.php under routing.callback_handler
"routing" => [ // ... "callback_handler" => MyCallbackHandler::class, ]
If you prefer to manually set up the callback, disable this feature by updating the configuration:
"routing" => [ "enabled" => false, // ... ]
When this feature is disabled, you need to set the callback_url or add DUITKU_CALLBACK_URL
to your .env file. Otherwise, the callback_url will default to home or /.
susutawar/laravel-duitku 适用场景与选型建议
susutawar/laravel-duitku 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 20 次下载、GitHub Stars 达 1, 最近一次更新时间为 2024 年 05 月 14 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 susutawar/laravel-duitku 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 susutawar/laravel-duitku 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 20
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 15
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: GPL-3.0-or-later
- 更新时间: 2024-05-14