devscast/flexpay
Composer 安装命令:
composer require devscast/flexpay
包简介
FlexPay API PHP Client
README 文档
README
For privacy reasons, Flexpay original documentation cannot be shared without written permission, for more information about credentials and implementation details, please reach them at flexpay.cd
Installation
You can use the PHP client by installing the Composer package and adding it to your application’s dependencies:
composer require devscast/flexpay
Usage
Authentication
- Step 1. Contact Flexpay to get a Merchant Account You will receive a Merchant Form to complete in order to provide your business details and preferred Cash out Wallet or Banking Details.
- Step 2. Once the paperwork is completed, you will be issued with Live and Sandbox Accounts (Merchant Code and Authorization token)
Then use these credentials to authenticate your client
use Devscast\Flexpay\Client as Flexpay; use Devscast\Flexpay\Credential; use Devscast\Flexpay\Environment; $flexpay = new Flexpay( new Credential('token', 'merchant_code'), Environment::SANDBOX // use Environment::LIVE for production );
Create a Payment Request
use Devscast\Flexpay\Data\Currency; use Devscast\Flexpay\Request\CardRequest; use Devscast\Flexpay\Request\MobileRequest; $mobile = new MobileRequest( amount: 10, // 10 USD currency: Currency::USD, phone: "243999999999", reference: "your_unique_transaction_reference", description: "your_transaction_description", callbackUrl: "your_website_webhook_url", ); $card = new CardRequest( amount: 10, // 10 USD currency: Currency::USD, reference: "your_unique_transaction_reference", description: "your_transaction_description", callbackUrl: "your_website_webhook_url", homeUrl: "your_website_home_url", )
Note: we highly recommend your
callbacksurls to be unique for each transaction.
Mobile Payment
Once called, Flexpay will send a payment request to the user's mobile money account, and the user will have to confirm the payment on their phone. after that the payment will be processed and the callback url will be called with the transaction details.
$response = $flexpay->pay($mobile);
Visa Card Payment
You can set up card payment via VPOS features, which is typically used for online payments. it's a gateway that allows you to accept payments from your customers using their credit cards.
$response = $flexpay->pay($card); // redirect to $response->url to complete the payment
handling callback (callbackUrl, approveUrl, cancelUrl, declineUrl)
Flexpay will send a POST request to the defined callbackUrl and the response will contain the transaction details. you can use the following code to handle the callback by providing incoming data as array.
$state = $flexpay->handleCallback($_POST); $state->isSuccessful(); // true or false
Check Transaction state
You don't trust webhook ? you can always check the transaction state by providing the order number.
$state = $flexpay->check($payment->orderNumber); $state->isSuccessful(); // true or false
devscast/flexpay 适用场景与选型建议
devscast/flexpay 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 3.28k 次下载、GitHub Stars 达 7, 最近一次更新时间为 2024 年 05 月 06 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「api」 「payment gateway」 「mobile money」 「flexpay」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 devscast/flexpay 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 devscast/flexpay 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 devscast/flexpay 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
repository php library
Payyo Gateway for the Omnipay payment processing library
A PSR-7 compatible library for making CRUD API endpoints
Client library to send SMS using Comilio SMS Gateway API (https://www.comilio.it)
GovPayNet driver for the Omnipay payment processing library
BlueSnap driver for the Omnipay payment processing library
统计信息
- 总下载量: 3.28k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 7
- 点击次数: 10
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-05-06