当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


PHP WHMCS GetTransactions用法及代码示例


获取符合通过条件的交易

请求参数

参数 类型 说明 必需的
action string “GetTransactions” Required
invoiceid int 获取特定发票 ID 的交易 Optional
clientid int 查找特定客户 ID 的交易 Optional
transid string 查找特定交易 ID 的交易 Optional

响应参数

参数 类型 说明
result string 操作结果:成功或错误
totalresults int 可用结果总数
startnumber int 返回结果的起始编号
numreturned int 返回的结果数
transactions array 与传递的条件匹配的事务数组

示例请求 (CURL)

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://www.example.com/includes/api.php');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,
    http_build_query(
        array(
            'action' => 'GetTransactions',
            // See https://developers.whmcs.com/api/authentication
            'username' => 'IDENTIFIER_OR_ADMIN_USERNAME',
            'password' => 'SECRET_OR_HASHED_PASSWORD',
            'clientid' => '1',
            'responsetype' => 'json',
        )
    )
);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($ch);
curl_close($ch);

示例请求(本地 API)

$command = 'GetTransactions';
$postData = array(
    'clientid' => '1',
);
$adminUsername = 'ADMIN_USERNAME'; // Optional for WHMCS 7.2 and later

$results = localAPI($command, $postData, $adminUsername);
print_r($results);

示例响应 JSON

{
    "result": "success",
    "totalresults": 1,
    "startnumber": 0,
    "numreturned": 1,
    "transactions": {
        "transaction": [
            {
                "id": "10",
                "userid": "1",
                "currency": "0",
                "gateway": "paypal",
                "date": "2016-01-01 06:41:11",
                "description": "Invoice Payment",
                "amountin": "45.90",
                "fees": "0.00",
                "amountout": "0.00",
                "rate": "1.00000",
                "transid": "1479732071aad259f3513ec",
                "invoiceid": "59",
                "refundid": "0"
            }
        ]
    }
}

相关用法


注:本文由纯净天空筛选整理自whmcs.com大神的英文原创作品 GetTransactions。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。