zrkb/bancard
Composer 安装命令:
composer require zrkb/bancard
包简介
A minimal implementation for Bancard API vPOS 2.0
README 文档
README
PHP SDK for the Bancard vPOS 2.0 payment gateway API
Installation
Requirements: PHP >= 8.1
composer require zrkb/bancard
Configuration
use Bancard\Bancard; $bancard = new Bancard( publicKey: 'YOUR_PUBLIC_KEY', privateKey: 'YOUR_PRIVATE_KEY', staging: true, // optional, defaults to false );
Usage
All operations return typed response objects with convenience methods.
Single Buy
use Bancard\Util\Currency; $response = $bancard->singleBuy([ 'shop_process_id' => '7777777', 'amount' => '10000.00', 'currency' => Currency::PYG->value, 'return_url' => 'https://app.test/return', 'cancel_url' => 'https://app.test/cancel', ]); if ($response->isSuccessful()) { $processId = $response->getProcessId(); }
Single Buy (Zimple)
$response = $bancard->singleBuyZimple([ 'shop_process_id' => '7777777', 'amount' => '10000.00', 'currency' => Currency::PYG->value, 'return_url' => 'https://app.test/return', 'cancel_url' => 'https://app.test/cancel', ]);
Single Buy Confirm
Generates the confirm token for the iframe callback (no HTTP request is made).
$response = $bancard->singleBuyConfirm([ 'shop_process_id' => '7777777', 'amount' => '10000.00', 'currency' => Currency::PYG->value, ]); $token = $response->getToken();
Single Buy Get Confirmation
$response = $bancard->singleBuyGetConfirmation([ 'shop_process_id' => '7777777', ]); if ($response->isApproved()) { $code = $response->getResponseCode(); }
Single Buy Rollback
$response = $bancard->singleBuyRollback([ 'shop_process_id' => '7777777', ]);
Register a New Card
$response = $bancard->cardsNew([ 'card_id' => '123', 'user_id' => '456', 'return_url' => 'https://app.test/return', ]); $processId = $response->getProcessId();
List User Cards
$response = $bancard->usersCards([ 'user_id' => '456', ]); foreach ($response->getCards() as $card) { echo $card->card_masked_number; }
Charge (Token-Based Payment)
$response = $bancard->charge([ 'shop_process_id' => '7777777', 'amount' => '10000.00', 'currency' => Currency::PYG->value, 'alias_token' => 'card_alias_token', ]); if ($response->isApproved()) { // Payment successful } if ($response->is3dsRedirect()) { // 3DS authentication required }
Delete Card
$response = $bancard->deleteCard([ 'user_id' => '456', 'alias_token' => 'card_alias_token', ]);
Preauthorization Confirm
$response = $bancard->preauthorizationConfirm([ 'shop_process_id' => '7777777', ]); if ($response->isApproved()) { // Preauthorization confirmed }
Billing Client Info
$response = $bancard->billingClientInfo([ // billing client info fields ]); $client = $response->getClient();
Billing Cancel
$response = $bancard->billingCancel([ 'shop_process_id' => '7777777', ]);
Response Objects
All responses extend Bancard\Response\Response and provide:
isSuccessful(): bool-- checks ifstatus === 'success'getStatus(): ?stringgetMessage(): ?string-- first message descriptiongetErrorKey(): ?string-- error key from messagesraw(): \stdClass-- access the raw response data
Specialized responses add operation-specific methods (e.g., getProcessId(), isApproved(), getCards()).
Error Handling
use Bancard\Exception\ValidationException; try { $response = $bancard->singleBuy($payload); } catch (ValidationException $e) { // Missing required fields $errors = $e->getErrors(); // ['shop_process_id', 'amount', 'currency'] }
Amount Formatting
use Bancard\Util\Amount; $formatted = Amount::format(10000); // "10000.00"
Upgrading from v1
See UPGRADE.md for the migration guide.
Security
If you discover any security related issues, please use the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.
zrkb/bancard 适用场景与选型建议
zrkb/bancard 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 244 次下载、GitHub Stars 达 1, 最近一次更新时间为 2020 年 06 月 10 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「php」 「bancard」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 zrkb/bancard 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 zrkb/bancard 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 zrkb/bancard 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Alfabank REST API integration
Laravel wrapper package for the Bancard QR API
Zero-dependency raw PHP DNS resolver, domain-ownership verification, and intoDNS/MxToolbox-style diagnostics. Queries authoritative nameservers directly over sockets — never trusts the recursive cache for ownership checks.
A lightweight plain-PHP framework for database-backed CRUD APIs.
bughq error tracking - PHP SDK
统计信息
- 总下载量: 244
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 27
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-06-10