Jump to content

Cancelling invoice by API doesn't trigger hook


steph.hope

Recommended Posts

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?

Link to comment
Share on other sites

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. 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated