pay radius plan

This commit is contained in:
Ibnu Maksum 2023-10-04 17:29:11 +07:00
parent 1891dee6b2
commit 1861358415
No known key found for this signature in database
GPG Key ID: 7FC82848810579E5

View File

@ -94,7 +94,7 @@ switch ($action) {
} }
// jika url kosong, balikin ke buy // jika url kosong, balikin ke buy
if (empty($trx['pg_url_payment'])) { if (empty($trx['pg_url_payment'])) {
r2(U . "order/buy/" . $trx['routers_id'] . '/' . $trx['plan_id'], 'w', Lang::T("Checking payment")); r2(U . "order/buy/" . (($trx['routers_id'] == 0) ? $trx['routers'] : $trx['routers_id']) . '/' . $trx['plan_id'], 'w', Lang::T("Checking payment"));
} }
if ($routes['3'] == 'check') { if ($routes['3'] == 'check') {
if (!file_exists('system/paymentgateway/' . $trx['gateway'] . '.php')) { if (!file_exists('system/paymentgateway/' . $trx['gateway'] . '.php')) {
@ -135,12 +135,16 @@ switch ($action) {
r2(U . "order/package", 'e', Lang::T("Balance not enabled")); r2(U . "order/package", 'e', Lang::T("Balance not enabled"));
} }
$plan = ORM::for_table('tbl_plans')->where('enabled', '1')->find_one($routes['3']); $plan = ORM::for_table('tbl_plans')->where('enabled', '1')->find_one($routes['3']);
$router = ORM::for_table('tbl_routers')->where('enabled', '1')->find_one($routes['2']); if (empty($plan)) {
if (empty($router) || empty($plan)) {
r2(U . "order/package", 'e', Lang::T("Plan Not found")); r2(U . "order/package", 'e', Lang::T("Plan Not found"));
} }
if ($routes['2'] == 'radius') {
$router_name = 'radius';
} else {
$router_name = $plan['routers'];
}
if ($plan && $plan['enabled'] && $user['balance'] >= $plan['price']) { if ($plan && $plan['enabled'] && $user['balance'] >= $plan['price']) {
if (Package::rechargeUser($user['id'], $plan['routers'], $plan['id'], 'Customer', 'Balance')) { if (Package::rechargeUser($user['id'], $router_name, $plan['id'], 'Customer', 'Balance')) {
// if success, then get the balance // if success, then get the balance
Balance::min($user['id'], $plan['price']); Balance::min($user['id'], $plan['price']);
r2(U . "home", 's', Lang::T("Success to buy package")); r2(U . "home", 's', Lang::T("Success to buy package"));
@ -164,6 +168,11 @@ switch ($action) {
if (empty($plan)) { if (empty($plan)) {
r2(U . "order/package", 'e', Lang::T("Plan Not found")); r2(U . "order/package", 'e', Lang::T("Plan Not found"));
} }
if ($routes['2'] == 'radius') {
$router_name = 'radius';
} else {
$router_name = $plan['routers'];
}
if (isset($_POST['send']) && $_POST['send'] == 'plan') { if (isset($_POST['send']) && $_POST['send'] == 'plan') {
$target = ORM::for_table('tbl_customers')->where('username', _post('username'))->find_one(); $target = ORM::for_table('tbl_customers')->where('username', _post('username'))->find_one();
if (!$target) { if (!$target) {
@ -183,7 +192,7 @@ switch ($action) {
if ($active && $active['plan_id'] != $plan['id']) { if ($active && $active['plan_id'] != $plan['id']) {
r2(U . "order/package", 'e', Lang::T("Target has active plan, different with current plant.") . " [ <b>$active[namebp]</b> ]"); r2(U . "order/package", 'e', Lang::T("Target has active plan, different with current plant.") . " [ <b>$active[namebp]</b> ]");
} }
if (Package::rechargeUser($target['id'], $plan['routers'], $plan['id'], $user['fullname'], 'Balance')) { if (Package::rechargeUser($target['id'], $router_name, $plan['id'], $user['fullname'], 'Balance')) {
// if success, then get the balance // if success, then get the balance
Balance::min($user['id'], $plan['price']); Balance::min($user['id'], $plan['price']);
//sender //sender
@ -193,7 +202,7 @@ switch ($action) {
$d->plan_id = $plan['id']; $d->plan_id = $plan['id'];
$d->plan_name = $plan['name_plan']; $d->plan_name = $plan['name_plan'];
$d->routers_id = $routes['2']; $d->routers_id = $routes['2'];
$d->routers = $plan['routers']; $d->routers = $router_name;
$d->price = $plan['price']; $d->price = $plan['price'];
$d->payment_method = "Balance"; $d->payment_method = "Balance";
$d->payment_channel = "Send Plan"; $d->payment_channel = "Send Plan";
@ -211,7 +220,7 @@ switch ($action) {
$d->plan_id = $plan['id']; $d->plan_id = $plan['id'];
$d->plan_name = $plan['name_plan']; $d->plan_name = $plan['name_plan'];
$d->routers_id = $routes['2']; $d->routers_id = $routes['2'];
$d->routers = $plan['routers']; $d->routers = $router_name;
$d->price = $plan['price']; $d->price = $plan['price'];
$d->payment_method = "Balance"; $d->payment_method = "Balance";
$d->payment_channel = "Received Plan"; $d->payment_channel = "Received Plan";
@ -225,13 +234,12 @@ switch ($action) {
} else { } else {
r2(U . "order/package", 'e', Lang::T("Failed to Send package")); r2(U . "order/package", 'e', Lang::T("Failed to Send package"));
Message::sendTelegram("Send Package with Balance Failed\n\n#u$user[username] #send \n" . $plan['name_plan'] . Message::sendTelegram("Send Package with Balance Failed\n\n#u$user[username] #send \n" . $plan['name_plan'] .
"\nRouter: " . $plan['routers'] . "\nRouter: " . $router_name .
"\nPrice: " . $plan['price']); "\nPrice: " . $plan['price']);
} }
} }
$ui->assign('username', $_GET['u']); $ui->assign('username', $_GET['u']);
$ui->assign('router', $router); $ui->assign('router', $router_name);
$ui->assign('plan', $plan); $ui->assign('plan', $plan);
$ui->display('user-sendPlan.tpl'); $ui->display('user-sendPlan.tpl');
break; break;
@ -248,7 +256,11 @@ switch ($action) {
run_hook('customer_buy_plan'); #HOOK run_hook('customer_buy_plan'); #HOOK
include 'system/paymentgateway/' . $config['payment_gateway'] . '.php'; include 'system/paymentgateway/' . $config['payment_gateway'] . '.php';
call_user_func($config['payment_gateway'] . '_validate_config'); call_user_func($config['payment_gateway'] . '_validate_config');
if ($routes['2'] > 0) {
if ($routes['2'] == 'radius') {
$router['id'] = 0;
$router['name'] = 'radius';
} else if ($routes['2'] > 0) {
$router = ORM::for_table('tbl_routers')->where('enabled', '1')->find_one($routes['2']); $router = ORM::for_table('tbl_routers')->where('enabled', '1')->find_one($routes['2']);
} else { } else {
$router['id'] = 0; $router['id'] = 0;