Payment Gateway Audit page

This commit is contained in:
Ibnu Maksum 2024-08-01 17:55:58 +07:00
parent efdb0fc6bc
commit b64e841bde
No known key found for this signature in database
GPG Key ID: 7FC82848810579E5
10 changed files with 242 additions and 34 deletions

View File

@ -13,13 +13,13 @@ class Admin
{ {
global $db_pass, $config; global $db_pass, $config;
$enable_session_timeout = $config['enable_session_timeout']; $enable_session_timeout = $config['enable_session_timeout'];
if ($enable_session_timeout) { if ($enable_session_timeout) {
$timeout = 0; $timeout = 0;
if($config['session_timeout_duration']){ if ($config['session_timeout_duration']) {
$timeout = intval($config['session_timeout_duration']); $timeout = intval($config['session_timeout_duration']);
} }
$session_timeout_duration = $timeout * 60; // Convert minutes to seconds $session_timeout_duration = $timeout * 60; // Convert minutes to seconds
} }
if (isset($_SESSION['aid']) && isset($_SESSION['aid_expiration']) && $_SESSION['aid_expiration'] > time()) { if (isset($_SESSION['aid']) && isset($_SESSION['aid_expiration']) && $_SESSION['aid_expiration'] > time()) {
return $_SESSION['aid']; return $_SESSION['aid'];

View File

@ -11,7 +11,7 @@ class Lang
public static function T($key) public static function T($key)
{ {
global $_L, $lan_file, $config; global $_L, $lan_file, $config;
if(is_array($_SESSION['Lang'])){ if (is_array($_SESSION['Lang'])) {
$_L = array_merge($_L, $_SESSION['Lang']); $_L = array_merge($_L, $_SESSION['Lang']);
} }
$key = preg_replace('/\s+/', ' ', $key); $key = preg_replace('/\s+/', ' ', $key);
@ -124,20 +124,20 @@ class Lang
} }
} }
$when = ""; $when = "";
if(time()>strtotime($datetime)){ if (time() > strtotime($datetime)) {
$when = Lang::T('ago'); $when = Lang::T('ago');
}else{ } else {
$when = ''; $when = '';
} }
if (!$full) if (!$full)
$string = array_slice($string, 0, 1); $string = array_slice($string, 0, 1);
if($string){ if ($string) {
if(empty($when)){ if (empty($when)) {
return '<b>'. implode(', ', $string) .'</b>'; return '<b>' . implode(', ', $string) . '</b>';
}else{ } else {
return implode(', ', $string) .' '. $when; return implode(', ', $string) . ' ' . $when;
} }
}else{ } else {
return Lang::T('just now'); return Lang::T('just now');
} }
} }
@ -245,16 +245,30 @@ class Lang
return $txt; return $txt;
} }
public static function maskText($text){ public static function maskText($text)
{
$len = strlen($text); $len = strlen($text);
if($len < 3){ if ($len < 3) {
return "***"; return "***";
}else if($len<5){ } else if ($len < 5) {
return substr($text,0,1)."***".substr($text,-1,1); return substr($text, 0, 1) . "***" . substr($text, -1, 1);
}else if($len<8){ } else if ($len < 8) {
return substr($text,0,2)."***".substr($text,-2,2); return substr($text, 0, 2) . "***" . substr($text, -2, 2);
}else{ } else {
return substr($text,0,4)."******".substr($text,-3,3); return substr($text, 0, 4) . "******" . substr($text, -3, 3);
} }
} }
// echo Json array to text
public static function jsonArray2text($array, $start = '', $result = '')
{
foreach ($array as $k => $v) {
if (is_array($v)) {
$result .= self::jsonArray2text($v, "$start$k.", '');
} else {
$result .= "$start$k = " . strval($v) . "\n";
}
}
return $result;
}
} }

View File

@ -460,7 +460,6 @@ switch ($action) {
} else { } else {
$d->price = ($plan['price'] + $add_cost + $tax); $d->price = ($plan['price'] + $add_cost + $tax);
} }
//$d->price = ($plan['price'] + $add_cost);
$d->created_date = date('Y-m-d H:i:s'); $d->created_date = date('Y-m-d H:i:s');
$d->status = 1; $d->status = 1;
$d->save(); $d->save();

View File

@ -19,6 +19,36 @@ if ($action == 'delete') {
r2(U . 'paymentgateway', 's', Lang::T('Payment Gateway Deleted')); r2(U . 'paymentgateway', 's', Lang::T('Payment Gateway Deleted'));
} }
if ($action == 'audit') {
$pg = alphanumeric($routes[2]);
$q = alphanumeric(_req('q'),'-._ ');
$query = ORM::for_table('tbl_payment_gateway')->order_by_desc("id");
$query->selects('id', 'username', 'gateway', 'gateway_trx_id', 'plan_id', 'plan_name', 'routers_id', 'routers', 'price', 'pg_url_payment', 'payment_method', 'payment_channel', 'expired_date', 'created_date', 'paid_date', 'trx_invoice', 'status');
$query->where('gateway', $pg);
if(!empty($q)) {
$query->whereRaw("(gateway_trx_id LIKE '%$q%' OR username LIKE '%$q%' OR routers LIKE '%$q%' OR plan_name LIKE '%$q%')");
$append_url = 'q='. urlencode($q);
}
$pgs = Paginator::findMany($query, ["search" => $search], 50, $append_url);
$ui->assign('_title', 'Payment Gateway Audit');
$ui->assign('pgs', $pgs);
$ui->assign('pg', $pg);
$ui->assign('q', $q);
$ui->display('paymentgateway-audit.tpl');
die();
}
if ($action == 'auditview') {
$pg = alphanumeric($routes[2]);
$d = ORM::for_table('tbl_payment_gateway')->find_one($pg);
$ui->assign('_title', 'Payment Gateway Audit View');
$ui->assign('pg', $d);
$ui->display('paymentgateway-audit-view.tpl');
die();
}
if (_post('save') == 'actives') { if (_post('save') == 'actives') {
$pgs = ''; $pgs = '';
if(is_array($_POST['pgs'])){ if(is_array($_POST['pgs'])){

View File

@ -681,5 +681,10 @@
"Idle_Timeout__Logout_Admin_if_Idle_for_xx_minutes": "Idle Timeout, Logout Admin if Idle for xx minutes", "Idle_Timeout__Logout_Admin_if_Idle_for_xx_minutes": "Idle Timeout, Logout Admin if Idle for xx minutes",
"Failed_to_create_transaction__please_tell_seller_": "Failed to create transaction, please tell seller.", "Failed_to_create_transaction__please_tell_seller_": "Failed to create transaction, please tell seller.",
"paid_off": "paid off", "paid_off": "paid off",
"Sync_account_if_you_failed_login_to_internet": "Sync account if you failed login to internet" "Sync_account_if_you_failed_login_to_internet": "Sync account if you failed login to internet",
"Channel": "Channel",
"Payment_Link": "Payment Link",
"Created": "Created",
"2": "2",
"_": "-"
} }

View File

@ -130,8 +130,8 @@
"ALTER TABLE `tbl_voucher` ADD `used_date` DATETIME NULL DEFAULT NULL AFTER `status`;", "ALTER TABLE `tbl_voucher` ADD `used_date` DATETIME NULL DEFAULT NULL AFTER `status`;",
"UPDATE `tbl_voucher` SET `used_date`=now() WHERE `status`=1;" "UPDATE `tbl_voucher` SET `used_date`=now() WHERE `status`=1;"
], ],
"2024.7.31" : [ "2024.8.1" : [
"ALTER TABLE `tbl_payment_gateway` CHANGE `gateway_trx_id` `gateway_trx_id` VARCHAR(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL;", "ALTER TABLE `tbl_payment_gateway` CHANGE `gateway_trx_id` `gateway_trx_id` VARCHAR(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '';",
"ALTER TABLE `tbl_payment_gateway` CHANGE `pg_url_payment` `pg_url_payment` VARCHAR(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL;" "ALTER TABLE `tbl_payment_gateway` CHANGE `pg_url_payment` `pg_url_payment` VARCHAR(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '';"
] ]
} }

View File

@ -0,0 +1,79 @@
{include file="sections/header.tpl"}
<div class="row">
<div class="col-sm-5">
<div class="panel panel-hovered mb20 panel-primary">
<div class="panel-heading">
{$pg['gateway_trx_id']}
</div>
<div class="panel-body">
<ul class="list-group list-group-unbordered">
<li class="list-group-item">
<b>TRX ID</b> <span class="pull-right">&nbsp;{$pg['id']}&nbsp;</span>
</li>
<li class="list-group-item">
<b>{Lang::T('Invoice')}</b> <span class="pull-right">&nbsp;
<a href="{$_url}reports/activation&q={$pg['trx_invoice']}" class="text-black">{$pg['trx_invoice']}</a>
&nbsp;</span>
</li>
<li class="list-group-item">
<b>{Lang::T('Status')}</b> <span
class="pull-right">&nbsp;{if $pg['status'] == 1}UNPAID{elseif $pg['status'] == 2}PAID{elseif $pg['status'] == 3}FAILED{else}CANCELED{/if}&nbsp;</span>
</li>
<li class="list-group-item">
<b>{Lang::T('Username')}</b>
<span class="pull-right">&nbsp;<a href="{$_url}customers/viewu/{$pg['username']}" class="text-black">{$pg['username']}</a>&nbsp;</span>
</li>
<li class="list-group-item">
<b>{Lang::T('Plan Name')}</b> <span class="pull-right">&nbsp;{$pg['plan_name']}&nbsp;</span>
</li>
<li class="list-group-item">
<b>{Lang::T('Routers')}</b> <span class="pull-right">&nbsp;{$pg['routers']}&nbsp;</span>
</li>
<li class="list-group-item">
<b>{Lang::T('Price')}</b> <span
class="pull-right">&nbsp;{Lang::moneyFormat($pg['price'])}&nbsp;</span>
</li>
<li class="list-group-item">
<b>{Lang::T('Payment Link')}</b> <span class="pull-right">&nbsp;{if $pg['pg_url_payment']}
<a href="{$pg['pg_url_payment']}" target="_blank" class="btn btn-xs btn-default"
rel="noopener noreferrer">open</a>
{/if}&nbsp;</span>
</li>
<li class="list-group-item">
<b>{Lang::T('Channel')}</b> <span class="pull-right">&nbsp;{$pg['payment_method']} -
{$pg['payment_channel']}&nbsp;</span>
</li>
<li class="list-group-item">
<b>{Lang::T('Created')}</b> <span
class="pull-right">&nbsp;{if $pg['created_date'] != null}{Lang::dateTimeFormat($pg['created_date'])}{/if}&nbsp;</span>
</li>
<li class="list-group-item">
<b>{Lang::T('Expired')}</b> <span
class="pull-right">&nbsp;{if $pg['expired_date'] != null}{Lang::dateTimeFormat($pg['expired_date'])}{/if}&nbsp;</span>
</li>
<li class="list-group-item">
<b>{Lang::T('Paid')}</b> <span
class="pull-right">&nbsp;{if $pg['paid_date'] != null}{Lang::dateTimeFormat($pg['paid_date'])}{/if}&nbsp;</span>
</li>
</ul>
</div>
</div>
</div>
</div>
<div class="panel panel-hovered mb20 panel-primary">
<div class="panel-heading">
Response when request payment
</div>
<pre class="panel-body p-1">{if $pg['pg_request'] != null}{Lang::jsonArray2text(json_decode($pg['pg_request'], true))}{/if}</pre>
</div>
<div class="panel panel-hovered mb20 panel-primary">
<div class="panel-heading">
Response when payment PAID
</div>
<pre class="panel-body p-1">{if $pg['pg_request'] != null}{Lang::jsonArray2text(json_decode($pg['pg_paid_response'], true))}{/if}</pre>
</div>
{include file="sections/footer.tpl"}

View File

@ -0,0 +1,71 @@
{include file="sections/header.tpl"}
<div class="panel panel-hovered mb20 panel-primary">
<div class="panel-heading">
{ucwords($pg)}
</div>
<div class="panel-body">
<form id="site-search" method="post" action="{$_url}paymentgateway/audit/{$pg}">
<div class="input-group">
<input type="text" name="q" class="form-control" placeholder="{Lang::T('Search')}..."
value="{$q}">
<div class="input-group-btn">
<button type="submit" class="btn btn-danger" title="Clear Search Query"
href="{$_url}plan/list"><span class="glyphicon glyphicon-search"></span></button>
</div>
</div>
</form>
<div class="table-responsive">
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th>TRX ID</th>
<th>PG ID</th>
<th>{Lang::T('Username')}</th>
<th>{Lang::T('Plan Name')}</th>
<th>{Lang::T('Routers')}</th>
<th>{Lang::T('Price')}</th>
<th>{Lang::T('Payment Link')}</th>
<th>{Lang::T('Channel')}</th>
<th>{Lang::T('Created')}</th>
<th>{Lang::T('Expired')}</th>
<th>{Lang::T('Paid')}</th>
<th>{Lang::T('Invoice')}</th>
<th>{Lang::T('Status')}</th>
</tr>
</thead>
<tbody>
{foreach $pgs as $pg}
<tr class="{if $pg['status'] == 1}warning{elseif $pg['status'] == 2}success{else}danger{/if}">
<td>{$pg['id']}</td>
<td><a href="{$_url}paymentgateway/audit-view/{$pg['id']}"
class="text-black">{$pg['gateway_trx_id']}</a></td>
<td><a href="{$_url}customers/viewu/{$pg['username']}" class="text-black">{$pg['username']}</a>
</td>
<td>{$pg['plan_name']}</td>
<td>{$pg['routers']}</td>
<td>{Lang::moneyFormat($pg['price'])}</td>
<td>
{if $pg['pg_url_payment']}
<a href="{$pg['pg_url_payment']}" target="_blank" class="btn btn-xs btn-default btn-block"
rel="noopener noreferrer">open</a>
{/if}
</td>
<td>{$pg['payment_method']} - {$pg['payment_channel']}</td>
<td>{if $pg['created_date'] != null}{Lang::dateTimeFormat($pg['created_date'])}{/if}</td>
<td>{if $pg['expired_date'] != null}{Lang::dateTimeFormat($pg['expired_date'])}{/if}</td>
<td>{if $pg['paid_date'] != null}{Lang::dateTimeFormat($pg['paid_date'])}{/if}</td>
<td>{if $pg['trx_invoice']}<a href="{$_url}reports/activation&q={$pg['trx_invoice']}"
class="text-black">{$pg['trx_invoice']}</a>{/if}</td>
<td>{if $pg['status'] == 1}UNPAID{elseif $pg['status'] == 2}PAID{elseif $pg['status'] == 3}FAILED{else}CANCELED{/if}
</td>
</tr>
{/foreach}
</tbody>
</table>
</div>
{include file="pagination.tpl"}
<a href="{$_url}paymentgateway/" class="btn btn-default btn-xs">kembali</a>
</div>
</div>
{include file="sections/footer.tpl"}

View File

@ -14,9 +14,19 @@
<td><a href="{$_url}paymentgateway/{$pg}" <td><a href="{$_url}paymentgateway/{$pg}"
class="btn btn-block btn-{if in_array($pg, $actives)}info{else}default{/if} text-left">{ucwords($pg)}</a> class="btn btn-block btn-{if in_array($pg, $actives)}info{else}default{/if} text-left">{ucwords($pg)}</a>
</td> </td>
<td width="10"><a href="{$_url}paymentgateway/delete/{$pg}" <td width="114">
onclick="return confirm('{Lang::T('Delete')} {$pg}?')" class="btn btn-danger"><i <div class="btn-group" role="group" aria-label="...">
class="glyphicon glyphicon-trash"></i></a></td> <div class="btn-group" role="group">
<a href="{$_url}paymentgateway/audit/{$pg}"
class="btn btn-success text-black">Audit</a>
</div>
<div class="btn-group" role="group">
<a href="{$_url}paymentgateway/delete/{$pg}"
onclick="return confirm('{Lang::T('Delete')} {$pg}?')"
class="btn btn-danger"><i class="glyphicon glyphicon-trash"></i></a>
</div>
</div>
</td>
</tr> </tr>
{/foreach} {/foreach}
</tbody> </tbody>

View File

@ -1,3 +1,3 @@
{ {
"version": "2024.8.1" "version": "2024.8.1.1"
} }