lscuderi/ tpay
T-Pay PHPLib
Requires
- php: ^7.4 || ^8.0
Requires (Dev)
- phpstan/phpstan: ^1.9
This package is auto-updated.
Last update: 2024-09-28 10:39:07 UTC
README
版本控制
此客户端API库使用Payrexx的1.0.0版本API。如果您遇到问题,请确保您正在使用正确的库版本!
要求
我们推荐使用PHP版本 >= 5.4
以下php模块是必需的:cURL
开始使用PAYREXX
如果您还没有使用Composer,那么您可能需要阅读安装指南https://composer.php.ac.cn/download/。
请通过Composer将此库包含在您的composer.json中,并执行composer update以刷新autoload.php。
对于最新库版本,您可以在composer.json中使用以下内容
{
"require": {
"payrexx/payrexx": "dev-master"
}
}
对于版本1.0.0,您可以在composer.json中使用以下内容
{
"require": {
"payrexx/payrexx": "1.0.0"
}
}
-
使用以下参数实例化payrexx类:$instance:您的Payrexx实例名称。(例如,实例名称'demo',您请求您的Payrexx实例https://demo.payrexx.com $apiSecret:这是您的API密钥,您可以在实例的管理中找到。
$payrexx = new \Payrexx\Payrexx($instance, $apiSecret);
-
使用API参考中描述的参数实例化模型类
$subscription = new \Payrexx\Models\Request\Subscription(); $subscription->setId(1);
-
使用您想要的函数
$response = $payrexx->cancel($subscription); $subscriptionId = $response->getId();
建议将其包装在"try/catch"中以处理异常,如下所示
try{ $response = $payrexx->cancel($subscription); $subscriptionId = $response->getId(); }catch(\Payrexx\PayrexxException $e){ //Do something with the error informations below $e->getCode(); $e->getMessage(); }
平台API
当与平台账户一起使用时,您需要在实例化客户端时指定您的自定义域名作为API基本URL。
$apiBaseDomain = 'your.domain.com'; $payrexx = new \Payrexx\Payrexx( $instance, $apiSecret, Communicator::DEFAULT_COMMUNICATION_HANDLER, $apiBaseDomain );
$instance仍然需要设置为唯一域名的子域部分。例如,在client.platform.yourcompany.com登录的平台账户,$instance设置为client,$apiBaseDomain设置为platform.yourcompany.com。
文档
有关更多信息,请参阅官方REST API参考:https://developers.payrexx.com/v1.0/reference