Swipelux

Order mapping and identification

Map and identify orders using tokens and external IDs in the onramp widget

Order token

The orderToken parameter is used to initiate the widget with a prepared order created using our REST API.

Example usage

const widget = new SwipeluxWidget({
  apiKey: "YOUR_PUBLISHABLE_API_KEY",
  orderToken: "YOUR_ORDER_TOKEN",
});

When to use order tokens

Order tokens are useful when you want to:

  • Pre-configure specific order parameters on the server side
  • Implement server-side validation before allowing widget initialization
  • Track orders through your backend systems before user interaction
  • Ensure consistent pricing and availability

External ID

The externalId parameter allows you to link Swipelux orders to your own system's order IDs or references.

Requirements

  • Maximum length: 64 characters
  • Must be unique within your system
  • Can contain alphanumeric characters, hyphens, and underscores

Static external ID

If you know the external ID in advance:

const widget = new SwipeluxWidget({
  apiKey: "YOUR_PUBLISHABLE_API_KEY",
  externalId: "YOUR_EXTERNAL_ID",
});

Dynamic external ID

If you need to generate the external ID at runtime:

const widget = new SwipeluxWidget({
  apiKey: "YOUR_PUBLISHABLE_API_KEY",
  externalId: async () => {
    // Generate or fetch external ID from your system
    const orderId = await getExternalIdFromServer();
    return orderId;
  },
});

Example with UUID generation

const widget = new SwipeluxWidget({
  apiKey: "YOUR_PUBLISHABLE_API_KEY",
  externalId: async () => {
    // Generate a unique identifier
    return `order_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
  },
});

Combining order token and external ID

You can use both parameters together for maximum flexibility:

const widget = new SwipeluxWidget({
  apiKey: "YOUR_PUBLISHABLE_API_KEY",
  orderToken: "YOUR_PREPARED_ORDER_TOKEN",
  externalId: "your-internal-order-id-123",
});

Type definitions

export type ExternalIdResolver = string | (() => Promise<string>);

On this page