Adds payment to a given invoice.

Request Parameters

Parameter Type Description Required
action string “AddInvoicePayment” Required
invoiceid int Required
transid string The unique transaction id that should be applied to the payment Required
gateway string the gateway used in system name format, eg. paypal, authorize Required
date \Carbon\Carbon The date that the payment should have assigned. Format: YYYY-MM-DD HH:mm:ss Optional
amount float the amount paid, can be left undefined to take full amount of invoice Optional
fees float the amount of the payment that was taken as a fee by the gateway Optional
noemail bool set to true to not send an email for the invoice payment Optional

Response Parameters

Parameter Type Description
result string The result of the operation: success or error

Example Request (CURL)

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, '');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,
            'action' => 'AddInvoicePayment',
            // See
            'username' => 'IDENTIFIER_OR_ADMIN_USERNAME',
            'password' => 'SECRET_OR_HASHED_PASSWORD',
            'invoiceid' => '1',
            'transid' => 'D28DJIDJW393JDWQKQI332',
            'gateway' => 'mailin',
            'date' => '2016-01-01 12:33:12',
            'responsetype' => 'json',
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($ch);

Example Request (Local API)

$command = 'AddInvoicePayment';
$postData = array(
    'invoiceid' => '1',
    'transid' => 'D28DJIDJW393JDWQKQI332',
    'gateway' => 'mailin',
    'date' => '2016-01-01 12:33:12',
$adminUsername = 'ADMIN_USERNAME'; // Optional for WHMCS 7.2 and later

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

Example Response JSON

    "result": "success"

Error Responses

Possible error condition responses include:

  • Invoice ID Not Found
  • It is not possible to add a payment to an invoice that is Cancelled

Version History

Version Changelog
1.0 Initial Version