Jump to content

Kian

GearHead
  • Content count

    1,433
  • Joined

  • Last visited

  • Days Won

    33

Everything posted by Kian

  1. Kian

    Payment method according to invoice amount

    I feel my awkwardness for posting that script. I coded it a lot of time ago for unknown reasons 😄 As I said earlier it's not very elegant and @brian! is right about multi-currency. Anyway it loops through all gateway key/value pairs to find the one with the highest limit according to invoice amount. Example: <?php $InvoiceTotal = 35; $Gateways['banktransfer'] = 10; $Gateways['bnlpositivity'] = 20; $Gateways['gestpay'] = 30; $Gateways['nexi'] = 40; foreach ($Gateways as $k => $v) { echo 'Use ' . strtoupper($k) . ' gateway when amount is greater than or equal to ' . $v . '<br>'; echo 'Is ' . $InvoiceTotal . ' (invoice amount) greater than or equal to ' . $v . '?<br>'; if ($InvoiceTotal >= $v) { echo 'Yes! Let\'s use ' . strtoupper($k); } else { echo 'Nope!'; } echo '<br><br>'; } /* Prints... Use BANKTRANSFER gateway when amount is greater than or equal to 10 Is 35 (invoice amount) greater than or equal to 10? Yes! Let's use BANKTRANSFER Use BNLPOSITIVITY gateway when amount is greater than or equal to 20 Is 35 (invoice amount) greater than or equal to 20? Yes! Let's use BNLPOSITIVITY Use GESTPAY gateway when amount is greater than or equal to 30 Is 35 (invoice amount) greater than or equal to 30? Yes! Let's use GESTPAY Use NEXI gateway when amount is greater than or equal to 40 Is 35 (invoice amount) greater than or equal to 40? Nope! */ Long story short GESTPAY will be used as gateway. If invoice amount changes to 40 the gateway will be set to NEXI. If it drops to 15 BANKTRANSFER and so on. As I said for sure there are better ways but now I wanna start playing League of Legends 😛
  2. Kian

    Payment method according to invoice amount

    For sure there are more elegant ways but this hook should work. <?php use Illuminate\Database\Capsule\Manager as Capsule; add_hook('ClientAreaPageViewInvoice', 1, function($vars) { $Data = Capsule::select(Capsule::raw('SELECT total, paymentmethod FROM tblinvoices WHERE id = "' . $vars['invoiceid'] . '" LIMIT 1')); /** * Use Gateway System Name as key and amount as value * * Invoice total 10 -> banktransfer * Invoice total 15 -> banktransfer * Invoice total 20 -> katamaze_bnlpositivity * Invoice total 30 -> katamaze_gestpay * Invoice total 40 -> katamaze_nexi */ $Gateways['banktransfer'] = 10; $Gateways['katamaze_bnlpositivity'] = 20; $Gateways['katamaze_gestpay'] = 30; $Gateways['katamaze_nexi'] = 40; foreach ($Gateways as $k => $v) { if ($Data[0]->total >= $v) { $AssignedGateway = $k; } } if ($AssignedGateway != $Data[0]->paymentmethod) { localAPI('UpdateInvoice', array('invoiceid' => $vars['invoiceid'], 'paymentmethod' => $AssignedGateway), $adminUsername); header('Location: viewinvoice.php?id=' . $vars['invoiceid']); die(); } }); Every time customer changes payment method or view the invoice, the hook triggers and set the correct payment method depending on invoice total.
  3. There are modules with some of the features you're looking for in Marketplace. For sure there's nothing for this and frankly I don't get what's the point of multi-tier affiliate markeing 😟 Watch out GDPR 😛
  4. Kian

    Auto Apply Credit

    This one should work. <?php use Illuminate\Database\Capsule\Manager as Capsule; add_hook('InvoiceCreation', 1, function($vars) { $Data = Capsule::select(Capsule::raw('SELECT t1.total, t2.credit FROM tblinvoices AS t1 LEFT JOIN tblclients AS t2 ON t1.userid = t2.id WHERE t1.id = "' . $vars['invoiceid'] . '" LIMIT 1')); $CreditBalance = $Data[0]->credit; $TotalDue = $Data[0]->total; // Apply Credit only if Credit Balance is greater than zero if ($CreditBalance) { $postData = array( 'invoiceid' => $vars['invoiceid'], 'amount' => ($CreditBalance < $TotalDue ? $CreditBalance : $TotalDue) // If Credit Balance is less than Total Due there will be a partial payment ); $results = localAPI('ApplyCredit', $postData, $adminUsername); } });
  5. Hi, Need more details but you can untick Require Domain (Setup > Products/Services > Products/Services > Your hosting package > Edit > Details tab > Require Domain).
  6. Kian

    Auto Apply Credit

    On InvoiceCreated or InvoiceCreationPreEmail hook points run ApplyCredit API function.
  7. I'm completing the refactoring of a module that I initially released on 2015 that allows to pay commissions to Affiliates depending on their sales, performance levels and monthly achievements. It has nothing to do with the Affiliates system of WHMCS. The current version of the module is still functional but has a problem. It has too many types of commissions which makes the module very difficult to use. That's what you get when you give too much room to bad users' feedback 🤔 My bad. The refactored module is based on making it simple to use for administrators and affiliates therefore I refused to implement subterfuges like 3% + 5% commissions (you don't get 8%), misleading mechanics and bonus scheme that requires a supercomputer to be explained. I'll never implement such things again. That said, I'm looking for feedback (good ones 😀), ideas and suggestions. Am I missing something important? Backend Commissions [ Click to enlarge ] You can define commission payouts based on specific Products/Services, TLDs and Product Addons both percentage and fixed amount. It is also possible to define group-based commissions (eg. all VPS servers, all TLDs). You can use padlocks to lock certain items so that they don't get updated when you change parents. Achievements [ Click to enlarge ] You can set multiple achievements to encourage Affiliates to keep selling your products. On a monthly basis the module automatically rewards them for reaching the goals you set. Achievements are based on Revenue, New Signups and Number of Sales. These same achievements can be used also to reward Top Affiliates (eg. first 5 Affiliates that brings you 1000€ of Revenue, Affiliates reaching 1000€ earn a bonus of 100€ etc.). The system pays commissions based on the following Attribution Metrics (Manual, Cookie-based, Interactive). You can put limits to Affiliation program and Payouts. There are also many other pages in backend (Dashboard, View/Filter/Manage Affiliates, Sales, Payouts, Settings) but right now I'd like to focus on the above ones. Before you ask the module already handles multiple currencies and conversion rates. Clientarea Earnings [ Click to enlarge ] This is how your Affiliates can monitor their sales, revenues and request payouts from Clientarea. Achievements [ Click to enlarge ] Here they review not only unlocked Achievements but also next ones. At a glance they can get an idea of their progress by simply looking at progress bars. This way they can decide to focus on a particular goal. Subscriptions [ Click to enlarge ] This area is for recurring commissions that can be lifetime or last for a certain amount of months. Statistics [ Click to enlarge ] We're still working on this page since we need to decide what metrics to represent in graphs. Quite frankly I really don't know. Revenue, Commissions, Payouts, ROI... what else? I'm not a "marketing guy".
  8. One quick question. Do you have Level 2 tax rate in Australia?
  9. For sure your PHP version is 7.1.24 but Cron is running with an older version hence the error. Make sure that Cron deamon uses a recent version of PHP.
  10. I'm sorry for asking so many questions but do you need to filter by all 143 entity types you have in Australia?
  11. Use InvoiceChangeGateway hook point. As soon as the gateway changes run: UPDATE tblinvoices SET paymentmethod = '{PAYMENT}' WHERE id = {INVOICE_ID} LIMIT 1
  12. Thanks for the GUID. It works. I was planning to store the following parameters: ABN Status (Active, Cancelled) Effective from YYYY-MM-DD Entity Status (Active, Cancelled) Effective from YYYY-MM-DD Type Code (DTT, PRV, IND) Description (Discretionary Trading Trust, Australian Private Company, Individual/Sole Trader) Name Legal/Business name (Nicole Kidman, Maximus Decimus Meridius LTD...) Effective from YYYY-MM-DD Address State Code (QLD, VIC) Postcode (4557, 3193) Effective from YYYY-MM-DD GST Status (Yes, No) Effective from YYYY-MM-DD ASIC Number (I have no idea of what is this value) Am I missing something? Should I remove some fields? I'm going to use these values on Invoices table and also for this panel. I also want to ask another question. VIES of European Union and ABN are very similar. When I use VIES I know that I can't flood them with too many requests. There are limits (max 10k checks per day, max 5 check per VAT Number etc.). I can't find anything about ABN limitations. What should I do? Descriptions are not final but yeah it makes more sense.
  13. Yes. All you need is a simple true/false for membership status. Yes, you can display any template you want based on the true/false status I have previously mentioned. Anyway could you please provide more details about your project with an example?
  14. Told ya 😄 Anyway I need some help for GUID. Take a look at the screenshot below. I check VAT Numbers using ABN Lookup via Web Service when customers register on WHMCS, update their VAT Numbers and automatically with Daily Cron of WHMCS. This way your RCTI will work in line with what ABN says (eg. Valid VAT Number yes/no, registered for GST yes/no). I keep a copy of all checks locally on WHMCS storing entity names, ABN status, GST, business localtions - I still have to decide what values are relevant. When you issue the RCTI, I take a snapshot of ABN and GST status and adjust it accordingly (VAT exemption, <75$ AUD rule, 49%, statement by supplier etc.). There's log where you can review changes to VAT Numbers and GST status. Moreover you can optionally receive a recap via email on a daily basis if there's something to notify. This new toy works on paper but I can't test ABN Lookup functionalities without GUID. I can't register on ABN since I'm not Australian so... 😋 Can someone PM me his/her GUID?
  15. It gets the job done. I used it like crazy for an entire year and it's fine. It's a bit old-school in some aspects but who cares? 🤭 reviews... that place where people judge complex stuff after 5 minutes of use. Full of fake reviews and sponsored honest ones. Not to mention star rating system and thumbs up/down that make absolutely no sense.
  16. Kian

    Invoice Paid Email Notification

    On InvoicePaid run a query to scan the invoice looking for product IDs you need: SELECT id FROM tblhosting WHERE packageid IN ('1', '2', '3') LIMIT 1 Replace 1, 2 and 3 with IDs of your VPS/Server plans. If the query returns true you could SendEmail via API but the problem is that it doesn't let you specify a recipient. You have to autoload PHPMailer, load your SMTP settings from tblconfiguration, retreive the recepient and send the email. In this post I have already described this approach. I know it's boring but there's no other way 🙂
  17. Use _link function to return anything you need like follows: <?php function YourGateway_link($params) { $output = <<<HTML <link href="your-style.css" rel="stylesheet" type="text/css" /> <form method="post" action="somewhere-over-the-rainbow.php"> <input type="text" name="something" value="1000"> <button type="submit">Submit</button> </form> HTML; return $output; } It will show a form with an input text where customers can enter your number and the submit button.
  18. Kian

    Any way to post-process reports?

    I could be wrong but I suspect that a module you are using has this feature. It pulls everything your accountant need from database. It's like using an API function of WHMCS.
  19. I do know that I didn't answer to your question. I just wanted to be helpful letting you know that this kind of change could cause billing mistakes. Over the years it happened with a lot of customers therefore before investing 15 minutes of my time giving you the snippet, I wanted to make sure that you were doing it in the right way. I don't like to share code that potentially could cause billing nightmares - you didn't mention you were adding another line with a negative amount. Yes: EmailPreSend (abortsend = true) UpdateInvoice (add a new line with negative newitemamount) SendEmail (re-send the previously suppressed email)
  20. Kian

    Domain ID variable for email templates

    Use EmailPreSend to load domain IDs from tbldomains with a query then declare {$domain_id} custom variable so that it's equal to your array.
  21. Think twice. Basically you are creating money from nothing. I pay 90 (taxed) and get 100. Before you start coding give a call to your accountant to make sure everything is fine.
  22. Kian

    Use value for variable in hook

    🤣 no. It was just an example based on a method I get used to implement in my WHMCS projects to retrieve stuff from tblconfiguration from any place (module, hooks, pages, widgets...)
  23. Kian

    Use value for variable in hook

    I could be wrong but Decrypt() and Encrypt() internal functions are not documented. For sure they were in past but I can no longer spot them. At least there are their API-equivalent: DecryptPassword and EncryptPassword.
  24. Kian

    Use value for variable in hook

    Decrypt (and Encrypt) takes care of that for you. You can also use API DecryptPassword.
  25. Kian

    VAT

    In some countries (eg. Italy) it's on a monthly basis if you earn a lot of money. Back on topic, there's a very important detail that is missing: VIES. Let's suppose that you register your VAT Number in Germany and that you sell a product that costs 100$ Italian customer (individual) pays 100$+ 22% IVA Italian customer (business) not registered in the VIES system pays 100$ + 22% IVA Italian customer (business) registered on VIES pays just 100$ (no tax) German customer (individual) pays 100$ + 19% MwSt./USt. German customer (business) not registered on VIES pays 100$ + 19% MwSt./USt. German customer (business) registered on VIES pays 100$ + 19% MwSt./USt. Rest of Europe Exceptions: Spain: Canary Islands (Las Palmas, Tenerife) UK: Mann Island, Channel Islands Overseas territories (damn France and Netherlands) Italy: Livigno, Campione d'Italia, Lugano Full list I'd suggest you to stay away from countries with electronic invoicing or that are going to adopt it. Let me give you an example with Italy (it has electronic invoicing). Here is what happens just with italian customers! Individual pays 100$+ 22% IVA Business not registered on VIES system pays 100$ + 22% IVA Business registered on VIES pays 100$ + 22$ IVA Business listed on FTSE MIB stock exchange pays 100$ * State-owned business pays 100$ * State-controlled business pays 100$ * State-partecipated business 70% or higher pays 100$ * Public Administration pays 100$ * Livigno, Campione d'Italia, Lugano 100$ (I'm not 100% sure!) San Marino I have no f**king idea 🤮 Can someone annex this country? Vatican City... Dear Pope, we need to talk The rest of EU and the world * You must verify their identities in "awesome" ways
×

Important Information

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