$waktuSekarang = round(abs($tanggalSekarang - $TanggalDatabase) / 60, 0); if ($state == 'paid') { $result['result'] = 0; echo json_encode($result); } else { if ($waktuSekarang <= $batasWaktu) { $payments = new payments(); $noinv['invoiceid'] = $NoInvoice; $getInvoice = $payments->Get_Invoice($noinv); if ($getInvoice->result == "success") { $applyCredit['invoiceid'] = $getInvoice->invoiceid; $applyCredit['amount'] = $getInvoice->total; $apply_Credit = json_decode($payments->Apply_Credit($applyCredit)); if ($apply_Credit->result != 0) { // update tbltoken $custom->uToken($_POST['token']); $result['result'] = 1; echo json_encode($result); } else { $result['result'] = 0; echo json_encode($result); } } else { $result['result'] = 0; echo json_encode($result); } } else { $result['result'] = 0; echo json_encode($result); } }