Swipelux

Fiat ← Crypto

Sell USDC for USD; verify via webhook then REST

Summary

Create a Customer, provision a wallet, create a crypto→fiat transfer to settle USDC → USD, then wait for a webhook and re-verify via REST before marking the payout complete. Rails/collection of payout details may require enablement. Fiat: USD only. Crypto: USDC only (today). (General transfer patterns and crypto-rail requests are documented; payout rails to fiat depend on your account configuration.)

Problem → Solution mapping

Pain pointCapabilityMechanism
Move funds out to fiatTransfers APIPOST /v1/transfers with crypto source and fiat destination
User data / payout detailsHosted flow if requiredYour account may expose a hosted step to collect payout details
Final, auditable stateWebhooks + REST re-verifySubscribe, validate HMAC, then GET /v1/transfers/{id} before marking paid

Architecture

Implementation steps

Create user

curl https://wallet.swipelux.com/v1/customers \
  --request POST \
  --header 'Content-Type: application/json' \
  --header 'X-API-Key: YOUR_API_KEY' \
  --data '{
    "firstName":"John","lastName":"Doe","email":"john.doe@example.com","phone":"+1234567890",
    "birthDate":"1990-01-01",
    "residentialAddress":{"streetLine1":"123 Main St","city":"San Francisco","state":"CA","postalCode":"94101","country":"US"},
    "identifyingInformation":[{"type":"drivers_license","issuingCountry":"US",
      "frontSideImage":"data:image/png;base64,iVBORw0KGgoAAA...","backSideImage":"data:image/png;base64,iVBORw0KGgoBBB..."}]
  }'

Provision wallet

curl https://wallet.swipelux.com/v1/customers/cus_cK69MttD5nAUAbud1B/wallets \
  --request POST \
  --header 'Content-Type: application/json' \
  --header 'X-API-Key: YOUR_API_KEY' \
  --data '{ "chains": ["base"] }'

Make a transfer (USDC → USD)

curl https://wallet.swipelux.com/v1/transfers \
  --request POST \
  --header 'Content-Type: application/json' \
  --header 'X-API-Key: YOUR_API_KEY' \
  --data '{
    "onBehalfOf":"cus_cK69MttD5nAUAbud1B",
    "amount":"50.0",
    "source":{ "paymentRail":"crypto" },
    "destination":{ "currency":"USD" }
  }'

Notes:

  • amount here denotes the crypto amount to sell (USDC units).
  • Depending on your payout rail configuration, the API may process automatically (state transitions via webhooks) or guide the user through a hosted step to provide payout details. Use webhook + REST to determine truth.

Wait & verify the webhook (then REST re-check)

Configure webhooks:

curl https://wallet.swipelux.com/v1/webhooks \
  --request PATCH \
  --header 'Content-Type: application/json' \
  --header 'X-API-Key: YOUR_API_KEY' \
  --data '{ "url": "https://your-domain.com/webhook" }'

Validate signature and re-fetch the transfer before marking payout delivered:

const crypto = require('crypto');
const express = require('express');
const fetch = require('node-fetch');
const app = express();
 
app.post('/webhook', express.raw({ type: 'application/json' }), async (req, res) => {
  const sig = req.header('X-Webhook-Signature') || '';
  const secretKey = process.env.WEBHOOK_SECRET_KEY;
  const expected = crypto.createHmac('sha256', secretKey).update(req.body).digest('hex');
  if (!crypto.timingSafeEqual(Buffer.from(sig, 'hex'), Buffer.from(expected, 'hex'))) {
    return res.status(401).end();
  }
  const evt = JSON.parse(req.body.toString('utf8'));
  if (evt.type === 'transfer.completed') {
    const trId = evt.data?.id;
    if (trId) {
      const r = await fetch(`https://wallet.swipelux.com/v1/transfers/${trId}`, {
        headers: {
          'X-API-Key': process.env.SWIPELUX_API_KEY,
          'Content-Type': 'application/json'
        }
      });
      const tr = await r.json();
      // Mark payout complete only if tr.state === 'completed'
    }
  }
  res.sendStatus(200);
});

Limits & caveats

  • Fiat: USD only. Crypto: USDC only (today).
  • Always treat REST as source of truth; do not fulfill based on webhook alone.
  • Payout rails to fiat depend on your account configuration.

On this page