Jump to content


  • Content count

  • Joined

  • Last visited

Community Reputation

10 Good

About drosendo

  • Rank
  1. Hi, Currently GetProducts (https://developers.whmcs.com/api-reference/getproducts/) retrieves all products and no information regarding if the product is active or not. So I just created my own API call to handle this and only retrieve the visible (not hidden) products. Just upload to /includes/api . Request Parameters "GetProductsActive" Parameter Type Description Required action string “GetProductsActive” Required pid int string Obtain a specific product id configuration. Can be a list of ids comma separated gid int Retrieve products in a specific group id Optional Response Parameters Parameter Type Description result string The result of the operation: success or error totalresults int The total number of results available startnumber int The starting number for the returned results numreturned int The number of results returned products array An array of products matching the criteria passed Example Request (CURL) $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'https://www.example.com/includes/api.php'); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query( array( 'action' => 'GetProductsActive', // See https://developers.whmcs.com/api/authentication 'username' => 'IDENTIFIER_OR_ADMIN_USERNAME', 'password' => 'SECRET_OR_HASHED_PASSWORD', 'pid' => '1', 'responsetype' => 'json', ) ) ); $response = curl_exec($ch); curl_close($ch); Example Request (Local API) $command = 'GetProductsActive'; $postData = array( 'pid' => '1', // or gid => '1' or both ); $adminUsername = 'ADMIN_USERNAME'; // Optional for WHMCS 7.2 and later $results = localAPI($command, $postData, $adminUsername); print_r($results); Have a better code or add something? Please do! Cheers, David getproductsactive.zip
  2. Hi everyone, Here goes a small contribution: ever wanted to connect to a remote API? Add //Documentation: http://guzzle3.readthedocs.io/docs.html //Declare an alias to Guzzle in your project file's use Client to access Guzzle: use \Guzzle\Http\Client; $client = Client('https://' . $url . '/api/{version}', array( 'version' => 'v1', 'request.options' => array( 'auth' => array($user, $pass, 'Basic'), ) )); Anyone contributing on this? All the best!
  3. HI, Im wondering if there is a simple way to re-generate payment data for an invoice. (Im asking for PHP code). My example case: I have a addon created, that lists payments of a certain gateway that generates payment details for the ATM machine. Now if I didnt have the module, the normal procedure would be: 1º When the payment details expire in order to renew them I have to delete the payment data from the DB table of the payment. 2º Go to the invoice, click on the "View as Client" and it would re-generate the payment details. With my addon, I wanted to simplify the steps, because not all admin users have DB knowledge for this, so on my addon page, it would list all invoices (unpaid) and the steps for re-generating payment details are: 1º Click button delete This will delete the payment data from the DB - Working! Now I would need to re-generate it, something like calling: gateway_link() function form my addon page. Is there a simple way to do this? Thanks, David
  4. I havent run it yet. I only have 1 currency. "€". Is my action correct??
  5. Got IT: UPDATE tblhosting SET paymentmethod='xxx' WHERE amount > 30.50 AND paymentmethod like 'zzz'; UPDATE tblhostingaddons SET paymentmethod='xxx' WHERE recurring > 30.50 AND paymentmethod like 'zzz'; UPDATE tbldomains SET paymentmethod='xxx' WHERE recurringamount > 30.50 AND paymentmethod like 'zzz';
  6. Hey, i have added a new payment gateway and I want to change all the recurring payments from now on. Basically change all orders where total is greater than 50$ and payment method is "Paypal" to payment method "newPayment". Thanks
  7. Hi guys, Some help... I added a new payment method to WHMCS and I want to change all the recurring payments where the total is greater than x$. How can I achieve this either by query(what db tables) or if anyone has a php function please help. Thanks, David
  8. Create a file in whmcsfolder/includes/api/. Label it in the name of the API call getproductaddons.php, all lowercase. Paste in the code (feel free to contirbute): <?php if (!defined("WHMCS")) { die("This file cannot be accessed directly"); } function getParams($vars) { $param = array('action' => array(), 'params' => array()); if (isset($vars['cmd'])) { //Local API mode $param['action'] = $vars['cmd']; $param['params'] = (object) $vars['apivalues1']; $param['adminuser'] = $vars['adminuser']; } else { //Post CURL mode $param['action'] = $vars['_POST']['action']; unset($vars['_POST']['username']); unset($vars['_POST']['password']); unset($vars['_POST']['action']); $param['params'] = (object) $vars['_POST']; } return (object) $param; } try { // Get the arguments $vars = get_defined_vars(); $postFields = getParams($vars); // Block of code to update the whmcs details $pkg = addons($pid); // Block ends here $apiresults = array("result" => "success", "addons" => $pkg); } catch (Exception $e) { $apiresults = array("result" => "error", "message" => $e->getMessage()); } function addons($pid) { $pkg = array(); $pkgIndex = 0; $table = "tbladdons"; $fields = "*"; $where = array("showorder" => 'on'); $result = select_query($table, $fields, $where); while ($row = mysql_fetch_assoc($result)) { if ($row['packages'] != '') { $packages = explode(",", $row['packages']); foreach ($packages as $package) { if ($package == $pid) { $pkg[$pkgIndex]['id'] = $row['id']; $pkg[$pkgIndex]['name'] = $row['name']; $pkg[$pkgIndex]['description'] = $row['description']; if ($row['billingcycle'] == "Free Account") { $pkg[$pkgIndex]['cost'] = 0; } else { $pkg[$pkgIndex]['cost'] = prodPrice($row['id'], "monthly", 'addon'); // addon prices allways in 'monthly' field, independently of Billing Cycle. } $pkg[$pkgIndex]['cycle'] = $row['billingcycle']; $pkgIndex++; } } } } return $pkg; } function prodPrice($pid, $cycle = NULL, $type = 'product', $currency = '1') { $table = "tblpricing"; $fields = "monthly,quarterly,semiannually,annually,biennially"; $where = array("type" => $type, "currency" => $currency, "relid" => $pid); $limits = "1"; $result = select_query($table, $fields, $where, '', '', $limits); while ($addon = mysql_fetch_assoc($result)) { return $addon[$cycle]; } } Save file, and now you can use it: $command = "getproductaddons"; $adminuser = "admin"; $values["pid"] = 5; $results = localAPI($command,$values,$adminuser); All the best! Please give support!
  9. Hi, Has anyone solved this issue? Why do I ask this question? because we work with different registrars, and since reseller club started charging for whois privacy, we cannot apply the cost ONLY to reseller club whois privacy, currenty WHCMS applies to all registrars (Setup -> Products/Services -> Domain Pricing. The box for this is at the bottom of the page.). We have other registrars for specific tld's that don't charge for this. As anyone found a solution or a way to separate this costs? Thanks, David
  10. Hi, hope someone can help me out here. Im using the API call "domainwhois", it's working with no problem. The issue is that with some tld's it returns empty the whois information, when I run the whois lookup in the WHMCS backoffice "admin/whois.php", it returns the result with no issue. Why is this happening, is there some type of option blocking this? Thanks, David
  11. Hi since we updated to this version 5.2.14, promotions stopped working, anyone else having issue? I submit the order but it doesnt apply any promotion even though it is in promotion... Step by step: edu.pt -> has direct promotion I go to buy and it shows the original price, after I still continue and finalize the buy, the email with the order and payment details come out with the original price not the promotional one. PS: User doesnt need to insert "promocional code" in these cases... Thnaks, Davd

Important Information

By using this site, you agree to our Terms of Use & Guidelines