コード例 #1
0
ファイル: topup.php プロジェクト: anggagewor/whmcs-api
 $param["clientid"] = $custom->byCardId($_POST['card_id']);
 $param["amount"] = $_POST['nominal'];
 $param["description"] = "Topup Saldo {$param["amount"]}";
 // start $param["clientid"]
 if (!$param["clientid"] == false) {
     // tambah credit
     $payments = new payments();
     $topup = json_decode($payments->Add_Credit($param));
     //membuat invoice
     $invoice["userid"] = $param["clientid"];
     $invoice["date"] = date("Ymd");
     $invoice["duedate"] = date("Ymd");
     $invoice["sendinvoice"] = false;
     $invoice["itemdescription1"] = $param["description"];
     $invoice["itemamount1"] = $param["amount"];
     $createInvoice = json_decode($payments->Create_Invoice($invoice));
     // update invoice
     $postfields["invoiceid"] = $createInvoice->invoiceid;
     $postfields["status"] = 'Paid';
     $updateInvoice = json_decode($payments->Update_Invoice($postfields));
     if ($updateInvoice->result == 1) {
         $result['result'] = 1;
         echo json_encode($result);
     } else {
         $result['result'] = 0;
         echo json_encode($result);
     }
     // $param["clientid"]
 } else {
     $result['result'] = 0;
     echo json_encode($result);