添加可计费项目
请求参数
参数 | 类型 | 说明 | 必需的 |
---|---|---|---|
action | string | “AddBillableItem” | Required |
clientid | int | 要将项目添加到的客户端。 | Required |
description | string | 可计费项目的说明。这将出现在发票上。 | Required |
amount | float | 开票的总数量。 | Required |
unit | string | 或者‘hours’ or ‘quantity’。 | Required |
quantity | float | 可计费项目所代表的单位数。默认为 0。 | Optional |
invoiceaction | string | ‘noinvoice’, ‘nextcron’, ‘nextinvoice’, ‘duedate’, or ‘recur’ 之一。 | Optional |
recur | int | 当 $invoiceaction=recur 。复发的频率。 |
Optional |
recurcycle | string | 重复计费项目的频率。天、周、月或年。 | Optional |
recurfor | int | 可计费项目应创建发票的次数。 | Optional |
duedate | string | 发票应到期的日期(仅适用于到期日和重复发票操作)。 YYYY-mm-dd | Optional |
响应参数
参数 | 类型 | 说明 |
---|---|---|
result | string | 操作结果:成功或错误 |
billableid | int | 新创建的计费项目的 ID。 |
示例请求 (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' => 'AddBillableItem',
// See https://developers.whmcs.com/api/authentication
'username' => 'IDENTIFIER_OR_ADMIN_USERNAME',
'password' => 'SECRET_OR_HASHED_PASSWORD',
'clientid' => '1',
'description' => 'This is a billable item',
'amount' => '10.00',
'invoiceaction' => 'recur',
'recur' => '1',
'recurcycle' => 'Months',
'recurfor' => '12',
'duedate' => '2021-01-01',
'responsetype' => 'json',
)
)
);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($ch);
curl_close($ch);
示例请求(本地 API)
$command = 'AddBillableItem';
$postData = array(
'clientid' => '1',
'description' => 'This is a billable item',
'amount' => '10.00',
'invoiceaction' => 'recur',
'recur' => '1',
'recurcycle' => 'Months',
'recurfor' => '12',
'duedate' => '2021-01-01',
);
$adminUsername = 'ADMIN_USERNAME'; // Optional for WHMCS 7.2 and later
$results = localAPI($command, $postData, $adminUsername);
print_r($results);
示例响应 JSON
{
"status": "success",
"billableid": 1
}
错误响应
可能的错误条件响应包括:
- 未找到客户 ID
- 您必须提供说明
- 无效的发票操作
- Recurring 必须有单位、周期和限制
- 截止日期为必填项
- 单位无效,请指定‘hours’ or ‘quantity’
- 无效的日期格式 - 预期:“YYYY-mm-dd”
相关用法
- PHP WHMCS AddBannedIp用法及代码示例
- PHP WHMCS AddonUnsuspended用法及代码示例
- PHP WHMCS AddContact用法及代码示例
- PHP WHMCS AddUser用法及代码示例
- PHP WHMCS AddonAdd用法及代码示例
- PHP WHMCS AddonTerminated用法及代码示例
- PHP WHMCS AddPayMethod用法及代码示例
- PHP WHMCS AddonFraud用法及代码示例
- PHP WHMCS AddTransaction用法及代码示例
- PHP WHMCS AddCancelRequest用法及代码示例
- PHP WHMCS AddonDeleted用法及代码示例
- PHP WHMCS AddonActivated用法及代码示例
- PHP WHMCS AddOrder用法及代码示例
- PHP WHMCS AddonSuspended用法及代码示例
- PHP WHMCS AddInvoicePayment用法及代码示例
- PHP WHMCS AddAnnouncement用法及代码示例
- PHP WHMCS AddonConfigSave用法及代码示例
- PHP WHMCS AddonConfig用法及代码示例
- PHP WHMCS AddClient用法及代码示例
- PHP WHMCS AddonRenewal用法及代码示例
- PHP WHMCS AddCredit用法及代码示例
- PHP WHMCS AddProjectTask用法及代码示例
- PHP WHMCS AddTicketNote用法及代码示例
- PHP WHMCS AddProjectMessage用法及代码示例
- PHP WHMCS AddonActivation用法及代码示例
注:本文由纯净天空筛选整理自whmcs.com大神的英文原创作品 AddBillableItem。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。