Swapped.com Documentation
  • πŸš€On-ramp Integration
    • βš™οΈSandbox Environment
    • πŸ”—iFrame initialization
      • πŸ’¬Order Notifications
      • 🚨Order Notification Retry Policy
      • πŸͺ™Supported Cryptocurrencies
      • πŸ’΅Supported Fiat Currencies
      • πŸ—£οΈSupported languages
      • Onramp Aggregator Partners
    • πŸ’³Test Credentials
    • 🎯Endpoints
      • πŸ’³Get Payment Methods
      • 🟒Get Payment Status
      • πŸ“˜Get Transactions
      • πŸ“ˆGet Current Price
      • βš–οΈGet Minimum Amount
    • FAQ
  • πŸš€Connect Integration
    • πŸ”—iFrame Initialization
    • 🀝Supported Connections
Powered by GitBook
On this page
  • Callback Config Priority
  • Best Practices
  • Callback examples:
  • Response Definition:
  • Order State Flows
  • The signature:
  1. On-ramp Integration
  2. iFrame initialization

Order Notifications

PreviousiFrame initializationNextOrder Notification Retry Policy

Last updated 2 months ago

To receive order notifications, you can either provide a responseUrl per order or define a merchant-level webhook on the β€œDevelopers” page within the . You will receive the notification via the provided URL. In the header of the HTTP request, there’s a signature to validate the data comes from Swapped.com.

The callback destination is determined at the time of order creation and cannot be modified afterwards.

The system follows this priority:

  • If an order-level responseURL is provided during order creation, it will be used for all callbacks for that order.

  • If no order-level responseURL exists, the system will use the merchant-level webhook URL configured in the dashboard.

  • If neither exists at order creation, no callbacks will be sent for that order.

Callback Config Priority

The system follows a clear priority structure for determining where to send callbacks.

  • If a responseURL is provided in the iframe initialization URL, this will be used as a priority.

  • If a responseURL is not provided, but a callback URL is configured via the , this will be used.

  • If neither responseURL nor callback URL is set, callbacks will be disabled for this order.

This configuration is locked in when the order is created and cannot be changed, even if you later update your merchant level webhook settings.

Best Practices

Order notifications can be resent to account for network errors. As such you must validate that a transaction has not been credited before crediting for it.

Callback examples:

Payment Pending:

Indicates that the transaction has been created but the customer hasn't completed payment.

{
  "order_status": "payment_pending",
  "external_customer_id": "1234567",
  "order_crypto": "LTC",
  "order_id": "9fcc45a5-4def-4953-9bd8-9ff75d9aaa9c"
}

Order Cancelled:

Indicates that the order is cancelled for any reason, such as payment failure, or user cancellation.

{
  "order_status": "order_cancelled",
  "external_customer_id": "1234567",
  "order_id": "9fcc45a5-4def-4953-9bd8-9ff75d9aaa9c"
}

Order Completed:

Indicates that the order has been processed, and the cryptocurrency purchase was successful.

{
  "order_id": "9fcc45a5-4def-4953-9bd8-9ff75d9aaa9c",
  "order_crypto_amount": 0.347764,
  "order_crypto": "LTC",
  "order_status": "order_completed",
  "order_crypto_address": "ltc1qlec2yfpkdvn4lr0vpf27qggrxtu34zeu5l6g2u",
  "external_customer_id": "1234567",
  "order_amount_usd": "25",
  "order_amount_usd_plus_fees": "25.5",
  "order_amount_eur": "21",
  "order_crypto_tag": 12345,
  "order_amount_eur_plus_fees": "22.5",
  "network": "litecoin"
}

Order Broadcasted:

Indicates that the cryptocurrency transaction has been broadcasted to the blockchain.

{
  "order_id": "9fcc45a5-4def-4953-9bd8-9ff75d9aaa9c",
  "order_crypto_amount": 0.347764,
  "order_crypto": "LTC",
  "order_status": "order_broadcasted",
  "transaction_id": "ea458dda0ff8583199bdd4d9b9a69a2813694764a633fd40b27de22a868cebec",
  "order_crypto_address": "ltc1qlec2yfpkdvn4lr0vpf27qggrxtu34zeu5l6g2u",
  "external_customer_id": "1234567",
  "order_amount_usd": "25",
  "order_amount_usd_plus_fees": "25.5",
  "order_amount_eur": "21",
  "order_crypto_tag": 12345,
  "order_amount_eur_plus_fees": "22.5",
  "network": "litecoin"
}

Response Definition:

  • order_id: The order id on Swapped.com.

  • order_crypto_amount: The exact cryptocurrency amount you will receive.

  • order_crypto: The cryptocurrency you receive.

  • order_status: The current status of the order.

  • order_crypto_address: The cryptocurrency address where you receive the cryptocurrency.

  • external_customer_id: Your customer's ID (If provided in the URL).

  • order_amount_usd: The order_crypto_amount converted to USD (Mid-market rates without spread). This does not include the platform fee.

  • order_amount_usd_plus_fees: The order_amount_usd plus the platform fee.

  • network: The network used to send transactions via.

Order State Flows

An order can follow one of two possible state flows:

Flow 1, this is applied when an order gets completed successfully and the user receives crypto:

payment_pending β†’ order_completed β†’ order_broadcasted

Flow 2, this occurs when an order gets cancelled for any reason and the user does not receive crypto:

payment_pending β†’ order_cancelled

Both order_broadcasted and order_cancelled are final states that correspond to a finalized swapped.com order ID. This means that an order will never go from a completed to a cancelled state.

The signature:

Compute an HMAC with a SHA-256 hash function. Use your secret API key as the key and use the request body as the message. Compare this to the signature sent in the request header.

Example with NodeJS:

import crypto from 'crypto';

const secretKey = 'sk_test_key'; // Replace with your secret key
const requestBody = '{ "order_id": "9fcc45a5-4def-4953-9bd8-9ff75d9aaa9c"}'

const signature =
  crypto
    .createHmac('sha256', secretKey)
    .update(requestBody)
    .digest('base64'); 

For more information on notification resending, see the .

πŸš€
πŸ”—
πŸ’¬
Need help with your integration? Click here to chat with our custom GPT for instant answers.
Swapped.com Dashboard
Swapped.com dashboard
Order Notification Retry Policy