Swipelux
Rails/Our OnRamp/Server-side Integration

Get Order Information

Retrieve comprehensive information about card rail orders, including transaction status, amounts, fees, and blockchain transaction details. This endpoint is useful for order tracking, user-facing status displays, and reconciliation processes.

Quick Reference

URL

GET https://api.swipelux.com/api/public/orders/{orderId}

Request Parameters

ParameterTypeRequiredDescription
orderIdstringYesThe ID of the order to get information about

Authentication

This is a public endpoint - no API key required. The order ID serves as the authentication token.

Implementation Examples

Response Structure

Example Response

{
  "orderId": "ord_abc123def456",
  "externalId": "user_purchase_123",
  "createdAt": "2024-01-31T14:16:16.798Z",
  "completedAt": "2024-01-31T14:18:45.123Z",
  "status": "SUCCESS",
  "email": "user@example.com",
  "phone": "+1234567890",
  "from": {
    "amount": 100.00,
    "currency": {
      "code": "USD",
      "name": "US Dollar"
    }
  },
  "to": {
    "amount": 99.2,
    "currency": {
      "code": "USDC",
      "name": "USD Coin"
    }
  },
  "fees": {
    "total": 0.80,
    "breakdown": [
      {
        "type": "processing",
        "amount": 0.50,
        "description": "Card processing fee"
      },
      {
        "type": "network",
        "amount": 0.30,
        "description": "Blockchain network fee"
      }
    ]
  },
  "targetAddress": "0x1234567890abcdef1234567890abcdef12345678",
  "network": "polygon",
  "transactions": [
    {
      "type": "crypto_transfer",
      "description": "USDC transfer to user wallet",
      "transactionId": "0xabc123def456...",
      "publicUrl": "https://polygonscan.com/tx/0xabc123def456...",
      "status": "confirmed",
      "confirmations": 12
    }
  ]
}

Order Status Values

StatusDescription
PENDINGOrder created but payment not yet initiated
PROCESSINGPayment is being processed
SUCCESSOrder completed successfully
FAILEDOrder failed during processing
CANCELLEDOrder was cancelled by user or system
EXPIREDOrder expired before payment completion

Transaction Types

TypeDescription
card_paymentCredit/debit card payment processing
crypto_transferBlockchain transfer to user wallet
fee_collectionFee collection transaction

Common Use Cases

Order Status Display

async function displayOrderStatus(orderId) {
  const order = await getCardRailOrder(orderId);
  
  const statusMessages = {
    'PENDING': 'Your order is being prepared...',
    'PROCESSING': 'Processing your payment...',
    'SUCCESS': 'Purchase completed successfully!',
    'FAILED': 'Payment failed. Please try again.',
    'CANCELLED': 'Order was cancelled.',
    'EXPIRED': 'Order expired. Please create a new order.'
  };
  
  return {
    message: statusMessages[order.status],
    canRetry: order.status === 'FAILED' || order.status === 'EXPIRED',
    transactionUrl: order.transactions?.[0]?.publicUrl,
    completedAt: order.completedAt
  };
}

Order Reconciliation

async function reconcileOrders(externalIds) {
  const results = await Promise.allSettled(
    externalIds.map(async (externalId) => {
      // You would need to store the mapping of externalId to orderId
      const orderId = await getOrderIdByExternalId(externalId);
      const order = await getCardRailOrder(orderId);
      
      return {
        externalId,
        orderId: order.orderId,
        status: order.status,
        amount: order.from.amount,
        currency: order.from.currency.code,
        completedAt: order.completedAt
      };
    })
  );
  
  return results
    .filter(result => result.status === 'fulfilled')
    .map(result => result.value);
}

User Order History

// Note: You'd need to maintain a mapping of users to their order IDs
async function getUserOrderHistory(userId) {
  const userOrderIds = await getUserOrderIds(userId); // Your internal function
  
  const orders = await Promise.all(
    userOrderIds.map(orderId => getCardRailOrder(orderId))
  );
  
  return orders
    .sort((a, b) => new Date(b.createdAt) - new Date(a.createdAt))
    .map(order => ({
      orderId: order.orderId,
      status: order.status,
      amount: `${order.from.amount} ${order.from.currency.code}`,
      crypto: `${order.to.amount} ${order.to.currency.code}`,
      date: new Date(order.createdAt).toLocaleDateString(),
      transactionUrl: order.transactions?.[0]?.publicUrl
    }));
}

Response Status Codes

Status CodeDescription
200Order found and returned successfully
404Order not found
429Rate limit exceeded
500Internal server error

Rate Limits

The Get Order endpoint has generous rate limits:

  • 100 requests per minute per IP address
  • 1000 requests per minute per merchant account

For high-volume applications, consider caching order data and using webhooks for real-time updates instead of frequent polling.

Next Steps

  • Real-time updates: Set up webhooks instead of polling for order status
  • Error handling: Implement retry logic for temporary failures
  • User experience: Display transaction URLs for blockchain verification

On this page