/**
  * @link http://docs.whmcs.com/API:Get_Credits	
  * @param clientid - The Client ID you wish to obtain the results for
  * @return json
  */
 public function getcredits()
 {
     $clientid = isset($_GET['clientid']) ? $_GET['clientid'] : 'null';
     $email = isset($_GET['email']) ? $_GET['email'] : 'null';
     if ($clientid == 'null' && $email != 'null') {
         $clientid = Helper::clientid($email);
         $_GET['clientid'] = $clientid;
     } elseif ($clientid == 'null' && $email == 'null') {
         $result['result'] = 'error';
         $result['message'] = 'Silakan masukan email / clientid';
         return json_encode($result);
     } else {
         $clientid = $clientid;
     }
     if (\Config::get('whmcs.useApiKey') == true) {
         $getkey = Helper::api_key();
         if ($getkey != 'null') {
             $cek = Helper::cek($getkey);
             if ($cek != 0) {
                 $action = "getcredits";
                 $datas = WhmcsBase::init($action, Helper::get());
                 $result = json_encode($datas);
                 return $result;
             } else {
                 $result['result'] = 'error';
                 $result['message'] = 'Api key belum terdaftar';
                 return json_encode($result);
             }
         } else {
             $result['result'] = 'error';
             $result['message'] = 'Your API key is missing';
             return json_encode($result);
         }
     } else {
         $action = "getcredits";
         $datas = WhmcsBase::init($action, Helper::get());
         $result = json_encode($datas);
         return $result;
     }
 }
Ejemplo n.º 2
0
 /**
  * @link http://docs.whmcs.com/API:Add_Order
  * @param clientid - client id for order
  * @param pid - product id
  * @param domain - domain name
  * @param billingcycle - onetime, monthly, quarterly, semiannually, etc..
  * @param domaintype - set for domain registration - register or transfer
  * @param regperiod = 1,2,3,etc...
  * @param eppcode - if domain transfer
  * @param nameserver1 - first nameserver (req for domain reg only)
  * @param paymentmethod - paypal, authorize, etc...
  * @param customfields - a base64 encoded serialized array of custom field values
  * @param configoptions - a base64 encoded serialized array of configurable product options
  * @param priceoverride - allows you to pass in a custom price override for the product (domains are not products)
  * @param promocode - pass coupon code to apply to the order
  * @param promooverride - pass this to override the products a coupon applies to (like through the admin area)
  * @param affid - affiliate ID if you want to assign the order to an affiliate
  * @param noinvoice - set true to not generate an invoice for this order
  * @param noinvoiceemail - set true to generate but not send the invoice notification email
  * @param noemail - set true to surpress the order confirmation email
  * @param clientip - can be used to pass the customers IP
  * @param addons - comma seperated list of addon ids
  * @return json
  */
 public function addorder()
 {
     $clientid = isset($_GET['clientid']) ? $_GET['clientid'] : 'null';
     $email = isset($_GET['email']) ? $_GET['email'] : 'null';
     if ($clientid == 'null' && $email != 'null') {
         $clientid = Helper::clientid($email);
         $_GET['clientid'] = $clientid;
     } elseif ($clientid == 'null' && $email == 'null') {
         $result['result'] = 'error';
         $result['message'] = 'Silakan masukan email / clientid';
         return json_encode($result);
     } else {
         $clientid = $clientid;
     }
     if (\Config::get('whmcs.useApiKey') == true) {
         $getkey = Helper::api_key();
         if ($getkey != 'null') {
             $cek = Helper::cek($getkey);
             if ($cek != 0) {
                 if (\Config::get('whmcs.useDeposit') == true) {
                     $client = new Client();
                     $credit = json_decode($client->getclientsdetails());
                     if ($credit->result == "success") {
                         if ($credit->credit == "0.00") {
                             $result['result'] = 'error';
                             $result['message'] = "You dont have Credit";
                             return json_encode($result);
                         } else {
                             /**
                              * @param pname product name
                              * @return int
                              */
                             if (!empty(Helper::get()['pname'])) {
                                 $data = OrderHandlingModel::idByName(Helper::get()['pname']);
                                 if ($data != 0) {
                                     $_GET['pid'] = $data;
                                     $ip = isset(Helper::get()['ip']) ? Helper::get()['ip'] : 'null';
                                     if ($ip != 'null') {
                                         $customfields = OrderHandlingModel::customfieldsID(array("pid" => $data));
                                         $fields = [$customfields => $ip];
                                         $_GET['customfields'] = json_encode($fields);
                                     }
                                 }
                             }
                             $action = "addorder";
                             $datas = WhmcsBase::init($action, Helper::get());
                             $result = json_encode($datas);
                             return $result;
                         }
                     } else {
                         $result['result'] = 'error';
                         $result['message'] = $credit->message;
                         return json_encode($result);
                     }
                 } else {
                     $action = "addorder";
                     $datas = WhmcsBase::init($action, Helper::get());
                     $result = json_encode($datas);
                     return $result;
                 }
             } else {
                 $result['result'] = 'error';
                 $result['message'] = 'Api key belum terdaftar';
                 return json_encode($result);
             }
         } else {
             $result['result'] = 'error';
             $result['message'] = 'Your API key is missing';
             return json_encode($result);
         }
     } else {
         $action = "addorder";
         $datas = WhmcsBase::init($action, Helper::get());
         $result = json_encode($datas);
         return $result;
     }
 }