canvaBodyHtml = `
`;
$('#gateway-details').html(canvaBodyHtml);
$('#status').val(response.gateway.STATUS || '');
$('#binance_api_key').val(response.gateway.API_KEY || '');
$('#binance_secret_key').val(response.gateway.SECRET_KEY || '');
$('#binance_charge').val(response.gateway.CHARGE || '');
$('#update-gateway').off('click').on('click', function() {
const formData = {
Status: $('#status').val(),
apiKey: $('#binance_api_key').val(),
secretKey: $('#binance_secret_key').val(),
charge: $('#binance_charge').val(),
};
let missingFields = [];
if (!formData.Status) {
missingFields.push('Status value');
}
if (!formData.apiKey) {
missingFields.push('App Key');
}
if (!formData.secretKey) {
missingFields.push('App Secret');
}
if (!formData.charge) {
missingFields.push('Gateway charge');
}
if (missingFields.length > 0) {
let message = missingFields.join(', ') + ' is required';
new Notify({
status: 'error',
text: message,
effect: 'fade',
speed: 300,
showIcon: true,
showCloseButton: false,
autoclose: true,
autotimeout: 3000,
position: 'left bottom',
type: 'filled',
});
return false;
}
$.ajax({
url: '/admin/update/pay-gateway/' + gatewayID,
method: 'POST',
data: formData,
beforeSend: function() {
$('.top-loader').show();
$('#update-gateway').prop('disabled', true);
$('#loadingSpinnerSuccess').removeClass('d-none');
},
complete: function() {
$('.top-loader').hide();
$('#update-gateway').prop('disabled', false);
$('#loadingSpinnerSuccess').addClass('d-none');
},
success: function(response) {
new Notify({
status: `${response.success ? 'success' : 'error'}`,
text: `${response.message}`,
effect: 'fade',
speed: 300,
showIcon: true,
showCloseButton: false,
autoclose: true,
autotimeout: 5000,
notificationsGap: null,
notificationsPadding: null,
type: 'filled',
position: 'left bottom',
});
if(response.success){
$('#gateway-details').offcanvas('hide');
reloadDataTable();
}
},
});
});