Openprovider-WHMCS-domains icon indicating copy to clipboard operation
Openprovider-WHMCS-domains copied to clipboard

[BUG] domain renewal dates not synced: grace > expired in WHMCS while active in OP

Open DigiNL opened this issue 2 years ago • 6 comments

Domains in WHMCS are not synced (in time). NOT using the renew on payment option in WHMCS.

When invoice has been paid (after due date) the due dates do not change to one year forward. Also renew and expire dates do not sync. Domains get the grace/expired state in whmcs so customers are panicking saying the domains have been gone and WHMCS does not sent emails or invoices on those domains. The actual domains in OP are normally active I use automatic renew in OP, only when in WHMCS customers manually disable auto renew for a domain OP follows This is something i really don't like, please fix this asap

using latest WHMCS 8.x version and latest WHMCS OP version 5.6

I want to use scenario 2 from your github page

DigiNL avatar Jun 30 '22 15:06 DigiNL

@DigiNL as the OP devs seems to be afk for almost a year... one of the things you can do...

The daily cron of WHMCS has a task which is called --UpdateDomainExpiryStatus: https://docs.whmcs.com/Crons. Run the cron.php which is setup to run every 5 minutes per WHMCS documentation with argument skip --UpdateDomainExpiryStatus:

yourwhmcsfolder/crons/cron.php skip --UpdateDomainExpiryStatus

Then use the OP domainsync and set syncDomainStatus to 'true' in the advanced configuration file. Now the WHMCS daily cron will not put domains in Expiry status while they are waiting to be synced by OP's own domainsync cron.

Be sure to disable 'updateNextDueDate' (set it to false!!!) as this will also sync tbldomains.nextinvoicedate and last entry of related domain in tblinvoiceitems.duedate to the same date as the expiry date. If the nextinvoicedate and duedate of tblinvoiceitems are the same, it will cause WHMCS to skip creating domain renewal invoices (!).

            // Update the invoice item if there was any.
            Capsule::table('tblinvoiceitems')
                ->where('type', 'domain')
                ->where('relid', $domain->id)
                ->where('duedate', $original_nextduedate)
                ->update(['duedate' =>  $domain->nextduedate]);

            $updated_domains[] = [ 'domain' => $domain, 'original_nextduedate' => $original_nextduedate];

This small code snippet costed us almost $100k of no invoiced renewals and seriously no idea why this is being done.

eMiz0rz avatar Mar 11 '23 19:03 eMiz0rz

Hello @eMiz0rz thank you for your comment, there is an updated version available, should i use that one? If so i want to try your solution but with care, can you contact me using some kind of DM here?

DigiNL avatar Mar 13 '23 08:03 DigiNL

Jesus fck, I have this issue also for a long time and as I see that this is reported back in 2022 and still not resolved I am getting a bit scared.

ikke-zelf avatar Apr 11 '23 19:04 ikke-zelf

@DigiNL as the OP devs seems to be afk for almost a year... one of the things you can do...

The daily cron of WHMCS has a task which is called --UpdateDomainExpiryStatus: https://docs.whmcs.com/Crons. Run the cron.php which is setup to run every 5 minutes per WHMCS documentation with argument skip --UpdateDomainExpiryStatus:

yourwhmcsfolder/crons/cron.php skip --UpdateDomainExpiryStatus

Then use the OP domainsync and set syncDomainStatus to 'true' in the advanced configuration file. Now the WHMCS daily cron will not put domains in Expiry status while they are waiting to be synced by OP's own domainsync cron.

Be sure to disable 'updateNextDueDate' (set it to false!!!) as this will also sync tbldomains.nextinvoicedate and last entry of related domain in tblinvoiceitems.duedate to the same date as the expiry date. If the nextinvoicedate and duedate of tblinvoiceitems are the same, it will cause WHMCS to skip creating domain renewal invoices (!).

            // Update the invoice item if there was any.
            Capsule::table('tblinvoiceitems')
                ->where('type', 'domain')
                ->where('relid', $domain->id)
                ->where('duedate', $original_nextduedate)
                ->update(['duedate' =>  $domain->nextduedate]);

            $updated_domains[] = [ 'domain' => $domain, 'original_nextduedate' => $original_nextduedate];

This small code snippet costed us almost $100k of no invoiced renewals and seriously no idea why this is being done.

Updating the next due date while leaving the duedate in the invoice at the original value, would cause to generate a new invoice. That said, there is a protection in place where it only updates if it differs less than nextDueDateUpdateMaxDayDifference days. By default, this is 100 days. If you have this value too high, it's possible it will renew each year so be careful with that.

It has been extensively tested when I developed this feature, however, many changes have been made that may make this feature unreliable. At some point, it was decided to abandon the custom domain sync feature in favor of the WHMCS sync feature. I still believe the WHMCS sync feature is unreliable, since it marks domains as expired while they are renewed at the registrar (e.g. openprovider renews shortly before the actual expiration date).

Since the feature is deprecated, I would not use the custom sync anymore. Instead, I suggest to loop through all expired domains in the last month with a script and check if the status at the registrar is similar to the one in WHMCS.

MrKoopie avatar Jan 12 '24 20:01 MrKoopie

@MrKoopie when you change those files are they overwritten when you update/upgrade Whmcs? Thank you for your extended explanation!

DigiNL avatar Jan 15 '24 09:01 DigiNL

@MrKoopie

We only want to invoice our client(s) whever the domain is actually up for renewal and not depending on the (transferred in) date. Some domains have an expiry date way beyond or even in 2033 when I look into our db now. We don't get renewal invoiced for the next 10 years, so why should we invoice our client... However when a new transfer is ordered in WHMCS, the nextduedate is always placed exactly one year later.

Setting nextDueDateUpdateMaxDayDifference to 100 days is indeed a (working) protection, but in our case clients will receive an invoice one year later after ordering a transfer (because the nextduedate is not altered) even when the domain expires multiple years later. That's why I've set the nextDueDateUpdateMaxDayDifference to 400 days and yes you're right: it creates another problem having renewals not being invoices :) But this is only because the OP sync alters the duedate in the table tblinvoiceitems for the corresponding invoice and I haven't found any reason yet as to why. The tblinvoiceitems table is only for invoicerows of invoices that have already been sent out to clients. There is no reason to alter this input backwards.

However; the code is deprecated so this is not really an issue anymore (but still, my "fix" of commenting these lines of code works).

Looping through all expired domains in WHMCS for the last month is unfortunately not a solution. WHMCS has no idea of domains that are being transferred out from OP as OP just removes the entry entirely (instead of giving it some status like "cancelled" or "transferred away" or whatever), so they remain active (and invoiced) in WHMCS until they are manually cancelled. Second issue with the WHMCS domain sync is that it does not sync domains that have the status "Grace period (Expired)". And indeed; when a domain is renewed on the last day by OP, occassionally WHMCS still tags it as "Grace period" when the domains have reached their expiry date in WHMCS causing these domains to be never updated again by the WHMCS cron (for instance when they are back active because OP has renewed the domains in the meanwhile).

Both implementations; the OP cron and WHMCS cron are somewhat broken and will cause issues in invoicing domains correctly. The only way is to custom develop a sync application and customers with WHMCS, using OP should be aware of it both implementations are unsupported and not working as they should.

eMiz0rz avatar Jan 16 '24 10:01 eMiz0rz

Domains in WHMCS are not synced (in time). NOT using the renew on payment option in WHMCS.

I want to use scenario 2 from your github page

I investigated this and gathered info with the help of WHMCS team.

WHMCS recommend switching off auto-renewal at the registrar and waiting for the client to pay for their domain renewal prior to performing any renewal action [Response from WHMCS Head of Support].

In scenario 2, if a client doesn't pay the renewal invoice before expiry date, the domain's status will indeed cycle Grace/Redemption/Expired, even though it was auto renewed at the registrar [Response from WHMCS Head of Support].

To trigger the updating of the domain status and expiry date, the invoice would need to be paid in WHMCS, the renewal command successfully sent to your registrar and successfully processed.

If you are not using a WHMCS registrar module to automate domain tasks and are manually/automatically renewing domains at your registrar, after you have renewed the domain, the expiry date and status would need to be updated manually in WHMCS. This is because, with the WHMCS native Domain Status Sync, domains are only checked when they are in Active, Pending Registration or Pending Transfer status. Once a domain is in Grace or Expired status in WHMCS, it will only be transitioned out by completing the Renew module command.

To avoid such issues, WHMCS recommends using Scenario 1 mentioned here.

sapillai avatar Jun 26 '24 11:06 sapillai