cashmos/cashmos-php-api
Composer 安装命令:
composer require cashmos/cashmos-php-api
包简介
Online Payment Processor
README 文档
README
The is the official PHP SDK for Cashmos Payment Processing.
Installation
The SDK can be easily installed using composer. To install, run the following command on your terminal or command prompt on Windows (make sure composer is installed and available in your project directory).
composer require cashmos/cashmos-php-api
If you don't want to use composer, you may directly download a zip file from among the releases.
Authentication & Cashmos Services
To consume any of the services offered by this SDK, you'll need the
client id and secret for your business account. These can be viewed under the
API tab of your business screen of Cashmos online.
Create a business at Cashmos.com if
you don't already have an account.
$cashmos = new Cashmos\Cashmos($clientId, $secret);
Order Processing
Use the following steps to process an order with Cashmos:
I. Create an order:
$order = new Cashmos\Services\Order\Order(); // Add items to order $order->addItem( new Cashmos\Services\Order\Item($name, $unitPrice, $quantity, $description), ); $order->addItem( new Cashmos\Services\Order\Item($name2, $unitPrice2, $quantity2, $description2), ); // Set order total. // Note that this is the total amount to be charged to the user. // Cashmos does not do any item level calculations for total amount. $order->setOrderTotal($orderTotal) // You can add any custom data to the order which // could be retrieved later after confirmation. // This may be information used to identify the customer // making the order, etc. $customData = [ 'foo' => 'bar' ]; $order->addCustomData($customData); // Set return and cancel urls $order->returnUrl('https://business.com/paid'); // Url when payment authorization was successful. $order->cancelUrl('https://business.com/canceled'); // Url when payment authorization was canceled.
II. Process Order Authorization:
This step allows the user to choose their payment method and provide authorization for the purchase. However, the user's is NOT actually charged. Use the next step to confirm the order and actually charge the user.
$cashmos = new Cashmos\Cashmos($clientId, $secret); $cashmos->process($order);
If the user authorizes the payment, Cashmos will return to the "returnUrl" provided with a payment token as a query parameter (?token="random-token"). This payment token is used to confirm the payment.
III. Confirm Order:
$confirmation = new Cashmos\Services\Order\OrderConfirmation($token); $cashmos = new Cashmos\Cashmos($clientId, $secret); if($cashmos->process($confirmation)){ // Order confirmed successfully. // You can get any custom data after the order is confirmed. $customData = $confirmation->getCustomData(); }else{ // There was an error with order confirmation echo $cashmos->getError(); }
Prerequisites
Security Vulnerabilities
If you discover a security vulnerability in this API, please email the details of the vulnerability to technical@omnile.com.
License
cashmos/cashmos-php-api 适用场景与选型建议
cashmos/cashmos-php-api 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 240 次下载、GitHub Stars 达 0, 最近一次更新时间为 2019 年 06 月 21 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 cashmos/cashmos-php-api 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 cashmos/cashmos-php-api 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 240
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 2
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-06-21