atdev/commweb
Composer 安装命令:
composer require atdev/commweb
包简介
Commweb Direct Payment REST API PHP SDK
README 文档
README
This is SDK for Direct Payment REST API of Commweb. Credit card payments supported only (pay, auth, capture, void, refund).
How to use
This sdk is installed via Composer. To install, simply add it to your composer.json file:
{
"require": {
"atdev/commweb": "~0.1"
}
}
And run composer to update your dependencies:
$ curl -s http://getcomposer.org/installer | php
$ php composer.phar update
Then, import the autoload.php from your vendor folder.
Sample calls
Add the following to the php file which calls SDK:
use ATDev\Commweb\PayRequest; use ATDev\Commweb\AuthorizeRequest; use ATDev\Commweb\CaptureRequest; use ATDev\Commweb\VoidRequest; use ATDev\Commweb\RefundRequest; use ATDev\Commweb\Order; use ATDev\Commweb\Transaction; use ATDev\Commweb\SourceOfFundsCard; use ATDev\Commweb\Card;
PAY
$result = (new PayRequest("MERCHANT_ID")) // Provided by gateway ->setApiPassword("API_PASSWORD") // Provided by gateway ->setOrder(new Order("SOME_ORDER_ID", 55.55, "AUD")) // Order id has to be unique, amount in money format, AUD is the only one supported now ->setTransaction(new Transaction("SOME_TRANSACTION_ID")) // Transaction id has to be unique ->setSourceOfFunds(new SourceOfFundsCard(new Card("CARD_NUMBER", "EXP_MONTH", "EXP_YEAR", "CVC"))) // Self explanatory, year is 2-digit ->send(); if ( ! empty($error = $result->getError()) ) { // Something went wrong, log it die($error); } // Successful, save order id, transaction id
AUTHORIZE
$result = (new AuthorizeRequest("MERCHANT_ID")) // Provided by gateway ->setApiPassword("API_PASSWORD") // Provided by gateway ->setOrder(new Order("SOME_ORDER_ID", 55.55, "AUD")) // Order id has to be unique, amount in money format, AUD is the only one supported now ->setTransaction(new Transaction("SOME_TRANSACTION_ID")) // Transaction id has to be unique ->setSourceOfFunds(new SourceOfFundsCard(new Card("CARD_NUMBER", "EXP_MONTH", "EXP_YEAR", "CVC"))) // Self explanatory, year is 2-digit ->send(); if ( ! empty($error = $result->getError()) ) { // Something went wrong, log it die($error); } // Successful, save order id, transaction id
VOID
$result = (new VoidRequest("MERCHANT_ID")) // Provided by gateway ->setApiPassword("API_PASSWORD") // Provided by gateway ->setOrder(new Order("SOME_ORDER_ID")) // Original order id ->setTransaction(new Transaction("SOME_TRANSACTION_ID")) // New transaction id to be created, has to be unique ->setOldTransaction(new Transaction(("OLD_TRANSACTION_ID")) // Original transaction id ->send(); if ( ! empty($error = $result->getError()) ) { // Something went wrong, log it die($error); } // Successful, save order id, transaction id
CAPTURE
$result = (new CaptureRequest("MERCHANT_ID")) // Provided by gateway ->setApiPassword("API_PASSWORD") // Provided by gateway ->setOrder(new Order("SOME_ORDER_ID")) // Original order id ->setTransaction(new Transaction("SOME_TRANSACTION_ID")) // New transaction id to be created, has to be unique ->setOldTransaction(new Transaction("OLD_TRANSACTION_ID", 55.55, "AUD")) // Original transaction id, amount to capture in money format, AUD is the only one supported now ->send(); if ( ! empty($error = $result->getError()) ) { // Something went wrong, log it die($error); } // Successful, save order id, transaction id
REFUND
$result = (new RefundRequest("MERCHANT_ID")) // Provided by gateway ->setApiPassword("API_PASSWORD") // Provided by gateway ->setOrder(new Order("SOME_ORDER_ID")) // Original order id ->setTransaction(new Transaction("SOME_TRANSACTION_ID")) // New transaction id to be created, has to be unique ->setOldTransaction(new Transaction("OLD_TRANSACTION_ID", 55.55, "AUD")) // Original transaction id, amount to refund in money format, AUD is the only one supported now ->send(); if ( ! empty($error = $result->getError()) ) { // Something went wrong, log it die($error); } // Successful, save order id, transaction id
Test mode
Just add "TEST" to your merchant id if it's not already here, or call setTestMode(true) method for any request called.
atdev/commweb 适用场景与选型建议
atdev/commweb 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 292 次下载、GitHub Stars 达 4, 最近一次更新时间为 2017 年 05 月 16 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「commweb」 「commbank」 「commonwealthbank」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 atdev/commweb 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 atdev/commweb 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 atdev/commweb 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Includes Omnipay payment processing library and all officially supported gateways
Alipay gateway for Omnipay payment processing library
A framework agnostic, multi-gateway payment processing library
A version of adrianmacneil/omnipay (omnipay/omnipay on packagist) which is included in the WordPress OmniPay Payment Gateway Plugin by Davelopware
统计信息
- 总下载量: 292
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 4
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-05-16