Commit 7ea471cc authored by Your Name's avatar Your Name

refactor: move payment gateway settings to payment settings page and hide API...

refactor: move payment gateway settings to payment settings page and hide API Tokens for config admin

- Moved payment gateway configuration (Stripe, PayPal, crypto) from admin tiers page to admin payment settings page
- Removed payment gateway HTML section (lines 115-290) from admin_tiers.html
- Removed payment gateway JavaScript functions from admin_tiers.html
- Added payment gateway section to admin_payment_settings.html with all 6 gateways (PayPal, Stripe, BTC, ETH, USDT, USDC)
- Added loadPaymentGateways() and savePaymentGateways() functions to admin_payment_settings.html
- Hide 'API Tokens' navigation link for config admin user (user_id is null for config admin)
- API Tokens link now only shows for database users (request.session.user_id exists)
- Config admin defined in aisbf.json has no user_id, so they won't see API Tokens link
- Admin tiers page now focuses only on tier management and currency settings
- Admin payment settings page now has all payment configuration in one place
parent 0735029e
......@@ -502,7 +502,9 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
<a href="{{ url_for(request, '/dashboard/autoselect') }}" {% if '/autoselect' in request.path %}class="active"{% endif %}>Autoselect</a>
<a href="{{ url_for(request, '/dashboard/prompts') }}" {% if '/prompts' in request.path %}class="active"{% endif %}>Prompts</a>
<a href="{{ url_for(request, '/dashboard/analytics') }}" {% if '/analytics' in request.path %}class="active"{% endif %}>Analytics</a>
{% if request.session.user_id %}
<a href="{{ url_for(request, '/dashboard/user/tokens') }}" {% if '/user/tokens' in request.path %}class="active"{% endif %}>API Tokens</a>
{% endif %}
{% if request.session.role == 'admin' %}
<a href="{{ url_for(request, '/dashboard/users') }}" {% if '/users' in request.path %}class="active"{% endif %}>Users</a>
<a href="{{ url_for(request, '/dashboard/settings') }}" {% if '/settings' in request.path %}class="active"{% endif %}>Settings</a>
......
......@@ -56,6 +56,183 @@
</div>
</div>
<!-- Payment Gateways Configuration -->
<div style="background: #16213e; border: 2px solid #f39c12; border-radius: 8px; padding: 20px; margin-bottom: 20px;">
<h3 style="margin: 0 0 20px 0; color: #f39c12;">
<i class="fas fa-credit-card me-2"></i>Payment Gateways Configuration
</h3>
<div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(400px, 1fr)); gap: 20px;">
<!-- PayPal -->
<div style="background: #1a1a2e; border: 1px solid #0f3460; border-radius: 8px; overflow: hidden;">
<div style="background: #0070ba; color: white; padding: 15px; display: flex; justify-content: space-between; align-items: center;">
<h6 style="margin: 0;"><i class="fab fa-paypal me-2"></i>PayPal</h6>
<label style="margin: 0; cursor: pointer;">
<input type="checkbox" id="paypalEnabled" style="margin-right: 5px;">Enabled
</label>
</div>
<div style="padding: 15px;">
<div style="margin-bottom: 15px;">
<label style="display: block; margin-bottom: 5px; font-weight: 500; color: #e0e0e0;">Client ID</label>
<input type="text" style="width: 100%; padding: 8px; border: 1px solid #0f3460; border-radius: 3px; background: #16213e; color: #e0e0e0;" id="paypalClientId" placeholder="PayPal Client ID">
</div>
<div style="margin-bottom: 15px;">
<label style="display: block; margin-bottom: 5px; font-weight: 500; color: #e0e0e0;">Client Secret</label>
<input type="password" style="width: 100%; padding: 8px; border: 1px solid #0f3460; border-radius: 3px; background: #16213e; color: #e0e0e0;" id="paypalClientSecret" placeholder="PayPal Client Secret">
</div>
<div style="margin-bottom: 15px;">
<label style="display: block; margin-bottom: 5px; font-weight: 500; color: #e0e0e0;">Webhook Secret</label>
<input type="password" style="width: 100%; padding: 8px; border: 1px solid #0f3460; border-radius: 3px; background: #16213e; color: #e0e0e0;" id="paypalWebhookSecret" placeholder="Webhook Secret">
</div>
<label style="cursor: pointer;">
<input type="checkbox" id="paypalSandbox" checked style="margin-right: 5px;">Sandbox Mode
</label>
</div>
</div>
<!-- Stripe -->
<div style="background: #1a1a2e; border: 1px solid #0f3460; border-radius: 8px; overflow: hidden;">
<div style="background: #635bff; color: white; padding: 15px; display: flex; justify-content: space-between; align-items: center;">
<h6 style="margin: 0;"><i class="fab fa-stripe me-2"></i>Stripe</h6>
<label style="margin: 0; cursor: pointer;">
<input type="checkbox" id="stripeEnabled" style="margin-right: 5px;">Enabled
</label>
</div>
<div style="padding: 15px;">
<div style="margin-bottom: 15px;">
<label style="display: block; margin-bottom: 5px; font-weight: 500; color: #e0e0e0;">Publishable Key</label>
<input type="text" style="width: 100%; padding: 8px; border: 1px solid #0f3460; border-radius: 3px; background: #16213e; color: #e0e0e0;" id="stripePublishableKey" placeholder="pk_...">
</div>
<div style="margin-bottom: 15px;">
<label style="display: block; margin-bottom: 5px; font-weight: 500; color: #e0e0e0;">Secret Key</label>
<input type="password" style="width: 100%; padding: 8px; border: 1px solid #0f3460; border-radius: 3px; background: #16213e; color: #e0e0e0;" id="stripeSecretKey" placeholder="sk_...">
</div>
<div style="margin-bottom: 15px;">
<label style="display: block; margin-bottom: 5px; font-weight: 500; color: #e0e0e0;">Webhook Secret</label>
<input type="password" style="width: 100%; padding: 8px; border: 1px solid #0f3460; border-radius: 3px; background: #16213e; color: #e0e0e0;" id="stripeWebhookSecret" placeholder="whsec_...">
</div>
<label style="cursor: pointer;">
<input type="checkbox" id="stripeSandbox" checked style="margin-right: 5px;">Test Mode
</label>
</div>
</div>
<!-- Bitcoin -->
<div style="background: #1a1a2e; border: 1px solid #0f3460; border-radius: 8px; overflow: hidden;">
<div style="background: #f7931a; color: white; padding: 15px; display: flex; justify-content: space-between; align-items: center;">
<h6 style="margin: 0;"><i class="fab fa-bitcoin me-2"></i>Bitcoin</h6>
<label style="margin: 0; cursor: pointer;">
<input type="checkbox" id="bitcoinEnabled" style="margin-right: 5px;">Enabled
</label>
</div>
<div style="padding: 15px;">
<div style="margin-bottom: 15px;">
<label style="display: block; margin-bottom: 5px; font-weight: 500; color: #e0e0e0;">Bitcoin Address</label>
<input type="text" style="width: 100%; padding: 8px; border: 1px solid #0f3460; border-radius: 3px; background: #16213e; color: #e0e0e0;" id="bitcoinAddress" placeholder="bc1q...">
</div>
<div style="margin-bottom: 15px;">
<label style="display: block; margin-bottom: 5px; font-weight: 500; color: #e0e0e0;">Minimum Confirmations</label>
<input type="number" style="width: 100%; padding: 8px; border: 1px solid #0f3460; border-radius: 3px; background: #16213e; color: #e0e0e0;" id="bitcoinConfirmations" value="3" min="1" max="10">
</div>
<div style="margin-bottom: 15px;">
<label style="display: block; margin-bottom: 5px; font-weight: 500; color: #e0e0e0;">Expiration Time (minutes)</label>
<input type="number" style="width: 100%; padding: 8px; border: 1px solid #0f3460; border-radius: 3px; background: #16213e; color: #e0e0e0;" id="bitcoinExpiration" value="120" min="15" max="1440">
</div>
</div>
</div>
<!-- Ethereum -->
<div style="background: #1a1a2e; border: 1px solid #0f3460; border-radius: 8px; overflow: hidden;">
<div style="background: #627eea; color: white; padding: 15px; display: flex; justify-content: space-between; align-items: center;">
<h6 style="margin: 0;"><i class="fab fa-ethereum me-2"></i>Ethereum (ETH)</h6>
<label style="margin: 0; cursor: pointer;">
<input type="checkbox" id="ethEnabled" style="margin-right: 5px;">Enabled
</label>
</div>
<div style="padding: 15px;">
<div style="margin-bottom: 15px;">
<label style="display: block; margin-bottom: 5px; font-weight: 500; color: #e0e0e0;">ETH Wallet Address</label>
<input type="text" style="width: 100%; padding: 8px; border: 1px solid #0f3460; border-radius: 3px; background: #16213e; color: #e0e0e0;" id="ethAddress" placeholder="0x...">
</div>
<div style="margin-bottom: 15px;">
<label style="display: block; margin-bottom: 5px; font-weight: 500; color: #e0e0e0;">Minimum Confirmations</label>
<input type="number" style="width: 100%; padding: 8px; border: 1px solid #0f3460; border-radius: 3px; background: #16213e; color: #e0e0e0;" id="ethConfirmations" value="12" min="1" max="50">
</div>
<div style="margin-bottom: 15px;">
<label style="display: block; margin-bottom: 5px; font-weight: 500; color: #e0e0e0;">Chain ID</label>
<select style="width: 100%; padding: 8px; border: 1px solid #0f3460; border-radius: 3px; background: #16213e; color: #e0e0e0;" id="ethChainId">
<option value="1">Ethereum Mainnet</option>
<option value="5">Goerli Testnet</option>
<option value="11155111">Sepolia Testnet</option>
</select>
</div>
</div>
</div>
<!-- USDT -->
<div style="background: #1a1a2e; border: 1px solid #0f3460; border-radius: 8px; overflow: hidden;">
<div style="background: #26a17b; color: white; padding: 15px; display: flex; justify-content: space-between; align-items: center;">
<h6 style="margin: 0;"><i class="fas fa-dollar-sign me-2"></i>Tether (USDT)</h6>
<label style="margin: 0; cursor: pointer;">
<input type="checkbox" id="usdtEnabled" style="margin-right: 5px;">Enabled
</label>
</div>
<div style="padding: 15px;">
<div style="margin-bottom: 15px;">
<label style="display: block; margin-bottom: 5px; font-weight: 500; color: #e0e0e0;">USDT Wallet Address</label>
<input type="text" style="width: 100%; padding: 8px; border: 1px solid #0f3460; border-radius: 3px; background: #16213e; color: #e0e0e0;" id="usdtAddress" placeholder="0x...">
</div>
<div style="margin-bottom: 15px;">
<label style="display: block; margin-bottom: 5px; font-weight: 500; color: #e0e0e0;">Network</label>
<select style="width: 100%; padding: 8px; border: 1px solid #0f3460; border-radius: 3px; background: #16213e; color: #e0e0e0;" id="usdtNetwork">
<option value="erc20">ERC20 (Ethereum)</option>
<option value="trc20">TRC20 (Tron)</option>
<option value="bep20">BEP20 (BSC)</option>
<option value="solana">Solana</option>
</select>
</div>
<div style="margin-bottom: 15px;">
<label style="display: block; margin-bottom: 5px; font-weight: 500; color: #e0e0e0;">Minimum Confirmations</label>
<input type="number" style="width: 100%; padding: 8px; border: 1px solid #0f3460; border-radius: 3px; background: #16213e; color: #e0e0e0;" id="usdtConfirmations" value="3" min="1" max="50">
</div>
</div>
</div>
<!-- USDC -->
<div style="background: #1a1a2e; border: 1px solid #0f3460; border-radius: 8px; overflow: hidden;">
<div style="background: #2775ca; color: white; padding: 15px; display: flex; justify-content: space-between; align-items: center;">
<h6 style="margin: 0;"><i class="fas fa-coins me-2"></i>USD Coin (USDC)</h6>
<label style="margin: 0; cursor: pointer;">
<input type="checkbox" id="usdcEnabled" style="margin-right: 5px;">Enabled
</label>
</div>
<div style="padding: 15px;">
<div style="margin-bottom: 15px;">
<label style="display: block; margin-bottom: 5px; font-weight: 500; color: #e0e0e0;">USDC Wallet Address</label>
<input type="text" style="width: 100%; padding: 8px; border: 1px solid #0f3460; border-radius: 3px; background: #16213e; color: #e0e0e0;" id="usdcAddress" placeholder="0x...">
</div>
<div style="margin-bottom: 15px;">
<label style="display: block; margin-bottom: 5px; font-weight: 500; color: #e0e0e0;">Network</label>
<select style="width: 100%; padding: 8px; border: 1px solid #0f3460; border-radius: 3px; background: #16213e; color: #e0e0e0;" id="usdcNetwork">
<option value="erc20">ERC20 (Ethereum)</option>
<option value="solana">Solana</option>
<option value="bep20">BEP20 (BSC)</option>
<option value="algorand">Algorand</option>
</select>
</div>
<div style="margin-bottom: 15px;">
<label style="display: block; margin-bottom: 5px; font-weight: 500; color: #e0e0e0;">Minimum Confirmations</label>
<input type="number" style="width: 100%; padding: 8px; border: 1px solid #0f3460; border-radius: 3px; background: #16213e; color: #e0e0e0;" id="usdcConfirmations" value="3" min="1" max="50">
</div>
</div>
</div>
</div>
<button type="button" class="btn" onclick="savePaymentGateways()" style="background: #f39c12; color: white; margin-top: 20px;">
<i class="fas fa-save me-2"></i>Save Payment Gateway Configuration
</button>
</div>
<!-- Price Sources Configuration -->
<div style="background: #16213e; border: 2px solid #f39c12; border-radius: 8px; padding: 20px; margin-bottom: 20px;">
<h3 style="margin: 0 0 20px 0; color: #f39c12;">
......@@ -407,10 +584,132 @@ function showToast(message, type) {
}, 5000);
}
// Load data on page load
// Load and save payment gateway functions
function loadPaymentGateways() {
fetch('{{ url_for(request, "/api/admin/settings/payment-gateways") }}')
.then(response => response.json())
.then(gateways => {
// Load gateway configuration into form fields
if (gateways.paypal) {
document.getElementById('paypalEnabled').checked = gateways.paypal.enabled || false;
document.getElementById('paypalClientId').value = gateways.paypal.client_id || '';
document.getElementById('paypalClientSecret').value = gateways.paypal.client_secret || '';
document.getElementById('paypalWebhookSecret').value = gateways.paypal.webhook_secret || '';
document.getElementById('paypalSandbox').checked = gateways.paypal.sandbox !== false;
}
if (gateways.stripe) {
document.getElementById('stripeEnabled').checked = gateways.stripe.enabled || false;
document.getElementById('stripePublishableKey').value = gateways.stripe.publishable_key || '';
document.getElementById('stripeSecretKey').value = gateways.stripe.secret_key || '';
document.getElementById('stripeWebhookSecret').value = gateways.stripe.webhook_secret || '';
document.getElementById('stripeSandbox').checked = gateways.stripe.sandbox !== false;
}
if (gateways.bitcoin) {
document.getElementById('bitcoinEnabled').checked = gateways.bitcoin.enabled || false;
document.getElementById('bitcoinAddress').value = gateways.bitcoin.address || '';
document.getElementById('bitcoinConfirmations').value = gateways.bitcoin.confirmations || 3;
document.getElementById('bitcoinExpiration').value = gateways.bitcoin.expiration_minutes || 120;
}
if (gateways.ethereum) {
document.getElementById('ethEnabled').checked = gateways.ethereum.enabled || false;
document.getElementById('ethAddress').value = gateways.ethereum.address || '';
document.getElementById('ethConfirmations').value = gateways.ethereum.confirmations || 12;
document.getElementById('ethChainId').value = gateways.ethereum.chain_id || 1;
}
if (gateways.usdt) {
document.getElementById('usdtEnabled').checked = gateways.usdt.enabled || false;
document.getElementById('usdtAddress').value = gateways.usdt.address || '';
document.getElementById('usdtNetwork').value = gateways.usdt.network || 'erc20';
document.getElementById('usdtConfirmations').value = gateways.usdt.confirmations || 3;
}
if (gateways.usdc) {
document.getElementById('usdcEnabled').checked = gateways.usdc.enabled || false;
document.getElementById('usdcAddress').value = gateways.usdc.address || '';
document.getElementById('usdcNetwork').value = gateways.usdc.network || 'erc20';
document.getElementById('usdcConfirmations').value = gateways.usdc.confirmations || 3;
}
});
}
function savePaymentGateways() {
const gatewaysData = {
paypal: {
enabled: document.getElementById('paypalEnabled').checked,
client_id: document.getElementById('paypalClientId').value,
client_secret: document.getElementById('paypalClientSecret').value,
webhook_secret: document.getElementById('paypalWebhookSecret').value,
sandbox: document.getElementById('paypalSandbox').checked
},
stripe: {
enabled: document.getElementById('stripeEnabled').checked,
publishable_key: document.getElementById('stripePublishableKey').value,
secret_key: document.getElementById('stripeSecretKey').value,
webhook_secret: document.getElementById('stripeWebhookSecret').value,
sandbox: document.getElementById('stripeSandbox').checked
},
bitcoin: {
enabled: document.getElementById('bitcoinEnabled').checked,
address: document.getElementById('bitcoinAddress').value,
confirmations: parseInt(document.getElementById('bitcoinConfirmations').value),
expiration_minutes: parseInt(document.getElementById('bitcoinExpiration').value)
},
ethereum: {
enabled: document.getElementById('ethEnabled').checked,
address: document.getElementById('ethAddress').value,
confirmations: parseInt(document.getElementById('ethConfirmations').value),
chain_id: parseInt(document.getElementById('ethChainId').value)
},
usdt: {
enabled: document.getElementById('usdtEnabled').checked,
address: document.getElementById('usdtAddress').value,
network: document.getElementById('usdtNetwork').value,
confirmations: parseInt(document.getElementById('usdtConfirmations').value)
},
usdc: {
enabled: document.getElementById('usdcEnabled').checked,
address: document.getElementById('usdcAddress').value,
network: document.getElementById('usdcNetwork').value,
confirmations: parseInt(document.getElementById('usdcConfirmations').value)
}
};
fetch('{{ url_for(request, "/api/admin/settings/payment-gateways") }}', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(gatewaysData)
})
.then(response => {
if (!response.ok) {
throw new Error('Failed to save payment gateway configuration');
}
return response.json();
})
.then(result => {
if (result.success) {
showToast('Payment gateway configuration saved successfully', 'success');
} else {
showToast(result.error || 'Error saving payment gateway configuration', 'danger');
}
})
.catch(error => {
console.error('Error saving payment gateways:', error);
showToast('Error saving payment gateway configuration: ' + error.message, 'danger');
});
}
// Load data on page load - update to include payment gateways
document.addEventListener('DOMContentLoaded', function() {
loadSystemStatus();
loadConfiguration();
loadPaymentGateways();
});
</script>
{% endblock %}
......@@ -112,182 +112,6 @@
</form>
</div>
<!-- Payment Gateways Configuration -->
<div style="background: #16213e; border: 2px solid #f39c12; border-radius: 8px; padding: 20px; margin-bottom: 20px;">
<h3 style="margin: 0 0 20px 0; color: #f39c12;">
<i class="fas fa-credit-card me-2"></i>Payment Gateways Configuration
</h3>
<div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(400px, 1fr)); gap: 20px;">
<!-- PayPal -->
<div style="background: #1a1a2e; border: 1px solid #0f3460; border-radius: 8px; overflow: hidden;">
<div style="background: #0070ba; color: white; padding: 15px; display: flex; justify-content: space-between; align-items: center;">
<h6 style="margin: 0;"><i class="fab fa-paypal me-2"></i>PayPal</h6>
<label style="margin: 0; cursor: pointer;">
<input type="checkbox" id="paypalEnabled" style="margin-right: 5px;">Enabled
</label>
</div>
<div style="padding: 15px;">
<div style="margin-bottom: 15px;">
<label style="display: block; margin-bottom: 5px; font-weight: 500; color: #e0e0e0;">Client ID</label>
<input type="text" style="width: 100%; padding: 8px; border: 1px solid #0f3460; border-radius: 3px; background: #16213e; color: #e0e0e0;" id="paypalClientId" placeholder="PayPal Client ID">
</div>
<div style="margin-bottom: 15px;">
<label style="display: block; margin-bottom: 5px; font-weight: 500; color: #e0e0e0;">Client Secret</label>
<input type="password" style="width: 100%; padding: 8px; border: 1px solid #0f3460; border-radius: 3px; background: #16213e; color: #e0e0e0;" id="paypalClientSecret" placeholder="PayPal Client Secret">
</div>
<div style="margin-bottom: 15px;">
<label style="display: block; margin-bottom: 5px; font-weight: 500; color: #e0e0e0;">Webhook Secret</label>
<input type="password" style="width: 100%; padding: 8px; border: 1px solid #0f3460; border-radius: 3px; background: #16213e; color: #e0e0e0;" id="paypalWebhookSecret" placeholder="Webhook Secret">
</div>
<label style="cursor: pointer;">
<input type="checkbox" id="paypalSandbox" checked style="margin-right: 5px;">Sandbox Mode
</label>
</div>
</div>
<!-- Stripe -->
<div style="background: #1a1a2e; border: 1px solid #0f3460; border-radius: 8px; overflow: hidden;">
<div style="background: #635bff; color: white; padding: 15px; display: flex; justify-content: space-between; align-items: center;">
<h6 style="margin: 0;"><i class="fab fa-stripe me-2"></i>Stripe</h6>
<label style="margin: 0; cursor: pointer;">
<input type="checkbox" id="stripeEnabled" style="margin-right: 5px;">Enabled
</label>
</div>
<div style="padding: 15px;">
<div style="margin-bottom: 15px;">
<label style="display: block; margin-bottom: 5px; font-weight: 500; color: #e0e0e0;">Publishable Key</label>
<input type="text" style="width: 100%; padding: 8px; border: 1px solid #0f3460; border-radius: 3px; background: #16213e; color: #e0e0e0;" id="stripePublishableKey" placeholder="pk_...">
</div>
<div style="margin-bottom: 15px;">
<label style="display: block; margin-bottom: 5px; font-weight: 500; color: #e0e0e0;">Secret Key</label>
<input type="password" style="width: 100%; padding: 8px; border: 1px solid #0f3460; border-radius: 3px; background: #16213e; color: #e0e0e0;" id="stripeSecretKey" placeholder="sk_...">
</div>
<div style="margin-bottom: 15px;">
<label style="display: block; margin-bottom: 5px; font-weight: 500; color: #e0e0e0;">Webhook Secret</label>
<input type="password" style="width: 100%; padding: 8px; border: 1px solid #0f3460; border-radius: 3px; background: #16213e; color: #e0e0e0;" id="stripeWebhookSecret" placeholder="whsec_...">
</div>
<label style="cursor: pointer;">
<input type="checkbox" id="stripeSandbox" checked style="margin-right: 5px;">Test Mode
</label>
</div>
</div>
<!-- Bitcoin -->
<div style="background: #1a1a2e; border: 1px solid #0f3460; border-radius: 8px; overflow: hidden;">
<div style="background: #f7931a; color: white; padding: 15px; display: flex; justify-content: space-between; align-items: center;">
<h6 style="margin: 0;"><i class="fab fa-bitcoin me-2"></i>Bitcoin</h6>
<label style="margin: 0; cursor: pointer;">
<input type="checkbox" id="bitcoinEnabled" style="margin-right: 5px;">Enabled
</label>
</div>
<div style="padding: 15px;">
<div style="margin-bottom: 15px;">
<label style="display: block; margin-bottom: 5px; font-weight: 500; color: #e0e0e0;">Bitcoin Address</label>
<input type="text" style="width: 100%; padding: 8px; border: 1px solid #0f3460; border-radius: 3px; background: #16213e; color: #e0e0e0;" id="bitcoinAddress" placeholder="bc1q...">
</div>
<div style="margin-bottom: 15px;">
<label style="display: block; margin-bottom: 5px; font-weight: 500; color: #e0e0e0;">Minimum Confirmations</label>
<input type="number" style="width: 100%; padding: 8px; border: 1px solid #0f3460; border-radius: 3px; background: #16213e; color: #e0e0e0;" id="bitcoinConfirmations" value="3" min="1" max="10">
</div>
<div style="margin-bottom: 15px;">
<label style="display: block; margin-bottom: 5px; font-weight: 500; color: #e0e0e0;">Expiration Time (minutes)</label>
<input type="number" style="width: 100%; padding: 8px; border: 1px solid #0f3460; border-radius: 3px; background: #16213e; color: #e0e0e0;" id="bitcoinExpiration" value="120" min="15" max="1440">
</div>
</div>
</div>
<!-- Ethereum -->
<div style="background: #1a1a2e; border: 1px solid #0f3460; border-radius: 8px; overflow: hidden;">
<div style="background: #627eea; color: white; padding: 15px; display: flex; justify-content: space-between; align-items: center;">
<h6 style="margin: 0;"><i class="fab fa-ethereum me-2"></i>Ethereum (ETH)</h6>
<label style="margin: 0; cursor: pointer;">
<input type="checkbox" id="ethEnabled" style="margin-right: 5px;">Enabled
</label>
</div>
<div style="padding: 15px;">
<div style="margin-bottom: 15px;">
<label style="display: block; margin-bottom: 5px; font-weight: 500; color: #e0e0e0;">ETH Wallet Address</label>
<input type="text" style="width: 100%; padding: 8px; border: 1px solid #0f3460; border-radius: 3px; background: #16213e; color: #e0e0e0;" id="ethAddress" placeholder="0x...">
</div>
<div style="margin-bottom: 15px;">
<label style="display: block; margin-bottom: 5px; font-weight: 500; color: #e0e0e0;">Minimum Confirmations</label>
<input type="number" style="width: 100%; padding: 8px; border: 1px solid #0f3460; border-radius: 3px; background: #16213e; color: #e0e0e0;" id="ethConfirmations" value="12" min="1" max="50">
</div>
<div style="margin-bottom: 15px;">
<label style="display: block; margin-bottom: 5px; font-weight: 500; color: #e0e0e0;">Chain ID</label>
<select style="width: 100%; padding: 8px; border: 1px solid #0f3460; border-radius: 3px; background: #16213e; color: #e0e0e0;" id="ethChainId">
<option value="1">Ethereum Mainnet</option>
<option value="5">Goerli Testnet</option>
<option value="11155111">Sepolia Testnet</option>
</select>
</div>
</div>
</div>
<!-- USDT -->
<div style="background: #1a1a2e; border: 1px solid #0f3460; border-radius: 8px; overflow: hidden;">
<div style="background: #26a17b; color: white; padding: 15px; display: flex; justify-content: space-between; align-items: center;">
<h6 style="margin: 0;"><i class="fas fa-dollar-sign me-2"></i>Tether (USDT)</h6>
<label style="margin: 0; cursor: pointer;">
<input type="checkbox" id="usdtEnabled" style="margin-right: 5px;">Enabled
</label>
</div>
<div style="padding: 15px;">
<div style="margin-bottom: 15px;">
<label style="display: block; margin-bottom: 5px; font-weight: 500; color: #e0e0e0;">USDT Wallet Address</label>
<input type="text" style="width: 100%; padding: 8px; border: 1px solid #0f3460; border-radius: 3px; background: #16213e; color: #e0e0e0;" id="usdtAddress" placeholder="0x...">
</div>
<div style="margin-bottom: 15px;">
<label style="display: block; margin-bottom: 5px; font-weight: 500; color: #e0e0e0;">Network</label>
<select style="width: 100%; padding: 8px; border: 1px solid #0f3460; border-radius: 3px; background: #16213e; color: #e0e0e0;" id="usdtNetwork">
<option value="erc20">ERC20 (Ethereum)</option>
<option value="trc20">TRC20 (Tron)</option>
<option value="bep20">BEP20 (BSC)</option>
<option value="solana">Solana</option>
</select>
</div>
<div style="margin-bottom: 15px;">
<label style="display: block; margin-bottom: 5px; font-weight: 500; color: #e0e0e0;">Minimum Confirmations</label>
<input type="number" style="width: 100%; padding: 8px; border: 1px solid #0f3460; border-radius: 3px; background: #16213e; color: #e0e0e0;" id="usdtConfirmations" value="3" min="1" max="50">
</div>
</div>
</div>
<!-- USDC -->
<div style="background: #1a1a2e; border: 1px solid #0f3460; border-radius: 8px; overflow: hidden;">
<div style="background: #2775ca; color: white; padding: 15px; display: flex; justify-content: space-between; align-items: center;">
<h6 style="margin: 0;"><i class="fas fa-coins me-2"></i>USD Coin (USDC)</h6>
<label style="margin: 0; cursor: pointer;">
<input type="checkbox" id="usdcEnabled" style="margin-right: 5px;">Enabled
</label>
</div>
<div style="padding: 15px;">
<div style="margin-bottom: 15px;">
<label style="display: block; margin-bottom: 5px; font-weight: 500; color: #e0e0e0;">USDC Wallet Address</label>
<input type="text" style="width: 100%; padding: 8px; border: 1px solid #0f3460; border-radius: 3px; background: #16213e; color: #e0e0e0;" id="usdcAddress" placeholder="0x...">
</div>
<div style="margin-bottom: 15px;">
<label style="display: block; margin-bottom: 5px; font-weight: 500; color: #e0e0e0;">Network</label>
<select style="width: 100%; padding: 8px; border: 1px solid #0f3460; border-radius: 3px; background: #16213e; color: #e0e0e0;" id="usdcNetwork">
<option value="erc20">ERC20 (Ethereum)</option>
<option value="solana">Solana</option>
<option value="bep20">BEP20 (BSC)</option>
<option value="algorand">Algorand</option>
</select>
</div>
<div style="margin-bottom: 15px;">
<label style="display: block; margin-bottom: 5px; font-weight: 500; color: #e0e0e0;">Minimum Confirmations</label>
<input type="number" style="width: 100%; padding: 8px; border: 1px solid #0f3460; border-radius: 3px; background: #16213e; color: #e0e0e0;" id="usdcConfirmations" value="3" min="1" max="50">
</div>
</div>
</div>
</div>
<button type="button" class="btn" onclick="savePaymentGateways()" style="background: #f39c12; color: white; margin-top: 20px;">
<i class="fas fa-save me-2"></i>Save Payment Gateway Configuration
</button>
</div>
<!-- Create/Edit Tier Modal -->
<div class="modal fade" id="tierModal" tabindex="-1" aria-labelledby="tierModalLabel" aria-hidden="true" style="display: none;">
......@@ -406,7 +230,6 @@
document.addEventListener('DOMContentLoaded', function() {
try {
loadCurrencySettings();
loadPaymentGateways();
} catch (error) {
console.error('Error initializing page:', error);
}
......@@ -632,124 +455,6 @@ document.getElementById('currencySettingsForm').addEventListener('submit', funct
});
});
function loadPaymentGateways() {
fetch('{{ url_for(request, "/api/admin/settings/payment-gateways") }}')
.then(response => response.json())
.then(gateways => {
// Load gateway configuration into form fields
if (gateways.paypal) {
document.getElementById('paypalEnabled').checked = gateways.paypal.enabled || false;
document.getElementById('paypalClientId').value = gateways.paypal.client_id || '';
document.getElementById('paypalClientSecret').value = gateways.paypal.client_secret || '';
document.getElementById('paypalWebhookSecret').value = gateways.paypal.webhook_secret || '';
document.getElementById('paypalSandbox').checked = gateways.paypal.sandbox !== false;
}
if (gateways.stripe) {
document.getElementById('stripeEnabled').checked = gateways.stripe.enabled || false;
document.getElementById('stripePublishableKey').value = gateways.stripe.publishable_key || '';
document.getElementById('stripeSecretKey').value = gateways.stripe.secret_key || '';
document.getElementById('stripeWebhookSecret').value = gateways.stripe.webhook_secret || '';
document.getElementById('stripeSandbox').checked = gateways.stripe.sandbox !== false;
}
if (gateways.bitcoin) {
document.getElementById('bitcoinEnabled').checked = gateways.bitcoin.enabled || false;
document.getElementById('bitcoinAddress').value = gateways.bitcoin.address || '';
document.getElementById('bitcoinConfirmations').value = gateways.bitcoin.confirmations || 3;
document.getElementById('bitcoinExpiration').value = gateways.bitcoin.expiration_minutes || 120;
}
if (gateways.ethereum) {
document.getElementById('ethEnabled').checked = gateways.ethereum.enabled || false;
document.getElementById('ethAddress').value = gateways.ethereum.address || '';
document.getElementById('ethConfirmations').value = gateways.ethereum.confirmations || 12;
document.getElementById('ethChainId').value = gateways.ethereum.chain_id || 1;
}
if (gateways.usdt) {
document.getElementById('usdtEnabled').checked = gateways.usdt.enabled || false;
document.getElementById('usdtAddress').value = gateways.usdt.address || '';
document.getElementById('usdtNetwork').value = gateways.usdt.network || 'erc20';
document.getElementById('usdtConfirmations').value = gateways.usdt.confirmations || 3;
}
if (gateways.usdc) {
document.getElementById('usdcEnabled').checked = gateways.usdc.enabled || false;
document.getElementById('usdcAddress').value = gateways.usdc.address || '';
document.getElementById('usdcNetwork').value = gateways.usdc.network || 'erc20';
document.getElementById('usdcConfirmations').value = gateways.usdc.confirmations || 3;
}
});
}
function savePaymentGateways() {
const gatewaysData = {
paypal: {
enabled: document.getElementById('paypalEnabled').checked,
client_id: document.getElementById('paypalClientId').value,
client_secret: document.getElementById('paypalClientSecret').value,
webhook_secret: document.getElementById('paypalWebhookSecret').value,
sandbox: document.getElementById('paypalSandbox').checked
},
stripe: {
enabled: document.getElementById('stripeEnabled').checked,
publishable_key: document.getElementById('stripePublishableKey').value,
secret_key: document.getElementById('stripeSecretKey').value,
webhook_secret: document.getElementById('stripeWebhookSecret').value,
sandbox: document.getElementById('stripeSandbox').checked
},
bitcoin: {
enabled: document.getElementById('bitcoinEnabled').checked,
address: document.getElementById('bitcoinAddress').value,
confirmations: parseInt(document.getElementById('bitcoinConfirmations').value),
expiration_minutes: parseInt(document.getElementById('bitcoinExpiration').value)
},
ethereum: {
enabled: document.getElementById('ethEnabled').checked,
address: document.getElementById('ethAddress').value,
confirmations: parseInt(document.getElementById('ethConfirmations').value),
chain_id: parseInt(document.getElementById('ethChainId').value)
},
usdt: {
enabled: document.getElementById('usdtEnabled').checked,
address: document.getElementById('usdtAddress').value,
network: document.getElementById('usdtNetwork').value,
confirmations: parseInt(document.getElementById('usdtConfirmations').value)
},
usdc: {
enabled: document.getElementById('usdcEnabled').checked,
address: document.getElementById('usdcAddress').value,
network: document.getElementById('usdcNetwork').value,
confirmations: parseInt(document.getElementById('usdcConfirmations').value)
}
};
fetch('{{ url_for(request, "/api/admin/settings/payment-gateways") }}', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(gatewaysData)
})
.then(response => {
if (!response.ok) {
throw new Error('Failed to save payment gateway configuration');
}
return response.json();
})
.then(result => {
if (result.success) {
showToast('Payment gateway configuration saved successfully', 'success');
} else {
showToast(result.error || 'Error saving payment gateway configuration', 'danger');
}
})
.catch(error => {
console.error('Error saving payment gateways:', error);
showToast('Error saving payment gateway configuration: ' + error.message, 'danger');
});
}
function showToast(message, type) {
// Create and show toast notification
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment