24 lines
1.2 KiB
TypeScript
24 lines
1.2 KiB
TypeScript
function parseEnable(v: unknown): boolean {
|
|
if (typeof v === 'string') {
|
|
const s = v.trim().toLowerCase()
|
|
return s === 'true' || s === '1' || s === 'yes' || s === 'on'
|
|
}
|
|
if (typeof v === 'boolean') return v
|
|
if (typeof v === 'number') return v === 1
|
|
return true
|
|
}
|
|
|
|
export const Env = {
|
|
API_BASE_URL: import.meta.env.VITE_API_BASE_URL || '',
|
|
MIDTRANS_CLIENT_KEY: import.meta.env.VITE_MIDTRANS_CLIENT_KEY || '',
|
|
MIDTRANS_ENV: (import.meta.env.VITE_MIDTRANS_ENV as 'sandbox' | 'production') || 'sandbox',
|
|
LOG_LEVEL: ((import.meta.env.VITE_LOG_LEVEL as string) || 'info').toLowerCase() as 'debug' | 'info' | 'warn' | 'error',
|
|
// Payment gateway mode: CORE (custom UI) or SNAP (hosted interface)
|
|
PAYMENT_GATEWAY_MODE: (import.meta.env.VITE_PAYMENT_GATEWAY_MODE as 'CORE' | 'SNAP') || 'SNAP',
|
|
// Feature toggles per payment type (frontend)
|
|
ENABLE_BANK_TRANSFER: parseEnable(import.meta.env.VITE_ENABLE_BANK_TRANSFER),
|
|
ENABLE_CREDIT_CARD: parseEnable(import.meta.env.VITE_ENABLE_CREDIT_CARD),
|
|
ENABLE_GOPAY: parseEnable(import.meta.env.VITE_ENABLE_GOPAY),
|
|
ENABLE_CSTORE: parseEnable(import.meta.env.VITE_ENABLE_CSTORE),
|
|
ENABLE_CPAY: parseEnable(import.meta.env.VITE_ENABLE_CPAY),
|
|
} |