sync
This commit is contained in:
33
lib/nowpayments.ts
Normal file
33
lib/nowpayments.ts
Normal 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,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user