Build Crypto Payment Gateway with Swaps

Stablecoin volumes smashed $33 trillion last year. Merchants, here's your TypeScript blueprint for a payment gateway that swaps any token to stablecoins instantly.

$33T Stablecoin Boom: Build a Non-Custodial Crypto Payment Gateway in TypeScript — theAIcatchup

Key Takeaways

  • Stablecoin volumes hit $33T in 2025, pushing 46% of merchants to crypto.
  • Build non-custodial gateway with TypeScript + swapapi.dev: free, multi-chain swaps.
  • DIY beats vendor fees; poised for 19% market growth amid regulatory thaw.

$33 trillion. That’s the stablecoin transaction volume in 2025—a 72% jump from the year before, with USDC shouldering $18.3 trillion alone.

Crypto payments aren’t some fringe dream anymore. Merchants—46% in recent surveys—have jumped in for quicker settlements, slashed fees, cross-border ease. Market projections? $2 billion this year to $2.39 billion next, 19% growth. But here’s the rub: customers clutch whatever token they’ve got, merchants crave stablecoins. Enter the gateway.

Crypto payments are no longer experimental. Stablecoin transaction volume hit $33 trillion in 2025 — a 72% increase over the prior year — and USDC alone accounted for $18.3 trillion of that volume.

This non-custodial setup in TypeScript accepts any ERC-20 on supported chains, swaps to USDC or USDT via swapapi.dev. Free DEX aggregator, 46 EVM chains, zero API keys. Smart move in a post-FTX world—non-custodial dodges the custodian nightmares that tanked billions.

Why Merchants Can’t Ignore Crypto Anymore?

PayPal’s survey nails it: 88% of U.S. merchants fielded crypto payment asks. Customers hold DOGE from a moonshot, WETH from DeFi yields, or some obscure memecoin. You? You want USDC, settled fast, no volatility hangover. Gateways bridge that—fetch quotes, execute swaps, settle to your wallet.

But vendors charge 1-2% fees. Build your own? Near-zero ongoing costs, full control. My take: this DIY path echoes early PayPal’s pivot from checks to instant digital—same disruption vibe, but with blockchain’s permanence. Bold prediction—by 2027, 70% of e-comm giants run custom gateways as regs stabilize.

The Payment Flow, Dissected

Customer picks token, amount. Gateway pings swapapi.dev for a quote. Shows expected USDC out, min amount (slippage-proof), price impact. Approve? Boom—executable tx calldata ready.

Code’s lean. Bun or Node, ethers v6, Hono for the API. Config chains like Ethereum (chainId 1, USDC at 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48), Arbitrum (42161), Base (8453), BSC (56, watch USDT’s 18 decimals—gotcha!). Merchant wallet? Plug yours in.

That getPaymentQuote function? Gold. Hits https://api.swapapi.dev/v1/swap/${chainId}, params for tokenIn, amountIn, sender. Max slippage 0.5%. Fetches tx with from/to/data/value. Expires in 30s—prices twitch, deadlines tick.

async function getPaymentQuote(
  chainId: number,
  tokenIn: string,
  amountIn: string,
  sender: string,
  orderId: string
): Promise<PaymentQuote> {
  // ... fetches from swapapi.dev
}

Human-readable? Parse decimals right—USDC’s 6, BSC USDT’s 18. Screw that, amounts flop.

Next? Customer signs tx via wallet (MetaMask, whatever). Your server? Relays or executes from a hot wallet with gas. Non-custodial twist: customer sends direct to DEX router, you settle.

Does swapapi.dev Hold Up Under Pressure?

Free, keyless, 46 chains. Covers Uniswap, 1inch routes—best price hunts. But test it. No route? Error. High impact (>5%)? Bail, suggest smaller amount. Real-world: Arbitrum/Base gas cheap, Ethereum? Pricey for big swaps.

Skepticism check. Hype screams “easy money.” Reality: rugs, hacks lurk. This setup’s safe-ish—customer controls keys, swaps atomic. Still, audit your server, rate-limit APIs, monitor MEV. Unique insight: unlike 2017 ICO gateways that flamed out on centralization, this decentralized swap layer survives bear markets—data shows DEX volumes up 40% YoY despite BTC dips.

Setting Up Your Server

bun add ethers hono. payment-gateway.ts. Define CHAINS record, MERCHANT_WALLET. Expose /quote endpoint:

const app = new Hono();

app.post('/quote', async (c) => {
  const { chainId, tokenIn, amountIn, sender, orderId } = await c.req.json();
  try {
    const quote = await getPaymentQuote(chainId, tokenIn, amountIn, sender, orderId);
    return c.json(quote);
  } catch (e) {
    return c.json({ error: e.message }, 400);
  }
});

Add /execute? Optional—customer broadcasts solo. Gas? Fund relayer wallet per chain.

Market dynamics favor this. Stripe’s crypto push lags—1% fees, limited chains. Your edge: any token, instant USDC, multi-chain. 19% market growth? Understates it—add remittances ($800B global), remittances crypto slice hits 10% by 2028.

But PR spin alert: “projected growth” often vendor fluff. Real driver? Emerging markets—Nigeria, Argentina—where USD stables beat inflation. Merchants there integrate first.

Risks and the Sharp Reality

Volatility. Even stables wobble—USDC depeg 2023 flashbacks. Swaps? Slippage eats 1-3% on illiquid pairs. Regs? EU’s MiCA, U.S. clarity incoming—non-custodial sidesteps KYC headaches.

Scale it. Redis for quotes, webhooks for settlements. Monitor via Dune dashboards—track volumes, failures.

Worth it? Yes, if >$10K/month payments. Below? Stripe Crypto suffices.


🧬 Related Insights

Frequently Asked Questions

How do I build a crypto payment gateway with swaps? Grab TypeScript, ethers, Hono. Use swapapi.dev for quotes/tx. Config chains, fetch quotes, let customers sign.

What chains and tokens does swapapi.dev support? 46 EVM chains—Eth, Arbitrum, Base, BSC, etc. Any ERC-20 in, USDC/USDT out.

Is a non-custodial crypto gateway safe for merchants? Yes—customer funds never touch you. Swaps atomic, settles direct. But watch gas, slippage.

Priya Sundaram
Written by

Hardware and infrastructure reporter. Tracks GPU wars, chip design, and the compute economy.

Frequently asked questions

How do I build a crypto payment gateway with swaps?
Grab TypeScript, ethers, Hono. Use swapapi.dev for quotes/tx. Config chains, fetch quotes, let customers sign.
What chains and tokens does swapapi.dev support?
46 EVM chains—Eth, Arbitrum, Base, BSC, etc. Any ERC-20 in, USDC/USDT out.
Is a non-custodial crypto gateway safe for merchants?
Yes—customer funds never touch you. Swaps atomic, settles direct. But watch gas, slippage.

Worth sharing?

Get the best AI stories of the week in your inbox — no noise, no spam.

Originally reported by dev.to

Stay in the loop

The week's most important stories from theAIcatchup, delivered once a week.