canvaBodyHtml = `
${'Gateway ' + '(' + response.gateway.NAME + ')'}
`; $('#gateway-details').html(canvaBodyHtml); $('#status').val(response.gateway.STATUS || ''); $('#bkash_app_key').val(response.gateway.API_KEY || ''); $('#bkash_app_secret').val(response.gateway.SECRET_KEY || ''); $('#bkash_username').val(response.gateway.USERNAME || ''); $('#bkash_password').val(response.gateway.PASSWORD || ''); $('#bkash_charge').val(response.gateway.CHARGE || ''); if (response.gateway.SANDBOX === 'true') { $('#bkash_sandbox').prop('checked', true); } else { $('#bkash_sandbox').prop('checked', false); } $('#update-gateway').off('click').on('click', function() { const formData = { Status: $('#status').val(), apiKey: $('#bkash_app_key').val(), secretKey: $('#bkash_app_secret').val(), Username: $('#bkash_username').val(), Password: $('#bkash_password').val(), charge: $('#bkash_charge').val(), Sandbox: $('#bkash_sandbox').prop('checked'), }; 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.Username) { missingFields.push('Bkash Username'); } if (!formData.Password) { missingFields.push('Bkash Password'); } if (!formData.charge) { missingFields.push('Bkash 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(); } }, }); });