Swipelux
Rails/Our OnRamp/Server-side Integration

Basic Integration

Create Swipelux OnRamp orders programmatically with the minimum required parameters. This guide covers the essential steps to get started with server-side order creation.

Quick Start

This guide features implementations in JavaScript, Python, PHP, Go, and Java, but these snippets can be translated to almost any other language by following the Reference section.

Get Your Secret API Key

If you don't have one, create it in the Merchant Panel. Read here for more information.

Install Dependencies if Needed

If you don't have a preferred language, we recommend using JavaScript. Most modern browsers and runtimes have Fetch API built-in, which is a modern way to make HTTP requests.

If you need to use a different language, you can use a package manager like pip to install the requests library for Python or curl for PHP. Refer to your language's documentation for more information.

Define a Basic Function

async function createBasicOrder(
  secretKey,
  {
    amount,
    fromCurrency = "USD", 
    toCurrency = "USDC",
    targetAddress,
    userEmail,
    userPhone,
  },
) {
  const response = await fetch(
    "https://api.swipelux.com/api/orders/createPrepared",
    {
      method: "POST",
      headers: {
        Authorization: secretKey,
        "Content-Type": "application/json",
      },
      body: JSON.stringify({
        amounts: {
          from: {
            amount,
            currency: fromCurrency
          },
          to: {
            currency: toCurrency
          },
        },
        user: {
          email: userEmail,
          phone: userPhone
        },
        targetAddress,
      }),
    },
  );
 
  if (!response.ok) {
    const error = await response.json();
    throw new Error(`API Error: ${error.message}`);
  }
 
  return await response.json();
}

Make Your First Request

try {
  const response = await createBasicOrder("YOUR_SECRET_KEY_HERE", {
    amount: 100,
    fromCurrency: "USD",
    toCurrency: "USDC", 
    targetAddress: "0x1234...",
    userEmail: "user@example.com",
    userPhone: "+1234567890",
  });
  console.log("Order created:", response.orderId);
  console.log("Order token:", response.orderToken);
} catch (error) {
  console.error("Error:", error.message);
}

Handle the Response

The JSON response contains important information about the created order:

{
  "orderId": "ord_abc123def456",
  "orderToken": "ord_token_abc123def456",
  "acsUrl": "https://track.swipelux.com?specificSettings={...}",
  "externalId": null
}

Using the response:

  • acsUrl: Direct users to this URL to complete payment via Payment Link
  • orderToken: Use with the widget for embedded integration
  • orderId: Track this order in your system and match with webhook events

Reference

URL

POST https://api.swipelux.com/api/orders/createPrepared

Request Headers

HeaderValueRequired
AuthorizationYour secret API keyYes
Content-Typeapplication/jsonYes

Required Parameters

PropTypeDefault
targetAddress
string
-
user
object
-
amounts
object
-

amounts Object

PropTypeDefault
to.currency
string
-
from.amount
number
-
from.currency
string
-

user Object

PropTypeDefault
email?
string
-
phone
string
-

Next Steps

After creating your first order:

On this page