添加可計費項目
請求參數
參數 | 類型 | 說明 | 必需的 |
---|---|---|---|
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。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。