elgibor-solution/laravel-payment-bca
Composer 安装命令:
composer require elgibor-solution/laravel-payment-bca
包简介
Laravel package for BCA OpenAPI Virtual Account (Inquiry, Payment Flag, Status) with caching and signatures.
README 文档
README
Production-ready Laravel 11 / PHP 8.3 package for BCA OpenAPI Virtual Account (bill presentment + payment flag + optional payment status). Namespace: ESolution\BCAPayment.
Installation
composer require elgibor-solution/laravel-payment-bca
php artisan vendor:publish --provider="ESolution\\BCAPayment\\BcaServiceProvider" --tag=bca-config
Configuration
Config lives at config/bca.php (aliased to config/bca-openapi.php). Keys:
base_url(prod) /base_url_staging(sandbox) — defaults:https://api.klikbca.com/https://devapi.klikbca.comclient_id,client_secret,private_key(PEM)channel_id,partner_id, optionalorigintimeout,connect_timeout,retry_times,retry_sleep_mstoken_cache_ttl_seconds(default 900),retry_on_codes(default5002600for payment status retry)debugtoggles staging base URL
Environment example:
BCA_BASE_URL=https://api.klikbca.com BCA_BASE_URL_STAGING=https://devapi.klikbca.com BCA_CLIENT_ID=your_client_id BCA_CLIENT_SECRET=your_symmetric_secret BCA_PRIVATE_KEY="-----BEGIN PRIVATE KEY-----..." BCA_CHANNEL_ID=95231 BCA_PARTNER_ID=12345 BCA_ORIGIN=https://merchant.example BCA_DEBUG=false
Runtime config
- Override defaults globally:
Bca::config([...])orBca::setDefaultConfig([...]). - Per-call overrides:
Bca::withConfig([...])orBca::withBaseUrl($url)returning a client instance. - Debug staging per call:
Bca::withConfig(['debug' => true]).
Usage
use ESolution\BCAPayment\Facades\Bca; // Access token (cached per client_id + base URL) $token = Bca::token(); // Inquiry (Bill Presentment) $inquiry = Bca::withConfig(['debug' => true])->inquiry([ 'partnerServiceId' => '123', 'customerNo' => '987654', 'virtualAccountNo' => '123987654', 'trxDateInit' => now()->toIso8601String(), 'channelCode' => '6011', 'amount' => ['value' => '10000', 'currency' => 'IDR'], 'inquiryRequestId' => 'REQ-1', ]); // Payment Flag $payment = Bca::payment([ 'partnerServiceId' => '123', 'customerNo' => '987654', 'virtualAccountNo' => '123987654', 'virtualAccountName' => 'John Doe', 'paymentRequestId' => 'PAY-1', // should match inquiryRequestId when retrying 'channelCode' => '6011', 'paidAmount' => ['value' => '10000', 'currency' => 'IDR'], 'totalAmount' => ['value' => '10000', 'currency' => 'IDR'], 'trxDateTime' => now()->toIso8601String(), 'flagAdvise' => 'N', // N=new, Y=retry ]); // Payment Status (optional) $status = Bca::paymentStatus([ 'partnerServiceId' => '123', 'customerNo' => '987654', 'virtualAccountNo' => '123987654', 'inquiryRequestId' => 'REQ-1', 'paymentRequestId' => 'PAY-1', ]);
All transaction calls accept an optional second argument to override headers (e.g. provide your own X-EXTERNAL-ID). The package auto-generates a numeric X-EXTERNAL-ID (<=36 chars), and always sends CHANNEL-ID, X-PARTNER-ID, and optional ORIGIN.
Endpoints (fixed)
- Token:
POST /openapi/v1.0/access-token/b2b - Inquiry:
POST /openapi/v1.0/transfer-va/inquiry - Payment:
POST /openapi/v1.0/transfer-va/payment - Payment Status:
POST /openapi/v1.0/transfer-va/status
Signatures (overview)
- Token (asymmetric RSA SHA256): String to sign =
client_id|X-TIMESTAMP. Headers:X-TIMESTAMP,X-CLIENT-KEY,X-SIGNATURE. - Transactions (HMAC SHA-512):
- String to sign =
HTTPMethod:RelativeUrl:AccessToken:lowercase(sha256(minified_body)):Timestamp RelativeUrlstarts with/and includes sorted query params.- Body is JSON-minified; empty body => empty string hashed.
- Header set includes
Authorization: Bearer {token},X-TIMESTAMP,X-SIGNATURE,X-EXTERNAL-ID,CHANNEL-ID,X-PARTNER-ID, optionalORIGIN.
- String to sign =
Notes
- Bill Presentment (Inquiry) and Payment Flag must be used together; Payment Status is optional and marks code
5002600as retryable by default. - Tokens are cached using
client_id+ base URL hash with a safety buffer to avoid near-expiry calls. - HTTP client uses Laravel
Httpwith configurable timeouts and retries; secrets are never logged.
Testing
Run the feature tests with Orchestra Testbench:
composer test
elgibor-solution/laravel-payment-bca 适用场景与选型建议
elgibor-solution/laravel-payment-bca 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 0 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 12 月 21 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 elgibor-solution/laravel-payment-bca 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 elgibor-solution/laravel-payment-bca 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 26
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Apache-2.0
- 更新时间: 2025-12-21