Constructor
new Billing(config)
Parameters:
Name |
Type |
Description |
config |
Object
|
Object containing your API credentials.
Properties
Name |
Type |
Attributes |
Description |
serverUrl |
string
|
|
URL to your installation. Remember to point to /includes/api.php |
username |
string
|
<optional>
|
|
password |
string
|
<optional>
|
|
identifier |
string
|
<optional>
|
|
secret |
string
|
<optional>
|
|
|
- Source:
Extends
Methods
acceptQuote(opts)
Accepts a quote - https://developers.whmcs.com/api-reference/acceptquote/
Parameters:
Name |
Type |
Description |
opts |
Object
|
Properties
Name |
Type |
Description |
quoteid |
Number
|
The quote id to be accepted and converted to an invoice |
|
- Source:
addBillableItem(opts)
Adds a Billable Item - https://developers.whmcs.com/api-reference/addbillableitem/
Parameters:
Name |
Type |
Description |
opts |
Object
|
Properties
Name |
Type |
Attributes |
Description |
clientid |
Number
|
|
The client to add the item to |
description |
String
|
|
The description of the Billable Item. This will appear on the invoice |
amount |
Number
|
|
the total amount to invoice for |
invoiceaction |
String
|
<optional>
|
One of ‘noinvoice’, ‘nextcron’, ‘nextinvoice’, ‘duedate’, ‘recur’ |
recur |
Number
|
<optional>
|
When $invoiceaction=recur. The frequency of the recurrence. |
recurcycle |
String
|
<optional>
|
How often to recur the Billable Item. Days, Weeks, Months or Years. |
recurfor |
Number
|
<optional>
|
How many times the Billable Item should create an invoice. |
duedate |
String
|
<optional>
|
Date the invoice should be due (only required for duedate & recur invoice actions). YYYY-mm-dd |
hours |
Number
|
<optional>
|
number of hours/quantity the item corresponds to. (not required for single quantities) |
|
- Source:
addCredit(opts)
Adds credit to a given client. - https://developers.whmcs.com/api-reference/addcredit/
Parameters:
Name |
Type |
Description |
opts |
Object
|
Properties
Name |
Type |
Description |
clientid |
Number
|
|
description |
String
|
Admin only notes for credit justification |
amount |
Number
|
|
|
- Source:
addInvoicePayment(opts)
Adds payment to a given invoice. - https://developers.whmcs.com/api-reference/addinvoicepayment/
Parameters:
Name |
Type |
Description |
opts |
Object
|
Properties
Name |
Type |
Attributes |
Description |
invoiceid |
Number
|
|
|
transid |
String
|
|
The unique transaction id that should be applied to the payment |
gateway |
String
|
|
the gateway used in system name format, eg. paypal, authorize |
date |
String
|
<optional>
|
The date that the payment should have assigned. Format: YYYY-MM-DD HH:mm:ss |
amount |
Number
|
<optional>
|
the amount paid, can be left undefined to take full amount of invoice |
fees |
Number
|
<optional>
|
the amount of the payment that was taken as a fee by the gateway |
noemail |
Boolean
|
<optional>
|
set to true to not send an email for the invoice payment |
|
- Source:
addTransaction(opts)
Add a transaction to the system - https://developers.whmcs.com/api-reference/addtransaction/
Parameters:
Name |
Type |
Description |
opts |
Object
|
Properties
Name |
Type |
Attributes |
Description |
paymentmethod |
String
|
|
The payment method of the transaction in system format |
userid |
Number
|
<optional>
|
The ID of the user to apply the transaction to |
invoiceid |
Number
|
<optional>
|
The ID of the invoice the transaction is for |
transid |
String
|
<optional>
|
The unique transaction id for this payment |
date |
String
|
<optional>
|
The date of the transaction in your Localisation Format (eg DD/MM/YYYY) |
currencyid |
Number
|
<optional>
|
The currency id for the transaction if not associated with a user |
description |
String
|
<optional>
|
The description of the transaction |
amountin |
Number
|
<optional>
|
The amount received by the payment |
fees |
Number
|
<optional>
|
The amount of fee charged on the transaction by the merchant - This can be negative |
amountout |
Number
|
<optional>
|
The amount paid out by the payment |
rate |
Number
|
<optional>
|
The exchange rate for the payment based on the default currency |
credit |
Boolean
|
<optional>
|
Should the payment be applied to credit on the client account. Invoice ID must not be provided. |
|
- Source:
applyCredit(opts)
Applies the Client’s Credit to an invoice - https://developers.whmcs.com/api-reference/applycredit/
Parameters:
Name |
Type |
Description |
opts |
Object
|
Properties
Name |
Type |
Attributes |
Description |
invoiceid |
Number
|
|
The ID of the invoice to apply credit |
amount |
Number
|
<optional>
|
string |
noemail |
Boolean
|
<optional>
|
Set to true to stop the invoice payment email being sent if the invoice becomes paid |
|
- Source:
capturePayment(opts)
Attempt to capture a payment on an unpaid CC Invoice - https://developers.whmcs.com/api-reference/capturepayment/
Parameters:
Name |
Type |
Description |
opts |
Object
|
Properties
Name |
Type |
Attributes |
Description |
invoiceid |
Number
|
|
The ID of the pending order |
cvv |
|
<optional>
|
string The CVV Number for the card being attempted |
|
- Source:
createInvoice(opts)
Create an invoice using the provided parameters. - https://developers.whmcs.com/api-reference/createinvoice/
Parameters:
Name |
Type |
Description |
opts |
Object
|
Properties
Name |
Type |
Attributes |
Description |
userid |
Number
|
|
The ID of the client to close |
status |
String
|
<optional>
|
The status of the invoice being created (Defaults to Unpaid) |
draft |
Boolean
|
<optional>
|
Should the invoice be created in draft status (No need to pass $status also) |
sendinvoice |
Boolean
|
<optional>
|
Should the Invoice Created Email be sent to the client (cannot be used with $draft) |
paymentmethod |
String
|
<optional>
|
The payment method of the created invoice in system format |
taxrate |
Number
|
<optional>
|
The first level tax rate to apply to the invoice to override the system default |
taxrate2 |
Number
|
<optional>
|
The second level tax rate to apply to the invoice to override the system default |
date |
String
|
<optional>
|
The date that the invoice should show as created YYYY-mm-dd |
duedate |
String
|
<optional>
|
The due date of the newly created invoice YYYY-mm-dd |
notes |
String
|
<optional>
|
The notes to appear on the created invoice |
itemdescriptionx |
String
|
<optional>
|
The line items description X is an integer to add multiple invoice items |
itemamountx |
Number
|
<optional>
|
The line items amount |
itemtaxedx |
Boolean
|
<optional>
|
The line items is taxed value |
autoapplycredit |
Boolean
|
<optional>
|
Should credit on the client account be automatically applied to the invoice |
|
- Source:
createQuote(opts)
Creates a new quote - https://developers.whmcs.com/api-reference/createquote/
Parameters:
Name |
Type |
Description |
opts |
Object
|
Properties
Name |
Type |
Attributes |
Description |
subject |
String
|
|
The subject of the new quote |
stage |
String
|
|
The current stage of the quote (‘Draft’,‘Delivered’,‘On Hold’,‘Accepted’,‘Lost’,‘Dead’) |
validuntil |
String
|
|
The date the quote is valid until in localised format (eg DD/MM/YYYY) |
datecreated |
String
|
<optional>
|
The date the quote was created in localised format (eg DD/MM/YYYY) |
lineitems |
Array
|
<optional>
|
A base64 encoded serialized array containing the following keys: |
lineitems[x][desc] |
String
|
<optional>
|
For $lineitems. The description of the line item |
lineitems[x][qty] |
Number
|
<optional>
|
For $lineitems. The quantity of the line item being quoted for |
lineitems[x][up] |
Number
|
<optional>
|
For $lineitems. The Unit Price of the line item |
lineitems[x][discount] |
Number
|
<optional>
|
For $lineitems. The amount of discount to provide on the line items |
lineitems[x][taxable] |
Boolean
|
<optional>
|
For $lineitems. Is the line item taxable |
userid |
Number
|
<optional>
|
If the quote is for an exising client, the client ID the quote is for |
firstname |
String
|
<optional>
|
The first name of the client the quote is for if no $userid |
lastname |
String
|
<optional>
|
The last name of the client the quote is for if no $userid |
companyname |
String
|
<optional>
|
The company of the client the quote is for if no $userid |
email |
String
|
<optional>
|
The email address of the client the quote is for if no $userid |
address1 |
String
|
<optional>
|
The address1 of the client the quote is for if no $userid |
address2 |
String
|
<optional>
|
The address2 of the client the quote is for if no $userid |
city |
String
|
<optional>
|
The city of the client the quote is for if no $userid |
state |
String
|
<optional>
|
The state of the client the quote is for if no $userid |
country |
String
|
<optional>
|
The country of the client the quote is for if no $userid |
phonenumber |
String
|
<optional>
|
The phone number of the client (no country code) the quote is for if no $userid. Local format eg 4035551234 |
tax_id |
String
|
<optional>
|
The tax id of the client |
currency |
Number
|
<optional>
|
The id of the currency for the quote is for if no $userid |
proposal |
String
|
<optional>
|
The proposal text displayed to the end user |
customernotes |
String
|
<optional>
|
The notes on the quote displayed to the end user |
adminnotes |
String
|
<optional>
|
The notes on the quote displayed to the staff only |
|
- Source:
deleteQuote(opts)
Removes a quote from the system. This cannot be undone - https://developers.whmcs.com/api-reference/deletequote/
Parameters:
Name |
Type |
Description |
opts |
Object
|
Properties
Name |
Type |
Description |
quoteid |
Number
|
The quote id to be deleted |
|
- Source:
genInvoices(opts)
Generate any invoices that are due to be generated - https://developers.whmcs.com/api-reference/geninvoices/
Parameters:
Name |
Type |
Description |
opts |
Object
|
Properties
Name |
Type |
Attributes |
Description |
noemails |
Boolean
|
<optional>
|
Stop any invoice created emails being sent |
clientid |
Number
|
<optional>
|
Pass to generate invoices only for a single client id |
serviceids |
Array.<Number>
|
<optional>
|
An array of service ids to generate invoices for |
domainids |
Array.<Number>
|
<optional>
|
An array of domain ids to generate invoices for |
addonids |
Array.<Number>
|
<optional>
|
An array of addon ids to generate invoices for |
|
- Source:
getCredits(opts)
Obtain the Credit Log for a Client Account - https://developers.whmcs.com/api-reference/getcredits/
Parameters:
Name |
Type |
Description |
opts |
Object
|
Properties
Name |
Type |
Description |
clientid |
Number
|
The Client to obtain the log for |
|
- Source:
getInvoice(opts)
Retrieve a specific invoice - https://developers.whmcs.com/api-reference/getinvoice/
Parameters:
Name |
Type |
Description |
opts |
Object
|
Properties
Name |
Type |
Description |
invoiceid |
Number
|
The ID of the invoice to retrieve |
|
- Source:
getInvoices(opts)
Retrieve a list of invoices. - https://developers.whmcs.com/api-reference/getinvoices/
Parameters:
Name |
Type |
Description |
opts |
Object
|
Properties
Name |
Type |
Attributes |
Description |
limitstart |
Number
|
<optional>
|
The offset for the returned invoice data (default: 0) |
limitnum |
Number
|
<optional>
|
The number of records to return (default: 25) |
userid |
Number
|
<optional>
|
Find invoices for a specific client id |
status |
String
|
<optional>
|
Find invoices for a specific status. Standard Invoice statuses plus Overdue |
orderby |
String
|
<optional>
|
The field to sort results by. Accepted values are: id, invoicenumber, date, duedate, total, status |
order |
String
|
<optional>
|
Order sort attribute. Accepted values are: asc or desc. |
|
- Source:
getQuotes(opts)
Obtain quotes matching the passed criteria - https://developers.whmcs.com/api-reference/getquotes/
Parameters:
Name |
Type |
Description |
opts |
Object
|
Properties
Name |
Type |
Attributes |
Description |
limitstart |
Number
|
<optional>
|
The offset for the returned quote data (default: 0) |
limitnum |
Number
|
<optional>
|
The number of records to return (default: 25) |
quoteid |
Number
|
<optional>
|
Obtain a specific quote id |
userid |
Number
|
<optional>
|
Find quotes for a specific client id |
subject |
String
|
<optional>
|
Find quotes for a specific subject |
stage |
String
|
<optional>
|
Find quotes for a specific stage (‘Draft’,‘Delivered’,‘On Hold’,‘Accepted’,‘Lost’,‘Dead’) |
datecreated |
String
|
<optional>
|
Find quotes for a specific created date. Format: Y-m-d |
lastmodified |
String
|
<optional>
|
Find quotes for a specific last modified date. Format: Y-m-d |
validuntil |
String
|
<optional>
|
Find quotes for a specific valid until date. Format: Y-m-d |
|
- Source:
getTransactions(opts)
Obtain transactions matching the passed criteria - https://developers.whmcs.com/api-reference/gettransactions/
Parameters:
Name |
Type |
Description |
opts |
Object
|
Properties
Name |
Type |
Attributes |
Description |
invoiceid |
Number
|
<optional>
|
Obtain transactions for a specific invoice id |
clientid |
Number
|
<optional>
|
Find transactions for a specific client id |
transid |
String
|
<optional>
|
Find transactions for a specific transaction id |
|
- Source:
sendQuote(opts)
Send a quote to the associated client - https://developers.whmcs.com/api-reference/sendquote/
Parameters:
Name |
Type |
Description |
opts |
Object
|
Properties
Name |
Type |
Description |
quoteid |
Number
|
The id of the quote to send |
|
- Source:
updateInvoice(opts)
Update an invoice using the provided parameters. - https://developers.whmcs.com/api-reference/updateinvoice/
Parameters:
Name |
Type |
Description |
opts |
Object
|
Properties
Name |
Type |
Attributes |
Description |
invoiceid |
Number
|
|
The ID of the invoice to update |
status |
String
|
<optional>
|
The status of the invoice being |
paymentmethod |
String
|
<optional>
|
The payment method of the invoice in system format |
taxrate |
Number
|
<optional>
|
The first level tax rate to apply to the invoice to override the system default |
taxrate2 |
Number
|
<optional>
|
The second level tax rate to apply to the invoice to override the system default |
subtotal |
Number
|
<optional>
|
Update the subtotal of the invoice |
total |
Number
|
<optional>
|
Update the total of the invoice |
credit |
Number
|
<optional>
|
Update the credit applied to the invoice |
date |
String
|
<optional>
|
The date that the invoice should show as created YYYY-mm-dd |
duedate |
String
|
<optional>
|
The due date of the invoice YYYY-mm-dd |
datepaid |
String
|
<optional>
|
The date paid of the invoice YYYY-mm-dd |
notes |
String
|
<optional>
|
The notes to appear on the invoice |
itemdescription |
Array.<String>
|
<optional>
|
An array of lineItemId => Description of items to change |
itemamount |
Array.<Number>
|
<optional>
|
An array of lineItemId => amount of items to change |
itemtaxed |
Array.<Boolean>
|
<optional>
|
An array of lineItemId => taxed of items to change |
newitemdescription |
Array.<String>
|
<optional>
|
The line items description |
newitemamount |
Array.<Number>
|
<optional>
|
The line items amount |
newitemtaxed |
Array.<Boolean>
|
<optional>
|
The line items is taxed value |
deletelineids |
Array.<Number>
|
<optional>
|
An array of line item ids to remove from the invoice |
publish |
Boolean
|
<optional>
|
Publish the invoice |
publishandsendemail |
Boolean
|
<optional>
|
Publish and email the invoice |
|
- Source:
updateQuote(opts)
Updates an existing quote - https://developers.whmcs.com/api-reference/updatequote/
Parameters:
Name |
Type |
Description |
opts |
Object
|
Properties
Name |
Type |
Attributes |
Description |
quoteid |
Number
|
|
The ID of the quote to update |
subject |
String
|
<optional>
|
The subject of the quote |
stage |
String
|
<optional>
|
The current stage of the quote (‘Draft’,‘Delivered’,‘On Hold’,‘Accepted’,‘Lost’,‘Dead’) |
validuntil |
String
|
<optional>
|
The date the quote is valid until in localised format (eg DD/MM/YYYY) |
datecreated |
String
|
<optional>
|
The date the quote was created in localised format (eg DD/MM/YYYY) |
lineitems |
Array
|
<optional>
|
A base64 encoded serialized array containing the following keys: |
lineitems[x][id] |
Number
|
<optional>
|
For $lineitems. The id of an existing line item. Omit for new lines |
lineitems[x][desc] |
String
|
<optional>
|
For $lineitems. The description of the line item |
lineitems[x][qty] |
Number
|
<optional>
|
For $lineitems. The quantity of the line item being quoted for |
lineitems[x][up] |
Number
|
<optional>
|
For $lineitems. The Unit Price of the line item |
lineitems[x][discount] |
Number
|
<optional>
|
For $lineitems. The amount of discount to provide on the line items |
lineitems[x][taxable] |
Boolean
|
<optional>
|
For $lineitems. Is the line item taxable |
userid |
Number
|
<optional>
|
If the quote is for an exising client, the client ID the quote is for |
firstname |
String
|
<optional>
|
The first name of the client the quote is for if no $userid |
lastname |
String
|
<optional>
|
The last name of the client the quote is for if no $userid |
companyname |
String
|
<optional>
|
The company of the client the quote is for if no $userid |
email |
String
|
<optional>
|
The email address of the client the quote is for if no $userid |
address1 |
String
|
<optional>
|
The address1 of the client the quote is for if no $userid |
address2 |
String
|
<optional>
|
The address2 of the client the quote is for if no $userid |
city |
String
|
<optional>
|
The city of the client the quote is for if no $userid |
state |
String
|
<optional>
|
The state of the client the quote is for if no $userid |
country |
String
|
<optional>
|
The country of the client the quote is for if no $userid |
phonenumber |
String
|
<optional>
|
The phone number of the client (no country code) the quote is for if no $userid. Local format eg 4035551234 |
tax_id |
String
|
<optional>
|
The tax id of the client |
currency |
Number
|
<optional>
|
The id of the currency for the quote is for if no $userid |
proposal |
String
|
<optional>
|
The proposal text displayed to the end user |
customernotes |
String
|
<optional>
|
The notes on the quote displayed to the end user |
adminnotes |
String
|
<optional>
|
The notes on the quote displayed to the staff only |
|
- Source:
updateTransaction(opts)
Updates a transaction in the system - https://developers.whmcs.com/api-reference/updatetransaction/
Parameters:
Name |
Type |
Description |
opts |
Object
|
Properties
Name |
Type |
Attributes |
Description |
transactionid |
Number
|
|
The unique id of the transaction to update |
refundid |
Number
|
<optional>
|
The unique id of the transaction that this transaction refunds |
userid |
Number
|
<optional>
|
The ID of the user to apply the transaction to |
invoiceid |
Number
|
<optional>
|
The ID of the invoice the transaction is for |
transid |
String
|
<optional>
|
The unique transaction id for this payment |
date |
String
|
<optional>
|
The date of the transaction Y-m-d |
gateway |
String
|
<optional>
|
The gateway of the transaction in system format |
currency |
Number
|
<optional>
|
The currency id for the transaction if not associated with a user |
description |
String
|
<optional>
|
The description of the transaction |
amountin |
Number
|
<optional>
|
The amount received by the payment |
fees |
Number
|
<optional>
|
The amount of fee charged on the transaction by the merchant - This can be negative |
amountout |
Number
|
<optional>
|
The amount paid out by the payment |
rate |
Number
|
<optional>
|
The exchange rate for the payment based on the default currency |
credit |
Boolean
|
<optional>
|
Should the payment be applied to credit on the client account. Invoice ID must not be provided. |
|
- Source: