The following hooks are provided for Invoices and Quotes related events.
Executes when a client is accepting a quote.
| Variable | Type | Notes |
|---|---|---|
| quoteid | int | The id of the quote being accepted. |
| invoiceid | int | The id of the invoice created for the quote (if applicable). |
No response supported
<?php
add_hook('AcceptQuote', 1, function($vars) {
// Perform hook code here...
});Executes when a late fee has been added to an invoice
| Variable | Type | Notes |
|---|---|---|
| invoiceid | int |
No response supported
<?php
add_hook('AddInvoiceLateFee', 1, function($vars) {
// Perform hook code here...
});Invoked when a payment is applied to an invoice (including partial payments).
| Variable | Type | Notes |
|---|---|---|
| invoiceid | int | The invoice id payment was applied to |
No response supported
<?php
add_hook('AddInvoicePayment', 1, function($vars) {
// Perform hook code here...
});Executes when a transaction is created. Can be a payment or a refund.
| Variable | Type | Notes |
|---|---|---|
| id | int | Transaction reference ID |
| userid | int | Client ID |
| currency | int | Currency ID (if not related to a client, otherwise client currency) |
| gateway | string | |
| date | \datetime | |
| description | string | |
| amountin | float | |
| fees | float | |
| amountout | float | |
| rate | float | Exchange rate |
| transid | string | Transaction reference ID provided by gateway or admin user |
| invocieid | int | Invoice ID to which the transaction was applied |
| refundid | int | ID of original Transaction, if this transaction is a refund |
No response supported
<?php
add_hook('AddTransaction', 1, function($vars) {
// Perform hook code here...
});Executes after invoice generation allowing for after invoicing clean-up.
| Variable | Type | Notes |
|---|---|---|
| No input parameters for this hook point. |
No response supported
<?php
add_hook('AfterInvoicingGenerateInvoiceItems', 1, function($vars) {
// Perform hook code here...
});Runs when an order is requested to be cancelled and refunded, prior to the change of status actually occurring.
| Variable | Type | Notes |
|---|---|---|
| orderid | int | The order ID |
No response supported
<?php
add_hook('CancelAndRefundOrder', 1, function($vars) {
// Perform hook code here...
});Executes when an invoice is being cancelled
| Variable | Type | Notes |
|---|---|---|
| invoiceid | int |
No response supported
<?php
add_hook('InvoiceCancelled', 1, function($vars) {
// Perform hook code here...
});Executes when changing the gateway on an invoice.
| Variable | Type | Notes |
|---|---|---|
| invoiceid | int | The id of the invoice being updated. |
| paymentmethod | string | The new payment method selected. |
No response supported
<?php
add_hook('InvoiceChangeGateway', 1, function($vars) {
// Perform hook code here...
});Executed when an invoice has left "Draft" status and is available to its respective client. Execution of this hook occurs after sending the Invoice Created email.
| Variable | Type | Notes |
|---|---|---|
| source | string | Indicates where the invoice creation action originated, can be one of adminarea, api or autogen |
| user | mixed | The user who initiated the invoice creation (either system or an admin ID value). |
| invoiceid | int | The invoice ID. |
| status | string | The status of the released invoice. |
No response supported
<?php
add_hook('InvoiceCreated', 1, function($vars) {
// Perform hook code here...
});Executes when an invoice is first created. The invoice has not been finalised and delivered to the client at this point. Changes can be made to line items at this point. The invoice totals will be recalculated post execution of this hook point.
| Variable | Type | Notes |
|---|---|---|
| source | string | Indicates where the invoice creation action originated, can be one of adminarea, api or autogen |
| user | mixed | User who initiated the invoice creation, either system or an admin ID value |
| invoiceid | int | The ID of the newly created invoice |
| status | string | The status of the newly created invoice |
No response supported
<?php
add_hook('InvoiceCreation', 1, function($vars) {
// Perform hook code here...
});Executes as an invoice is being created in the admin area before the email is being sent
| Variable | Type | Notes |
|---|---|---|
| source | string | When the invoice is being created |
| user | int | string |
| invoiceid | int | The id of the newly created invoice |
| status | string | The status of the newly created invoice |
No response supported
<?php
add_hook('InvoiceCreationPreEmail', 1, function($vars) {
// Perform hook code here...
});Executes when an invoice is Paid following the email receipt having been sent and any automation tasks associated with the payment action having been run.
| Variable | Type | Notes |
|---|---|---|
| invoiceid | int | |
| invoice | \WHMCS\Billing\Invoice |
No response supported
<?php
add_hook('InvoicePaid', 1, function($vars) {
// Perform hook code here...
});Executes when an invoice is Paid prior to any email or automation tasks associated with the payment action having been run.
| Variable | Type | Notes |
|---|---|---|
| invoiceid | int |
No response supported
<?php
add_hook('InvoicePaidPreEmail', 1, function($vars) {
// Perform hook code here...
});Executes when an automated invoice payment reminder is sent.
| Variable | Type | Notes |
|---|---|---|
| invoiceid | int | |
| type | string |
No response supported
<?php
add_hook('InvoicePaymentReminder', 1, function($vars) {
// Perform hook code here...
});Executes when an invoice status is changed to Refunded.
| Variable | Type | Notes |
|---|---|---|
| invoiceid | int | Invoice ID |
No response supported
<?php
add_hook('InvoiceRefunded', 1, function($vars) {
// Perform hook code here...
});Executes as an invoice is being split
| Variable | Type | Notes |
|---|---|---|
| originalinvoiceid | int | The id of the original invoice |
| newinvoiceid | int | The id of the new invoice |
No response supported
<?php
add_hook('InvoiceSplit', 1, function($vars) {
// Perform hook code here...
});Executes when an invoice is being marked as Unpaid
| Variable | Type | Notes |
|---|---|---|
| invoiceid | int |
No response supported
<?php
add_hook('InvoiceUnpaid', 1, function($vars) {
// Perform hook code here...
});Runs any time a payment gateway callback is received and logged.
| Variable | Type | Notes |
|---|---|---|
| gateway | string | The payment gateway name |
| data | string | A string formatted version of all post data received |
| result | string | The status the gateway module returned |
No response supported
<?php
add_hook('LogTransaction', 1, function($vars) {
// Perform hook code here...
});Executes when an invoice is refunded via the Manual Refund option.
| Variable | Type | Notes |
|---|---|---|
| transid | string | Transaction ID of the original payment |
| amount | float | The amount to be refunded |
No response supported
<?php
add_hook('ManualRefund', 1, function($vars) {
// Perform hook code here...
});Executes prior to an invoice being automatically cancelled. Allows the action to be aborted.
| Variable | Type | Notes |
|---|---|---|
| invoiceid | int | The id of the invoice being automatically cancelled. |
Accepts a return of key/value pairs. Return abortCancel=true to abort the automatic cancellation.
<?php
add_hook('PreInvoiceAutomaticCancellation', 1, function($vars) {
// Perform hook code here...
});Executes prior to invoice generation to allow for manipulation of stored data prior to aggregation of due items.
| Variable | Type | Notes |
|---|---|---|
| No input parameters for this hook point. |
No response supported
<?php
use WHMCS\Service\Service;
/**
* Prevent invoicing of any new services added to clientID 5
*/
add_hook('PreInvoicingGenerateInvoiceItems', 1, function() {
$services = Service::where('userid', 5)
->where('billingcycle', '!=', 'Free Account')
->get();
foreach ($services as $service) {
$service->billingcycle = 'Free Account';
$service->save();
}
});Executes when a quote is created.
| Variable | Type | Notes |
|---|---|---|
| quoteid | int | |
| status | string |
No response supported
<?php
add_hook('QuoteCreated', 1, function($vars) {
// Perform hook code here...
});Executes when a quote status is updated
| Variable | Type | Notes |
|---|---|---|
| quoteid | int | |
| status | string |
No response supported
<?php
add_hook('QuoteStatusChange', 1, function($vars) {
// Perform hook code here...
});Executes when an invoice is updated with changes to or additions of line items. Can be used to manipulate the invoice.
| Variable | Type | Notes |
|---|---|---|
| invoiceid | int | The invoice ID. |
No response supported
<?php
add_hook('UpdateInvoiceTotal', 1, function($vars) {
// Perform hook code here...
});Executes as the invoice is being viewed as a client
| Variable | Type | Notes |
|---|---|---|
| invoiceid | int |
No response supported
<?php
add_hook('ViewInvoiceDetailsPage', 1, function($vars) {
// Perform hook code here...
});