async function createOnrampingOrder() {
console.log("━━━ Example 2: Create Onramping Pay-Link ━━━\n");
const result = await apiRequest("POST", "/api/ramping/links", {
// ── Required fields ──────────────────────────
// Customer details — used for the checkout flow and KYC verification
firstName: "John",
lastName: "Smith",
email: "john.smith@example.com",
// The net fiat amount you (the merchant) want to receive
// The onramp provider may add its own fees on top for the customer
fiatAmount: 100,
// ── Optional fields ──────────────────────────
// Blockchain network for the crypto purchase
// Accepted values: "BTC" | "LTC" | "ETH" | "SOL" | "XRP"
// If omitted, falls back to your saved default in dashboard settings
network: "ETH",
// Crypto asset to purchase
// Native coins: "BTC", "LTC", "ETH", "SOL", "XRP"
// ERC-20 tokens (ETH network only): "USDT", "USDC"
// If omitted, falls back to your saved default in dashboard settings
asset: "USDT",
// Fiat currency the customer will pay in (defaults to "EUR")
// Supported: USD, EUR, GBP, AUD, AED, BRL, CAD, CHF, CZK, DKK,
// HKD, IDR, INR, JPY, MXN, NOK, NZD, PHP, PLN, QAR,
// RON, SAR, SEK, SGD, THB, TRY, TWD, VND, ZAR
fiatCurrency: "EUR",
// Your own unique reference for this order
// If omitted, the API generates one automatically
reference: "RAMP-ORDER-001",
// Optional: preferred onramp provider
// If omitted, the API auto-selects the best provider based on
// the customer's geolocation
// provider: "banxa",
});
// ── Reading the response ──────────────────────
console.log("Onramping pay-link created successfully!\n");
// *** This is the most important field ***
// Redirect your customer to this URL to start the checkout
console.log(" Checkout URL: ", result.url);
// The signed token embedded in the URL (for verification)
console.log(" Token: ", result.token);
console.log("\n ── Underlying crypto invoice ──");
// The crypto invoice created behind the scenes
console.log(" Order ID: ", result.order.id);
console.log(" Reference: ", result.order.reference);
console.log(" Deposit address: ", result.order.depositAddress);
console.log(" Crypto amount: ", result.order.amountCrypto, result.order.asset);
console.log(" Fiat amount: ", result.order.fiatAmount, result.order.fiatCurrency);
console.log(" Status: ", result.order.status);
console.log(" Expires at: ", result.order.expiresAt);
console.log("\n ── Pay-link details ──");
// Additional details about the pay-link and fee breakdown
console.log(" Fiat (net): ", result.link.fiatAmountNet);
console.log(" Fiat (gross): ", result.link.fiatAmountGross);
console.log(" Fee percent: ", result.link.feePercent);
console.log(" Provider hint: ", result.link.providerHint || "auto-selected");
console.log(" Link expires at: ", result.link.expiresAt);
console.log();
return result;
}