UNPKG

dltpays

Version:

CLI for DLTPays - instant affiliate commissions

175 lines (149 loc) 5.48 kB
#!/usr/bin/env node const readline = require('readline'); const https = require('https'); const API_URL = 'api.dltpays.com'; // Colors const c = { reset: '\x1b[0m', bold: '\x1b[1m', dim: '\x1b[2m', green: '\x1b[32m', cyan: '\x1b[36m', yellow: '\x1b[33m', red: '\x1b[31m', magenta: '\x1b[35m', blue: '\x1b[34m', bgBlue: '\x1b[44m', white: '\x1b[37m' }; const rl = readline.createInterface({ input: process.stdin, output: process.stdout }); function ask(question) { return new Promise(resolve => rl.question(`${c.cyan}${question}${c.reset}`, resolve)); } function apiCall(method, path, data = null) { return new Promise((resolve, reject) => { const options = { hostname: API_URL, port: 443, path: `/api/v1${path}`, method, headers: { 'Content-Type': 'application/json' } }; const req = https.request(options, res => { let body = ''; res.on('data', chunk => body += chunk); res.on('end', () => { try { resolve(JSON.parse(body)); } catch { resolve(body); } }); }); req.on('error', reject); if (data) req.write(JSON.stringify(data)); req.end(); }); } function banner() { console.log(''); console.log(`${c.bgBlue}${c.white}${c.bold} ${c.reset}`); console.log(`${c.bgBlue}${c.white}${c.bold} ⚡ YesAllOfUs CLI ⚡ ${c.reset}`); console.log(`${c.bgBlue}${c.white}${c.bold} ${c.reset}`); console.log(''); console.log(`${c.dim} Instant affiliate commissions on XRPL${c.reset}`); console.log(`${c.dim} Pay affiliates in seconds, not months.${c.reset}`); console.log(''); console.log(`${c.dim}${'─'.repeat(50)}${c.reset}`); console.log(''); } function section(title) { console.log(''); console.log(`${c.dim}${'─'.repeat(50)}${c.reset}`); console.log(`${c.bold}${c.magenta} ${title}${c.reset}`); console.log(`${c.dim}${'─'.repeat(50)}${c.reset}`); console.log(''); } function success(msg) { console.log(`${c.green}${msg}${c.reset}`); } function info(label, value) { console.log(`${c.dim} ${label}:${c.reset} ${c.bold}${value}${c.reset}`); } function spinner(text) { const frames = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏']; let i = 0; process.stdout.write(`\n${c.yellow} ${frames[0]} ${text}${c.reset}`); return setInterval(() => { i = (i + 1) % frames.length; process.stdout.clearLine(0); process.stdout.cursorTo(0); process.stdout.write(`${c.yellow} ${frames[i]} ${text}${c.reset}`); }, 80); } function stopSpinner(interval) { clearInterval(interval); process.stdout.clearLine(0); process.stdout.cursorTo(0); } async function main() { banner(); console.log(`${c.bold} Let's set up your store${c.reset}\n`); const storeName = await ask(' Store name: '); const storeUrl = await ask(' Website URL: '); const email = await ask(' Email: '); const spin = spinner('Registering with YesAllOfUs...'); const result = await apiCall('POST', '/store/register', { store_name: storeName, store_url: storeUrl, email: email }); stopSpinner(spin); if (result.error) { console.log(`\n${c.red} ✗ Error: ${result.error}${c.reset}\n`); rl.close(); return; } success('Store registered successfully!'); section('📋 Your Credentials'); info('Store ID', result.store_id); info('API Key', result.api_key); info('API Secret', result.api_secret); info('Referral Code', result.store_referral_code); console.log(`\n${c.yellow} ⚠ Save your API Secret - it cannot be retrieved later${c.reset}`); section('🔗 Step 1: Connect Your Wallet'); console.log(`${c.dim} Open this URL to connect Xaman or Crossmark:${c.reset}\n`); console.log(`${c.cyan}${c.bold} https://yesallofus.com/connect?store=${result.store_id}${c.reset}`); section('📦 Step 2: Add to Your Checkout'); console.log(`${c.dim} Call this when an order completes:${c.reset}\n`); console.log(`${c.blue} const response = await fetch('https://api.dltpays.com/api/v1/payout', {`); console.log(` method: 'POST',`); console.log(` headers: {`); console.log(` 'Authorization': 'Bearer ${c.yellow}YOUR_API_SECRET${c.blue}',`); console.log(` 'Content-Type': 'application/json'`); console.log(` },`); console.log(` body: JSON.stringify({`); console.log(` order_id: orderId,`); console.log(` order_total: orderTotal,`); console.log(` referral_code: customerRefCode // from ?ref= param`); console.log(` })`); console.log(` });${c.reset}`); section('🎯 Step 3: Affiliate Signup'); console.log(`${c.dim} Share this link for affiliates to register:${c.reset}\n`); console.log(`${c.cyan}${c.bold} https://yesallofus.com/affiliate/signup?store=${result.store_id}${c.reset}`); section('📚 Resources'); console.log(`${c.dim} Documentation:${c.reset} ${c.cyan}https://yesallofus.com/docs${c.reset}`); console.log(`${c.dim} Support:${c.reset} ${c.cyan}mark@yesallofus.com${c.reset}`); console.log(`${c.dim} Twitter:${c.reset} ${c.cyan}@YesAllOfUs${c.reset}`); console.log(''); console.log(`${c.green}${c.bold} 🚀 You're ready to pay affiliates instantly!${c.reset}`); console.log(''); rl.close(); } main().catch(err => { console.error(`${c.red}Error: ${err.message}${c.reset}`); rl.close(); });