Jump to content

drosendo

Member
  • Posts

    16
  • Joined

  • Last visited

About drosendo

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

drosendo's Achievements

Junior Member

Junior Member (1/3)

1

Reputation

  1. I cant find the checkbox in the invoices client area page. Has it been removed? Using six theme.
  2. Hi, Will this help prevent {address1=address1 contains invalid characters.} when trying to activate the purchase with reseller club? Cheers,
  3. Hello, We work exclusively with the WHMCS API and there are cases where WHMCS works with 2 different naming for the same thing. Example: user buys a product that is "Semi-Annually", I have to send it to whmcs api as billingcycle "semiannually" on the api "addOrder". Now, if I have a coupon created with billingcycle "Semi-Annually" the api returns "semi-annually". When user tries to use the coupon created in his cart products, the result: coupon "semi-annually" != "semiannually" product So nothing is applied. Of course i had to remove the "-" but still I dont know where else this may have implications. Therefor WHMCS should normalize this information. Cheers, David
  4. Retrieve domain whois information with premium pricing if applicable Request Parameters Parameter Type Description Required action string “getwhoistldpricing” Required domain string The domain name to lookup Required Response Parameters Parameter Type Description result string The result of the operation: success or error status string The registration status: available or unavailable whois string Whois server response 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' => 'getwhoistldpricing', // See https://developers.whmcs.com/api/authentication 'username' => 'IDENTIFIER_OR_ADMIN_USERNAME', 'password' => 'SECRET_OR_HASHED_PASSWORD', 'domain' => 'example.com', 'responsetype' => 'json', ) ) ); $response = curl_exec($ch); curl_close($ch); Example Request (Local API) $command = 'getwhoistldpricing'; $postData = array( 'domain' => 'example.com', ); $adminUsername = 'ADMIN_USERNAME'; // Optional for WHMCS 7.2 and later $results = localAPI($command, $postData, $adminUsername); print_r($results); Example Response JSON { "example.com": { "result": "success", "status": "available", "whois": null, "premium": { "premiumCostExtra": { "to_amount": "-1.00", "markup": "20.00000" }, "isPremium": true, "premiumCostPricing": { "transfer": "9.13", "create": "1596.73", "renew": "9.13", "sellingCurrencySymbol": "EUR" } } } } Just upload to /includes/api . This is Working for ResellerClub, you may adjust to your reseller API, over on line 56 and 58. $params = getRegistrarConfigOptions('resellerclub'); $url = 'https://test.httpapi.com/api/domains/available.json?auth-userid=' . $params['ResellerID'] . '&api-key=' . $params['APIKey'] . '&domain-name=' . $domainname . '&tlds=' . $tld . '&suggest-alternative=false'; Any contribution will be appreciated. Cheers, David getwhoistldpricing.zip
  5. Hi, Any update on this code? I have a code of mine to try and fit all possible solutions, must read to understand... but maybe we can exchange things. function runPromos() { global $whmcsis_cart, $whmcs; $promo = $_POST["promo"]; $postfields["code"] = $promo; $promotions = $whmcs->getpromotions($postfields); $active_promo = $promotions->promotions->promotion[0]; $thedate = date("Y-m-d"); $todaysdate = strtotime($thedate); $expirationdate = $active_promo->expirationdate; $expires = strtotime($expirationdate); if ($expires < $todaysdate && $expirationdate != "0000-00-00") { header("Content-type: application/json"); echo json_encode(false); die(); } if ($active_promo == '') { header("Content-type: application/json"); echo json_encode(false); die(); } $cart_data = $whmcsis_cart->getItems(); if ($cart_data['promocode'] != '') { header("Content-type: application/json"); echo json_encode(false); die(); } $whmcsis_cart->addItem('promocode', $promo); $str_ids = explode(',', $active_promo->appliesto); $str_cycle = explode(',', strtolower($active_promo->cycles)); $cart_data = $whmcsis_cart->getItems(); $cart = $cart_data['cart']; $x = 0; $promo_option = array(); foreach ($cart as $group => $option) { foreach ($option as $key => $item) { $duration = $item['duration']; if ($item['duration'] == 'semiannually') $duration = 'semi-annually'; switch ($group) { case 'domains': $tld = explode('.', $item['name'], 2); if ($item['price'] > 0) { if (in_array('D.' . $tld[1], $str_ids) && in_array($item['duration'] . 'years', $str_cycle)) { if (isset($item['original_price']) && $item['original_price'] != '') $price = $item['original_price']; else $price = $item['price']; $new_price = $whmcs->promotionType($active_promo, $price); if ($price < 0) $price = 0; if ($new_price < 0) $new_price = 0; $item['original_price'] = $price; $item['price'] = $new_price; $item['promo'] = true; $promo_option['data'][$x]['group'] = $group; $promo_option['data'][$x]['data'] = $item; $x += 1; } else { if (isset($item['original_price']) && $item['original_price'] != '') $price = $item['original_price']; else $price = $item['price']; $item['promo'] = false; $item['original_price'] = $price; } $whmcsis_cart->updateItemQuantity('cart', $group, $key, $item); $whmcsis_cart->addItem('promocode', $promo); } break; case 'dedicated': case 'cloud': case 'housing': if (in_array($item["id"], $str_ids) && in_array($duration, $str_cycle)) { if (isset($item['original_price']) && $item['original_price'] != '') $price = $item['original_price']; else $price = $item['prod_price']; $new_price = $whmcs->promotionType($active_promo, $price); if ($price < 0) $price = 0; if ($new_price < 0) $new_price = 0; $item['original_price'] = $price; $item['prod_price'] = $new_price; $item['price'] = $new_price; $item['promo'] = true; $promo_option['data'][$x]['group'] = $group; $promo_option['data'][$x]['data'] = $item; $promo_option['data'][$x]['key'] = $key; $x += 1; } else { if (isset($item['original_price']) && $item['original_price'] != '') $price = $item['original_price']; else $price = $item['prod_price']; $item['promo'] = false; $item['price'] = $price; $item['original_price'] = $price; } $whmcsis_cart->updateItemQuantity('cart', $group, $key, $item); $whmcsis_cart->addItem('promocode', $promo); break; case 'ssl': foreach ($item['configoption'] as $kssl => $dssl) { $ssl_period = $dssl['ssl_period'] . 'years'; } if (in_array($item["id"], $str_ids) && in_array($ssl_period, $str_cycle)) { if ($item['original_price']) $price = $item['original_price']; else $price = $item['price']; $new_price = $whmcs->promotionType($active_promo, $price); if ($price < 0) $price = 0; if ($new_price < 0) $new_price = 0; //pre($new_price); //pre($item); $item['original_price'] = $price; $item['prod_price'] = $new_price; $item['promo'] = true; /* ADICIONAR EXTRA AO PRECO */ /* if ($item['configoption']) { foreach ($item['configoption'] as $k => $v) { if ($v['value']) $new_price = $new_price + (($whmcs->calc_extras_cost($v['price'], $item['duration']))); else unset($data['configoption'][$k]); } } */ $item['price'] = $new_price + $item['domain']['price']; $promo_option['data'][$x]['group'] = $group; $promo_option['data'][$x]['data'] = $item; $promo_option['data'][$x]['key'] = $key; $x += 1; } else { $price = $item['prod_price']; if ($price == '') $price = $item['price']; /* ADICIONAR EXTRA AO PRECO */ if ($item['configoption']) { foreach ($item['configoption'] as $k => $v) { if ($v['value']) $price = $price + (($whmcs->calc_extras_cost($v['price'], $item['duration']))); else unset($item['configoption'][$k]); } } $item['promo'] = false; $item['price'] = $price + $item['domain']['price']; $item['original_price'] = $price; $promo_option['data'][$x]['group'] = $group; $promo_option['data'][$x]['data'] = $item; $promo_option['data'][$x]['key'] = $key; $x += 1; } $whmcsis_cart->updateItemQuantity('cart', $group, $key, $item); $whmcsis_cart->addItem('promocode', $promo); break; case 'webstore': $tld = explode('.', $item['domain']['name'], 2); if ($item['domain']['price'] > 0) { if (in_array('D.' . $tld[1], $str_ids) && in_array($item['domain']['period'] . 'years', $str_cycle)) { if (isset($item['domain']['original_price']) && $item['domain']['original_price'] != '') $price = $item['domain']['original_price']; else $price = $item['domain']['price']; $new_price = $whmcs->promotionType($active_promo, $price); if ($price < 0) $price = 0; if ($new_price < 0) $new_price = 0; $item['domain']['original_price'] = $price; $item['domain']['price'] = $new_price; $item['domain']['promo'] = true; } else { if (isset($item['domain']['original_price']) && $item['domain']['original_price'] != '') $price = $item['domain']['original_price']; else $price = $item['domain']['price']; $item['domain']['promo'] = false; $item['domain']['original_price'] = $price; } } if (in_array($item["id"], $str_ids) && in_array($duration, $str_cycle)) { $price = $item['prod_price']; if ($price == '') $price = $item['price']; $new_price = $whmcs->promotionType($active_promo, $price); if ($price < 0) $price = 0; if ($new_price < 0) $new_price = 0; $item['original_price'] = $price; $item['prod_price'] = $new_price; $item['promo'] = true; /* ADICIONAR EXTRA AO PRECO */ if ($item['configoption']) { foreach ($item['configoption'] as $k => $v) { if ($v['value']) $new_price = $new_price + $value['value']; else unset($data['configoption'][$k]); } } if ($item['addons']) { foreach ($item['addons'] as $k => $v) { if ($v['value']) $new_price = $new_price + $v['price']; else unset($item['addons'][$k]); } } $item['price'] = $new_price + $item['domain']['price']; $promo_option['data'][$x]['group'] = $group; $promo_option['data'][$x]['data'] = $item; $promo_option['data'][$x]['key'] = $key; $x += 1; } else { $price = $item['prod_price']; if ($price == '') $price = $item['price']; /* ADICIONAR EXTRA AO PRECO */ if ($item['configoption']) { foreach ($item['configoption'] as $k => $v) { if ($v['value']) $price = $price + $value['value']; else unset($item['configoption'][$k]); } } if ($item['addons']) { foreach ($item['addons'] as $k => $v) { if ($v['value']) $price = $price + $v['price']; else unset($item['addons'][$k]); } } $item['promo'] = false; $item['price'] = $price + $item['domain']['price']; $item['original_price'] = $price; $promo_option['data'][$x]['group'] = $group; $promo_option['data'][$x]['data'] = $item; $promo_option['data'][$x]['key'] = $key; $x += 1; } $whmcsis_cart->updateItemQuantity('cart', $group, $key, $item); $whmcsis_cart->addItem('promocode', $promo); break; default: $tld = explode('.', $item['domain']['name'], 2); if ($item['domain']['price'] > 0) { if (in_array('D.' . $tld[1], $str_ids) && in_array($item['domain']['period'] . 'years', $str_cycle)) { if (isset($item['domain']['original_price']) && $item['domain']['original_price'] != '') $price = $item['domain']['original_price']; else $price = $item['domain']['price']; $new_price = $whmcs->promotionType($active_promo, $price); if ($price < 0) $price = 0; if ($new_price < 0) $new_price = 0; $item['domain']['original_price'] = $price; $item['domain']['price'] = $new_price; $item['domain']['promo'] = true; } else { if (isset($item['domain']['original_price']) && $item['domain']['original_price'] != '') $price = $item['domain']['original_price']; else $price = $item['domain']['price']; $item['domain']['promo'] = false; $item['domain']['original_price'] = $price; } } if (in_array($item["id"], $str_ids) && in_array($duration, $str_cycle)) { $price = $item['prod_price']; if ($price == '') $price = $item['price']; $new_price = $whmcs->promotionType($active_promo, $price); if ($price < 0) $price = 0; if ($new_price < 0) $new_price = 0; $item['original_price'] = $price; $item['prod_price'] = $new_price; $item['promo'] = true; /* ADICIONAR EXTRA AO PRECO */ if ($item['configoption']) { foreach ($item['configoption'] as $k => $v) { if ($v['value']) $new_price = $new_price + (($whmcs->calc_extras_cost($v['price'], $item['duration'])) * $value['value']); else unset($data['configoption'][$k]); } } if ($item['addons']) { foreach ($item['addons'] as $k => $v) { if ($v['value']) $new_price = $new_price + $v['price']; else unset($item['addons'][$k]); } } $item['price'] = $new_price + $item['domain']['price']; $promo_option['data'][$x]['group'] = $group; $promo_option['data'][$x]['data'] = $item; $promo_option['data'][$x]['key'] = $key; $x += 1; } else { $price = $item['prod_price']; if ($price == '') $price = $item['price']; /* ADICIONAR EXTRA AO PRECO */ if ($item['configoption']) { foreach ($item['configoption'] as $k => $v) { if ($v['value']) $price = $price + (($whmcs->calc_extras_cost($v['price'], $item['duration'])) * $v['value']); else unset($item['configoption'][$k]); } } if ($item['addons']) { foreach ($item['addons'] as $k => $v) { if ($v['value']) $price = $price + $v['price']; else unset($item['addons'][$k]); } } $item['promo'] = false; $item['price'] = $price + $item['domain']['price']; $item['original_price'] = $price; $promo_option['data'][$x]['group'] = $group; $promo_option['data'][$x]['data'] = $item; $promo_option['data'][$x]['key'] = $key; $x += 1; } $whmcsis_cart->updateItemQuantity('cart', $group, $key, $item); $whmcsis_cart->addItem('promocode', $promo); break; } } } $promo_option['promocode'] = $promo; $whmcsis_cart->save(); header("Content-type: application/json"); echo json_encode($promo_option); die(); }
  6. 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
  7. 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!
  8. 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
  9. I havent run it yet. I only have 1 currency. "€". Is my action correct??
  10. 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';
  11. 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
  12. 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
  13. 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!
  14. 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
  15. 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
×
×
  • 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