Multiple Payment gateway Fix

This commit is contained in:
Ibnu Maksum 2024-03-12 11:17:05 +07:00
parent 538850b323
commit 4cdde32cb1
No known key found for this signature in database
GPG key ID: 7FC82848810579E5
7 changed files with 88 additions and 47 deletions

View file

@ -2,6 +2,16 @@
# CHANGELOG # CHANGELOG
## 2024.3.12
- Check if Validity Period, so calculate price will not affected other validity
- Add firewall using .htaccess for apache only
- Multiple Payment Gateway by @Focuslinkstech
- Fix Logic Multiple Payment gateway
- Fix delete Attribute
- Allow Delete Payment Gateway
- Allow Delete Plugin
## 2024.3.6 ## 2024.3.6
- change attributes view - change attributes view

View file

@ -272,20 +272,30 @@ switch ($action) {
if (strpos($user['email'], '@') === false) { if (strpos($user['email'], '@') === false) {
r2(U . 'accounts/profile', 'e', Lang::T("Please enter your email address")); r2(U . 'accounts/profile', 'e', Lang::T("Please enter your email address"));
} }
$files = scandir($PAYMENTGATEWAY_PATH); $pgs = array_values(explode(',', $config['payment_gateway']));
foreach ($files as $file) { if(count($pgs)==0){
if (pathinfo($file, PATHINFO_EXTENSION) == 'php') { sendTelegram("Payment Gateway not set, please set it in Settings");
$pgs[] = str_replace('.php', '', $file); _log(Lang::T("Payment Gateway not set, please set it in Settings"));
r2(U . "home", 'e', Lang::T("Failed to create Transaction.."));
}
if(count($pgs)>1){
$ui->assign('pgs',$pgs );
//$ui->assign('pgs', $pgs);
$ui->assign('route2', $routes[2]);
$ui->assign('route3', $routes[3]);
//$ui->assign('plan', $plan);
$ui->display('user-selectGateway.tpl');
break;
}else{
if(empty($pgs[0])){
sendTelegram("Payment Gateway not set, please set it in Settings");
_log(Lang::T("Payment Gateway not set, please set it in Settings"));
r2(U . "home", 'e', Lang::T("Failed to create Transaction.."));
}else{
$_POST['gateway'] = $pgs[0];
} }
} }
$ui->assign('pgs', $pgs);
$ui->assign('route2', $routes[2]);
$ui->assign('route3', $routes[3]);
//$ui->assign('plan', $plan);
$ui->display('user-selectGateway.tpl');
break;
case 'buy': case 'buy':
$gateway = _post('gateway'); $gateway = _post('gateway');
if (empty($gateway) && !empty($_SESSION['gateway'])) { if (empty($gateway) && !empty($_SESSION['gateway'])) {

View file

@ -19,6 +19,24 @@ if ($action == 'delete') {
r2(U . 'paymentgateway', 's', Lang::T('Payment Gateway Deleted')); r2(U . 'paymentgateway', 's', Lang::T('Payment Gateway Deleted'));
} }
if (_post('save') == 'actives') {
$pgs = '';
if(is_array($_POST['pgs'])){
$pgs = implode(',', $_POST['pgs']);
}
$d = ORM::for_table('tbl_appconfig')->where('setting', 'payment_gateway')->find_one();
if ($d) {
$d->value = $pgs;
$d->save();
} else {
$d = ORM::for_table('tbl_appconfig')->create();
$d->setting = 'payment_gateway';
$d->value = $pgs;
$d->save();
}
r2(U . 'paymentgateway', 's', Lang::T('Payment Gateway saved successfully'));
}
if (file_exists($PAYMENTGATEWAY_PATH . DIRECTORY_SEPARATOR . $action . '.php')) { if (file_exists($PAYMENTGATEWAY_PATH . DIRECTORY_SEPARATOR . $action . '.php')) {
include $PAYMENTGATEWAY_PATH . DIRECTORY_SEPARATOR . $action . '.php'; include $PAYMENTGATEWAY_PATH . DIRECTORY_SEPARATOR . $action . '.php';
if ($_SERVER['REQUEST_METHOD'] === 'POST') { if ($_SERVER['REQUEST_METHOD'] === 'POST') {
@ -44,22 +62,9 @@ if (file_exists($PAYMENTGATEWAY_PATH . DIRECTORY_SEPARATOR . $action . '.php'))
$pgs[] = str_replace('.php', '', $file); $pgs[] = str_replace('.php', '', $file);
} }
} }
if (isset($_POST['payment_gateway'])) {
$payment_gateway = _post('payment_gateway');
$d = ORM::for_table('tbl_appconfig')->where('setting', 'payment_gateway')->find_one();
if ($d) {
$d->value = $payment_gateway;
$d->save();
} else {
$d = ORM::for_table('tbl_appconfig')->create();
$d->setting = 'payment_gateway';
$d->value = $payment_gateway;
$d->save();
}
r2(U . 'paymentgateway', 's', Lang::T('Payment Gateway saved successfully'));
}
$ui->assign('_title', 'Payment Gateway Settings'); $ui->assign('_title', 'Payment Gateway Settings');
$ui->assign('pgs', $pgs); $ui->assign('pgs', $pgs);
$ui->assign('actives', explode(',', $config['payment_gateway']));
$ui->display('paymentgateway.tpl'); $ui->display('paymentgateway.tpl');
} }
} }

View file

@ -461,5 +461,12 @@
"Customer_Announcement": "Customer Announcement", "Customer_Announcement": "Customer Announcement",
"1_Period___1_Month__Expires_the_20th_of_each_month": "1 Period = 1 Month, Expires the 20th of each month", "1_Period___1_Month__Expires_the_20th_of_each_month": "1 Period = 1 Month, Expires the 20th of each month",
"Period": "Period", "Period": "Period",
"Add": "Add" "Add": "Add",
"Select_Payment_Gateway": "Select Payment Gateway",
"Available_Payment_Gateway": "Available Payment Gateway",
"Pay_Now": "Pay Now",
"Please_select_Payment_Gateway": "Please select Payment Gateway",
"Payment_Gateway_Deleted": "Payment Gateway Deleted",
"Payment_Gateway_not_set__please_set_it_in_Settings": "Payment Gateway not set, please set it in Settings",
"Failed_to_create_Transaction__": "Failed to create Transaction.."
} }

View file

@ -1,22 +1,31 @@
{include file="sections/header.tpl"} {include file="sections/header.tpl"}
<div class="row"> <form method="post">
<div class="col-md-6 col-md-offset-3"> <div class="row">
<div class="panel panel-info panel-hovered"> <div class="col-md-6 col-md-offset-3">
<div class="panel-heading">{Lang::T('Payment Gateway')}</div> <div class="panel panel-info panel-hovered">
<div class="table-responsive"> <div class="panel-heading">{Lang::T('Payment Gateway')}</div>
<table class="table table-striped table-condensed"> <div class="table-responsive">
<tbody> <table class="table table-striped table-condensed">
{foreach $pgs as $pg} <tbody>
<tr> {foreach $pgs as $pg}
<td><a href="{$_url}paymentgateway/{$pg}" <tr>
class="btn btn-block btn-default text-left">{ucwords($pg)}</a></td> <td width="10" align="center" valign="center"><input type="checkbox" name="pgs[]"
<td width="10"><a href="{$_url}paymentgateway/delete/{$pg}" onclick="return confirm('{Lang::T('Delete')} {$pg}?')" class="btn btn-danger"><i {if in_array($pg, $actives)}checked{/if}
class="glyphicon glyphicon-trash"></i></a></td> value="{$pg}"></td>
</tr> <td><a href="{$_url}paymentgateway/{$pg}"
{/foreach} class="btn btn-block btn-{if in_array($pg, $actives)}info{else}default{/if} text-left">{ucwords($pg)}</a></td>
</tbody> <td width="10"><a href="{$_url}paymentgateway/delete/{$pg}"
</table> onclick="return confirm('{Lang::T('Delete')} {$pg}?')" class="btn btn-danger"><i
class="glyphicon glyphicon-trash"></i></a></td>
</tr>
{/foreach}
</tbody>
</table>
</div>
<div class="panel-footer"><button type="submit"
class="btn btn-primary btn-block" name="save" value="actives">{Lang::T('Save Changes')}</button></div>
</div> </div>
</div> </div>
</div> </div>
</form>
{include file="sections/footer.tpl"} {include file="sections/footer.tpl"}

View file

@ -11,8 +11,8 @@
<div class="col-md-8"> <div class="col-md-8">
<select name="gateway" id="gateway" class="form-control"> <select name="gateway" id="gateway" class="form-control">
{foreach $pgs as $pg} {foreach $pgs as $pg}
<option value="{$pg}"> <option value="{$pg}">
{ucwords($pg)}</option> {ucwords($pg)}</option>
{/foreach} {/foreach}
</select> </select>
</div> </div>

View file

@ -1,3 +1,3 @@
{ {
"version": "2024.3.6" "version": "2024.3.12"
} }