This commit is contained in:
root
2025-12-20 19:00:42 +01:00
parent 9871289bfb
commit e1a0966dee
23 changed files with 1878 additions and 48 deletions

33
lib/nowpayments.ts Normal file
View File

@@ -0,0 +1,33 @@
// NOWPayments API configuration
export function getNowPaymentsConfig() {
const isTestnet = process.env.NOWPAYMENTS_TESTNET === 'true'
// For testnet, use sandbox API key if available, otherwise fall back to regular API key
const apiKey = isTestnet
? (process.env.NOWPAYMENTS_SANDBOX_API_KEY || process.env.NOWPAYMENTS_API_KEY || '')
: (process.env.NOWPAYMENTS_API_KEY || '')
// Sandbox/testnet uses api-sandbox.nowpayments.io
// If the environment variable is not explicitly set, default to production
const baseUrl = isTestnet
? 'https://api-sandbox.nowpayments.io'
: 'https://api.nowpayments.io'
// Currency configuration
// Default: USD for testnet (sandbox doesn't support CHF), CHF for production
// Can be overridden with NOWPAYMENTS_CURRENCY env variable
const defaultCurrency = isTestnet ? 'usd' : 'chf'
const currency = (process.env.NOWPAYMENTS_CURRENCY || defaultCurrency).toLowerCase()
if (isTestnet) {
console.log('Using NOWPayments Sandbox/Testnet environment')
}
return {
baseUrl,
apiKey,
isTestnet,
currency,
}
}