steph.hope Posted November 18, 2020 Share Posted November 18, 2020 It seems that setting an invoice's status to cancelled via the UpdateInvoice API doesn't trigger the InvoiceCancelled hook. This is a problem as it seems that a 3rd party module we're using makes use of that hook to identify cancellations. Is there any other way to cancel an invoice by API that would work better? 0 Quote Link to comment Share on other sites More sharing options...
steven99 Posted November 19, 2020 Share Posted November 19, 2020 I believe the updateinvoice is the only api that does that. You can try doing this via internal classes on the Invoice class https://classdocs.whmcs.com/7.8/WHMCS/Billing/Invoice.html Something like: <?php $Invoice = \WHMCS\Billing\Invoice::find($InvoiceID); if ($Invoice) { $Invoice->status = 'Cancelled'; $Invoice->save(); } Have not tested if the hook will fire with that though. 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted November 19, 2020 Share Posted November 19, 2020 or for v8 - https://classdocs.whmcs.com/8.0/WHMCS/Billing/Invoice.html 0 Quote Link to comment Share on other sites More sharing options...
steven99 Posted November 19, 2020 Share Posted November 19, 2020 Ah had not seen 8.0 docs yet. In there there is a setStatusCancelled() function that would likely be better. 0 Quote Link to comment Share on other sites More sharing options...
steph.hope Posted November 19, 2020 Author Share Posted November 19, 2020 19 hours ago, steven99 said: <?php $Invoice = \WHMCS\Billing\Invoice::find($InvoiceID); if ($Invoice) { $Invoice->status = 'Cancelled'; $Invoice->save(); } Have not tested if the hook will fire with that though. It doesn't seem to 😞 And unfortunately we haven't upgraded to v8 yet for a host of reasons. That's fine, we'll work around it somehow. 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.