Lwks Posted August 25, 2010 Share Posted August 25, 2010 I wan't to creat a new module for whmcs allopass credition but i wan't to know something about whmcs how to credit the loged user example when the client made paiment on site.com/pay1.php he will bi redirect to page payed1.php that have this code <?php $url = "http://www.yourdomain.com/whmcs/includes/api.php"; # URL to WHMCS API file $username = "Admin"; # Admin username goes here $password = "demo"; # Admin password goes here $postfields["action"] = "addcredit"; $postfields["clientid"] = ""; $postfields["description"] = "Adding funds via custom module"; $postfields["amount"] = "1.00"; ?> But what i wan't is how to locate the clientid of the ready customer ? 0 Quote Link to comment Share on other sites More sharing options...
laszlof Posted August 25, 2010 Share Posted August 25, 2010 Its stored as a cookie ($_COOKIE) or session variable ($_SESSION) when the client is logged in. 0 Quote Link to comment Share on other sites More sharing options...
Lwks Posted August 25, 2010 Author Share Posted August 25, 2010 So what i have to do ? $postfields["clientid"] = "$_SESSION"; ?? is it true please 0 Quote Link to comment Share on other sites More sharing options...
laurens_dragicevic Posted August 25, 2010 Share Posted August 25, 2010 (edited) probably this is what he ment but don't know the exact name of the clientid of the session but you could try this, $postfields["clientid"] = $_SESSION["clientid"]; or $postfields["clientid"] = $_COOKIE["clientid"]; oh also try this one $postfields["clientid"] = $_SESSION["uid"]; You could try both not sure if it works though Edited August 25, 2010 by laurens_dragicevic 0 Quote Link to comment Share on other sites More sharing options...
Lwks Posted August 25, 2010 Author Share Posted August 25, 2010 (edited) i Tried <?php $url = "http://www.yourdomain.com/whmcs/includes/api.php"; # URL to WHMCS API file $username = "Admin"; # Admin username goes here $password = "demo"; # Admin password goes here $postfields["action"] = "addcredit"; $postfields["clientid"] = "2"; $postfields["description"] = "Adding funds via custom module"; $postfields["amount"] = "1.00"; ?> buts not working why ? do i have to include any files like configuration etc ? to update balance please ? what i need its a simple api who update Client id balance by adding amount Edited August 25, 2010 by Lwks 0 Quote Link to comment Share on other sites More sharing options...
laurens_dragicevic Posted August 25, 2010 Share Posted August 25, 2010 (edited) it could be something like this <?php $url = "http://www.yourdomain.com/whmcs/includes/api.php"; # URL to WHMCS API file $username = "Admin"; # Admin username goes here $password = "demo"; # Admin password goes here $postfields["username"] = $username; $postfields["password"] = md5($password); $postfields["action"] = "addcredit"; $postfields["clientid"] = "2"; $postfields["description"] = "Adding funds via custom module"; $postfields["amount"] = "1.00"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_TIMEOUT, 100); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields); $data = curl_exec($ch); curl_close($ch); $data = explode(";",$data); foreach ($data AS $temp) { $temp = explode("=",$temp); $results[$temp[0]] = $temp[1]; } if ($results["result"]=="success") { # Result was OK! echo "succeed"; } else { # An error occured echo "The following error occured: ".$results["message"]; } ?> Edited August 25, 2010 by laurens_dragicevic 0 Quote Link to comment Share on other sites More sharing options...
Lwks Posted August 25, 2010 Author Share Posted August 25, 2010 Thank you laurens that work perfectly but now i wanted just to edentify the loged user $postfields["clientid"] = $_COOKIE["clientid"]; ? is this will work and do i have to includ other things ? 0 Quote Link to comment Share on other sites More sharing options...
laszlof Posted August 25, 2010 Share Posted August 25, 2010 maybe, try it.. do a print_r($_COOKIE) and print_r($_SESSION) to see what is in those arrays. 0 Quote Link to comment Share on other sites More sharing options...
laurens_dragicevic Posted August 25, 2010 Share Posted August 25, 2010 how to credit the loged user example when the client made paiment on site.com/pay1.php he will bi redirect to page payed1.php that have this code Don't think its a smart idea to make something like this, why? everyone can connect to payed1.php to gain credits even when they have not paid for it, like i can see you don't have alot of knowledge of php to build a safe system. also why do you need to make something like that? you can use whmcs to buy credits. but it's possible to make a gift system out of it, which could be awsome just a note $_SESSION and $_COOKIE does not work outside domain so you cannot get the clientid, not sure if there is a way to get clientid through api 0 Quote Link to comment Share on other sites More sharing options...
laszlof Posted August 25, 2010 Share Posted August 25, 2010 not sure if there is a way to get clientid through api You could use Get_Clients (http://wiki.whmcs.com/API:Get_Clients) and search for a specific domain, email address, etc.. Obviously not the most efficient. Would probably be better/faster to write a login system and grab the client ID directly from the database. 0 Quote Link to comment Share on other sites More sharing options...
Lwks Posted August 25, 2010 Author Share Posted August 25, 2010 (edited) how it work the Getclient because i have al ready an action on my api ? and yes this wha't i wanted to do a MYSQL Query but what is the files to include etc the credit api Edited August 25, 2010 by Lwks 0 Quote Link to comment Share on other sites More sharing options...
Lwks Posted August 25, 2010 Author Share Posted August 25, 2010 (edited) how to credit the loged user example when the client made paiment on site.com/pay1.php he will bi redirect to page payed1.php that have this code Don't think its a smart idea to make something like this, why? everyone can connect to payed1.php to gain credits even when they have not paid for it, like i can see you don't have alot of knowledge of php to build a safe system. also why do you need to make something like that? you can use whmcs to buy credits. but it's possible to make a gift system out of it, which could be awsome just a note $_SESSION and $_COOKIE does not work outside domain so you cannot get the clientid, not sure if there is a way to get clientid through api i will use a Script protection Don't Crear allopass offer a script like this and wan't i wan't is to made a WHMCS module for allopass to buy credits with allopass Edited August 25, 2010 by Lwks 0 Quote Link to comment Share on other sites More sharing options...
Lwks Posted August 25, 2010 Author Share Posted August 25, 2010 (edited) <?php require("dbconnect.php"); require("includes/functions.php"); require("includes/clientareafunctions.php"); require("configuration.php"); ?> <?php mysql_query("UPDATE tblclients.serveurs_lwks SET credit =credit + 1 WHERE id = '"$_SESSION['uid']"' "); ?> i tried this but not working i don't know what is the required files tried on phpmyadmin works verry well Edited August 25, 2010 by Lwks 0 Quote Link to comment Share on other sites More sharing options...
laszlof Posted August 25, 2010 Share Posted August 25, 2010 It looks like required files are the least of your problems. You might want to outsource the project to someone who has experience developing in PHP. 0 Quote Link to comment Share on other sites More sharing options...
Lwks Posted August 25, 2010 Author Share Posted August 25, 2010 (edited) UP it work now for interested here is the code <?php require("dbconnect.php"); require("includes/functions.php"); require("includes/clientareafunctions.php"); require("configuration.php"); ?> <?php mysql_query("UPDATE tblclients SET credit =5.00"); ?> Edited August 25, 2010 by Lwks 0 Quote Link to comment Share on other sites More sharing options...
Lwks Posted August 26, 2010 Author Share Posted August 26, 2010 Now what im looking for is how to edentify the Loged user ID ? WHERE id= $_SESSION['id'] not working 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.