function get_xhr($type = null) { if ($this->checkAuth()) { $headers = getallheaders(); $userPay = new PaymentSystem(); $userPay->loadUser(mb_strtolower($headers['Auth-User'])); if (is_null($type)) { echo json_encode(StatusReturn::S200($userPay->getAllBillingInfo()), JSON_NUMERIC_CHECK); } else { if ($type == 'invoices') { echo json_encode(StatusReturn::S200($userPay->getCurrentInvoices()), JSON_NUMERIC_CHECK); } else { if ($type == 'history') { echo json_encode(StatusReturn::S200($userPay->getPaymentHistory()), JSON_NUMERIC_CHECK); } else { if ($type == 'profiles') { echo json_encode(StatusReturn::S200($userPay->getPaymentProfiles()), JSON_NUMERIC_CHECK); } else { echo json_encode(StatusReturn::E404('404 Not Found!')); } } } } } }