twelver313/kapital-bank
Composer 安装命令:
composer require twelver313/kapital-bank
包简介
Kapital Bank E-Commerce 3DS v2.2 Payment Gateway adapter
README 文档
README
Kapital Bank E-Commerce API integration library
Seamlessly integrate Kapital Bank E-Commerce API using object-oriented PHP.
Table of Contents
1. Installation
composer require twelver313/kapital-bank
2. Usage
2.1 Initialize payment gateway adapter
use Twelver313\KapitalBank\PaymentGateway; $paymentGateway = new PaymentGateway([ 'login' => '<YOUR_LOGIN>', 'password' => '<YOUR_PASSWORD>', 'isDev' => true, // Optional flag for using Kapital-Bank's test environment /* You don't need to pass the option below. It was added just in case Kapital Bank changes host address */ // 'paymentHost' => 'https://txpgtst.kapitalbank.az' ]);
2.2 Create order
$orderParams = [ 'amount' => 10, // i.e '10.00', 'currency' => 'AZN', // Optional, 'AZN' by default 'description' => 'Purchase order example', // Your description 'redirectUrl' => '/your-redirect-url', 'language' => 'az', // Optional, 'az' by default ]; /** Creating purchase order */ $order = $paymentGateway->createPurchaseOrder($orderParams); /** Creating pre-auth order */ $order = $paymentGateway->createPreAuthOrder($orderParams); /** Creating recurring order */ $order = $paymentGateway->createRecurringOrder($orderParams); /** Navigate to payment page */ $order->navigateToPaymentPage(); /** Or alternatively use other properties to accomplish your tasks */ $order->url; $order->id; $order->secret; $order->password;
2.3 Refunding
$response = $paymentGateway->refund([ 'id' => <ORDER_ID>, 'password' => '<ORDER_PASSWORD>', 'amount' => 10, // i.e 10.00 'phase' => 'Single', // Optional, 'Single' by default ]); // Response properties $response->approvalCode; // Example: "963348" $response->pmoResultCode; // Example: "1" $response->match->{$property}; // Read Kapital-Bank's official documentation see possible properties to refer
2.4 Get order status
use Twelver313\KapitalBank\OrderStatus $orderStatus = $paymentGateway->getOrderStatus([ 'id' => <ORDER_ID>, 'password' => '<ORDER_PASSWORD>' ]); // or use $orderStatus = $paymentGateway->getDetailedOrderStatus([ 'id' => <ORDER_ID>, 'password' => '<ORDER_PASSWORD>' ]); // for detailed order status $status = $orderStatus->status; // Do any stuff depending on status if ($status == OrderStatus::CANCELED) { // equivalent: $orderStatus->isCanceled() ... } if ($status == OrderStatus::DECLINED) { // equivalent: $orderStatus->isDeclined() ... } if ($status == OrderStatus::FULLY_PAID) { // equivalent: $orderStatus->isFullyPaid() ... } if ($status == OrderStatus::EXPIRED) { // equivalent: $orderStatus->isExpired() ... } if ($status == OrderStatus::REFUNDED) { // equivalent: $orderStatus->isRefunded() ... } if ($orderStatus->isOneOf([OrderStatus::CANCELED, OrderStatus::DECLINED])) { ... }
2.5 Restore order
You can only restore payments with Preparing status so we recommend you to check the order status using PaymentGateway::getOrderStatus() method to make sure of it before restoring the order
$orderParams = [ 'id' => <ORDER_ID>, 'password' => '<ORDER_PASSWORD>' ]; $orderStatus = $paymentGateway->getOrderStatus($orderParams); /** Restoring order if it was not finished or expired */ if ($orderStatus->isPreparing()) { $order = $paymentGateway->restoreOrder($orderParams); $order->navigateToPaymentPage(); }
2.6 Sending custom requests
Since this library doesn't provide all E-Commerce API features you can still perform the operations that are not coming out of the box by sending custom HTTP-requests
$response = $paymentGateway->makeRequest('POST', '/api/order/{id}/set-src-token?password={password}', [ 'order' => [ 'initiationEnvKind' => 'Server' ], 'token' => [ 'extCof' => [ 'ridByCofp' => '<RID_OF_CARD>', 'cofProviderRid' => 'TWO_COF' ], 'card' => [ 'entryMode' => 'ECommerce' ] ] ]); print_r($response);
Response will be an instance of stdClass. See official BirBank E-commerce API documentation to find out the response structure depending on your request
twelver313/kapital-bank 适用场景与选型建议
twelver313/kapital-bank 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 37 次下载、GitHub Stars 达 0, 最近一次更新时间为 2024 年 12 月 01 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 twelver313/kapital-bank 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 twelver313/kapital-bank 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 37
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 15
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: BSD-3-Clause
- 更新时间: 2024-12-01