if ($_POST) { /** * untuk mengecek apakah card id sudah terdaftar atau tidak. */ $custom = new custom(); $cekCardId = $custom->cekCardId($_POST['card_id']); // start $cekCardId if ($cekCardId != 0) { $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);