payfast/payfast-common
Composer 安装命令:
composer require payfast/payfast-common
包简介
Payfast common class for modules.
README 文档
README
Payfast common class for modules
This is the Payfast common class for modules.
Installation
You can install this module using composer:
composer require payfast/payfast-common
Aggregator
Module parameters for pfValidData()
Declare the relevant $moduleInfo values when using the pfValidData() method, for example:
$moduleInfo = [
"pfSoftwareName" => 'OpenCart',
"pfSoftwareVer" => '4.0.2.0',
"pfSoftwareModuleName" => 'PF_OpenCart',
"pfModuleVer" => '2.3.1',
];
$pfValid = $payfastCommon->pfValidData($moduleInfo, $pfHost, $pfParamString);
Debug Mode
Configure debug mode by passing true|false when instantiating the Payfast\PayfastCommon\Aggregator\Request\PaymentRequest class.
$aggregatorPaymentRequest = new Payfast\PayfastCommon\Aggregator\Request\PaymentRequest(true);
Breaking Changes since v1.2.0
Namespace Changes: Payfast → Aggregator
The namespaces for several core classes have been updated to improve consistency and better align with the library's purpose. This requires updating your imports to reflect the new structure.
Class Renames
To enhance clarity and maintain consistency, some classes have been renamed. Make sure to update your code to reference the new class names.
Example of Correct and Incorrect Usage:
Correct
use Payfast\PayfastCommon\Aggregator\Request\PaymentRequest; $paymentRequest = new PaymentRequest($testMode);
Incorrect
use Payfast\PayfastCommon\PayfastCommon; $payfastCommon = new PayfastCommon($testMode);
Breaking Changes since v1.1.0
We have migrated from static to instance methods for the Aggregator PaymentRequest class.
For example, prior to v1.1.0 we used:
// Debug mode
define('PF_DEBUG', true);
// Module parameters for pfValidData
define('PF_SOFTWARE_NAME', 'GravityForms');
define('PF_SOFTWARE_VER', '2.8.7');
define('PF_MODULE_NAME', 'PayFast-GravityForms');
define('PF_MODULE_VER', '1.5.4');
// Calling methods on Payfast\PayfastCommon\Aggregator\Request\PaymentRequest
$pfData = PaymentRequest::pfGetData();
PaymentRequest::pflog('Verify data received');
But this has now become:
// Debug mode
$aggregatorPaymentRequest = new PaymentRequest(true);
// Module parameters for pfValidData
$moduleInfo = [
"pfSoftwareName" => 'GravityForms',
"pfSoftwareVer" => '2.8.7',
"pfSoftwareModuleName" => 'PayFast-GravityForms',
"pfModuleVer" => '1.5.4',
];
$pfValid = $aggregatorPaymentRequest->pfValidData($moduleInfo, $pfHost, $pfParamString);
// Calling methods on Payfast\PayfastCommon\Aggregator\Request\PaymentRequest
$pfData = $aggregatorPaymentRequest->pfGetData();
$aggregatorPaymentRequest->pflog('Verify data received');
Gateway
Usage examples
Payment Initiate
try { $paymentRequest = new PaymentRequest($merchantId, $encryptionKey); $response = $paymentRequest->initiate($data); } catch (Exceptione $e) { echo 'Error initiating payment: ' . $e->getMessage(); }
Redirect to Gateway
echo $paymentRequest->getRedirectHTML($payRequestId, $checksum);
Query Transaction
try { $paymentRequest = new PaymentRequest($merchantId, $encryptionKey); $response = $paymentRequest->query($payRequestId, $reference); } catch (Exceptione $e) { echo 'Error querying transaction: ' . $e->getMessage(); }
payfast/payfast-common 适用场景与选型建议
payfast/payfast-common 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 4.43k 次下载、GitHub Stars 达 1, 最近一次更新时间为 2023 年 02 月 01 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 payfast/payfast-common 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 payfast/payfast-common 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 4.43k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 2
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: GPL-3.0
- 更新时间: 2023-02-01