Skip to content
Last updated

GetInvoice

Retrieve a specific invoice

Request Parameters

ParameterTypeDescriptionRequired
actionstring"GetInvoice"Required
invoiceidintThe ID of the invoice to retrieve.Required

Response Parameters

ParameterTypeDescription
resultstringThe result of the operation: success or error
invoiceidintThe ID of the invoice.
invoicenumstringThe Sequential Invoice Number assigned (if enabled).
useridintThe ID of the user who owns this invoice.
datestringThe date of the invoice. Format: YYYY-MM-DD
duedatestringThe due date of the invoice. Format: YYYY-MM-DD
datepaidstringThe date the invoice was paid. Format: YYYY-MM-DD HH:ii:ss
subtotalfloatThe subtotal on the invoice.
creditfloatThe amount of credit assigned to the invoice.
taxfloatThe amount of first-level tax charged on the invoice.
tax2floatThe amount of second-level tax charged on the invoice.
totalfloatThe total of the invoice.
balancefloatThe amount left to pay on the invoice.
taxratefloatThe rate of the first-level tax.
taxrate2floatThe rate of the second-level tax.
statusstringThe status of the invoice.
paymentmethodstringThe payment method on the invoice, in system format.
notesstringThe notes associated with the invoice.
ccgatewayboolWhether the payment method is a credit card gateway that can be submitted to attempt capture.
itemsarrayThe items on the invoice.
transactionsarrayThe transactions on the invoice.

Example Request (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' => 'GetInvoice',
            // See https://developers.whmcs.com/api/authentication
            'username' => 'IDENTIFIER_OR_ADMIN_USERNAME',
            'password' => 'SECRET_OR_HASHED_PASSWORD',
            'invoiceid' => '1',
            'responsetype' => 'json',
        )
    )
);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($ch);
curl_close($ch);

Example Request (Local API)

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

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

Example Response JSON

{
    "result": "success",
    "invoiceid": 1,
    "invoicenum": "",
    "userid": 2361,
    "date": "2016-01-01",
    "duedate": "2020-12-30",
    "datepaid": "0000-00-00 00:00:00",
    "lastcaptureattempt": "0000-00-00 00:00:00",
    "subtotal": "15.95",
    "credit": "0.00",
    "tax": "0.00",
    "tax2": "0.00",
    "total": "15.95",
    "balance": "15.95",
    "taxrate": "0.000",
    "taxrate2": "0.000",
    "status": "Unpaid",
    "paymentmethod": "paypalcheckout",
    "notes": "",
    "ccgateway": false,
    "items": {
        "item": [
            {
                "id": 1,
                "type": "Hosting",
                "relid": 1,
                "description": "Sample Monthly Product (01\/01\/2016 - 31\/01\/2016)",
                "amount": "15.95",
                "taxed": 0
            }
        ]
    },
    "transactions": ""
}

Error Responses

Possible error condition responses include:

  • Invoice ID Not Found

Version History

VersionChangelog
1.0Initial Version