#!/usr/bin/env node const API_URL = 'http://localhost:8000/createtransaksi' const API_KEY = 'dev-key' const orderId = `SNAPTEST-${Date.now()}` const payload = { mercant_id: 'TESTMERCHANT', timestamp: Date.now(), deskripsi: 'Testing Snap Payment Mode', nominal: 150000, nama: 'Test Snap User', no_telepon: '081234567890', email: 'test@snap.com', item: [ { item_id: orderId, nama: 'Test Product Snap', harga: 150000, qty: 1 } ] } try { const response = await fetch(API_URL, { method: 'POST', headers: { 'Content-Type': 'application/json', 'x-api-key': API_KEY }, body: JSON.stringify(payload) }) if (!response.ok) { const error = await response.text() console.error('āŒ Error:', response.status, error) process.exit(1) } const data = await response.json() const paymentUrl = data.data?.url || data.payment_url const token = paymentUrl ? paymentUrl.split('/pay/')[1] : null console.log('āœ… Payment link created successfully!') console.log('\nšŸ”— Snap Mode Payment Link:') console.log(paymentUrl.replace('https://midtrans-cifo.winteraccess.id', 'http://localhost:5173')) console.log('\nšŸ“‹ Order ID:', orderId) console.log('šŸ’° Amount: Rp 150,000') console.log('šŸ”‘ Mode: SNAP (Hosted UI)') if (token) { console.log('\nšŸ“„ Token:', token.substring(0, 50) + '...') } } catch (error) { console.error('āŒ Failed to create payment link:', error.message) process.exit(1) }