Recharge with additional Cost

This commit is contained in:
Ibnu Maksum 2024-03-13 14:53:33 +07:00
parent 60c573821b
commit c8f4574984
No known key found for this signature in database
GPG Key ID: 7FC82848810579E5

View File

@ -135,6 +135,10 @@ switch ($action) {
$channel = $admin['fullname'];
$cust = User::_info($id_customer);
if ($using == 'balance' && $config['enable_balance'] == 'yes') {
$add_cost = User::getAttribute("Additional Cost", $id_customer);
if(empty($add_cost)){
$add_cost = 0;
}
$plan = ORM::for_table('tbl_plans')->find_one($planId);
if (!$cust) {
r2(U . 'prepaid/recharge', 'e', Lang::T('Customer not found'));
@ -142,7 +146,7 @@ switch ($action) {
if (!$plan) {
r2(U . 'prepaid/recharge', 'e', Lang::T('Plan not found'));
}
if ($cust['balance'] < $plan['price']) {
if ($cust['balance'] < ($plan['price']+$add_cost)) {
r2(U . 'prepaid/recharge', 'e', Lang::T('insufficient balance'));
}
$gateway = 'Recharge Balance';
@ -153,7 +157,7 @@ switch ($action) {
}
if (Package::rechargeUser($id_customer, $server, $planId, $gateway, $channel)) {
if ($using == 'balance') {
Balance::min($cust['id'], $plan['price']);
Balance::min($cust['id'], $plan['price']+$add_cost);
}
$in = ORM::for_table('tbl_transactions')->where('username', $cust['username'])->order_by_desc('id')->find_one();
Package::createInvoice($in);