Jump to content

Custom billing period


SubZeroFX

Recommended Posts

Hello WHMCS Admins,

I wanted to ask if it's possible to set up a custom billing period, other then standard "monthly (30 days)" etc.

For example can I charge a (example) $10 for first 10 days for a product/server and then on the 11th day bill said client for $30 ( Monthly / 30 days ) and set them on auto renew billing thereafter?

Please let me know if it's possible to set it up on WHMCS or do I need to use some kind of a addon/module? Any recommendations?

Edited by SubZeroFX
Link to comment
Share on other sites

Of course it's possible. API -> CreateInvoice + Hook -> DailyCronJob. How? That's a long story.

Make the Product/Service one-time $10. On every Daily Cron Job...

SELECT id FROM tblhosting WHERE packageid = {$ID-Of-Product-In-Question} AND billingcycle = 'OneTime' AND regdate = DATE_SUB(CURDATE(), INTERVAL 10 DAY) AND domainstatus IN ("Active", "Completed")

This way we selected all products/services that had been ordered 10 days ago with Active/Completed status. Foreach of these records...

UPDATE tblhosting SET billingcycle = 'Monthly', amount = '30.00', nextduedate = DATE_ADD(CURDATE(), INTERVAL 30 DAY), nextinvoicedate = DATE_ADD(CURDATE(), INTERVAL 30 DAY) WHERE id = {$The-IDs-Of-The-Above-Query} LIMIT 1

By doing this we made the product $30 / month with next due date and invoice date set to current date plus 30 days. In order words from now on the client receives an invoice of $30 on a monthly basis. Now there's just one thing that is missing. We need to issue the invoice for current month and this can be done via API still in Daily Cron Job.

Please keep in mind that there are probably tens of ways to achieve the same result maybe even easier (I tend to overthink too much).

Edited by Kian
Link to comment
Share on other sites

@Kian thanks a ton for this replay!

I've got just another question about how to tie all of those custom created invoices with payment gateways, like PayPal or Credit/Debit Cards so that all payments are automatically made (like subscription)? Which method/API/Hook should I use?

 

Link to comment
Share on other sites

Umh... The first invoice ($10) shouldn't have a subscription button since we're talking about a one-time payment. The option to pay and create a subscription would be available on subsequent invoices ($30) since they're recurring.

Link to comment
Share on other sites

22 hours ago, Kian said:

By doing this we made the product $30 / month with next due date and invoice date set to current date plus 30 days. In order words from now on the client receives an invoice of $30 on a monthly basis. Now there's just one thing that is missing. We need to issue the invoice for current month and this can be done via API still in Daily Cron Job.

What if I simply update `tblhosting` day before and set `nextduedate` and `nextinvoicedate` +1 day - wouldn't that make WHMCS to auto-generate an invoice so that I won't need to use API CreateInvoice?

Link to comment
Share on other sites

Nice idea. I was thinking that probably is even better to link everything to AfterModuleCreate hook point:

  1. Client places the order and pays the one-time invoice $10
  2. AfterModuleCreate you automatically change billing cycle from OneTime to Monthly with nextduedate & nextinvoicedate equal to current date +10 days
  3. Next day with DailyCronJob WHMCS will automatically create the invoice for the renewal. This way client immediately receives the invoice and has 9 days (and X hours) to pay before service expires

By doing this you don't need to play with API CreateInvoice and DailyCronJob hook point. It's way more easier.

Link to comment
Share on other sites

3 minutes ago, Kian said:

Nice idea. I was thinking that probably is even better to link everything to AfterModuleCreate hook point:

  1. Client places the order and pays the one-time invoice $10
  2. AfterModuleCreate you automatically change billing cycle from OneTime to Monthly with nextduedate & nextinvoicedate equal to current date +10 days
  3.  Next day with DailyCronJob WHMCS will automatically create the invoice for the renewal. This way client immediately receives the invoice and has 9 days (and X hours) to pay before service expires

By doing this you don't need to play with API CreateInvoice and DailyCronJob hook point. It's way more easier.

This is the best way to do this! Thank you Kian, you are a legend!

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