πŸ”—iFrame initialization

Need help with your integration? Click here to chat with our custom GPT for instant answers.

iFrame Initialisation (Off-Ramp)

To integrate the Swapped Off-Ramp widget, build a secure URL with required and optional parameters. The widget enables users to send crypto and receive fiat payouts.

Required Parameters

  • apiKey: Your public API key for customer and transaction assignment.

  • signature: Your HMAC-SHA256 signature of the full query string, base64-encoded.

Optional Parameters

  • email: Pre-fills the customer's email address on the login page.

  • customerKYC: The level of Know Your Customer (KYC) verification.

    • 0 = the customer has not completed KYC.

    • 1 = the customer has completed Proof of ID + Liveness Check.

    • 2 = the customer has completed Proof of ID + Liveness Check + Proof of Address.

  • style: The Styling ID and widget customization options can be configured on the β€œWidget Customizations” page within the Swapped.com Dashboard.

  • minAmount: Sets the minimum order amount in EUR. This cannot be lower than 7 EUR.

  • fiatCurrencyCode: Fiat payout currency (e.g. EUR, USD).

  • cryptoCurrencyCode: The crypto the user is selling (e.g. BTC, ETH).


Example with PHP

<?php

// Define the public API key.
$publicKey = 'your_public_key';

// Define the secret API key.
$secretKey = 'your_secret_key';

// Define the currency code.
$currencyCode = 'currency_code';

// Build URL with query parameters.
$originalUrl = "https://widget.swapped.com/sell?apiKey={$publicKey}&currencyCode={$currencyCode}";

// Parse the URL into its components.
$parsedUrl = parse_url($originalUrl);

// Create a SHA-256 HMAC signature from the query string, then encode in Base64.
$signature = base64_encode(hash_hmac('sha256', '?'.$parsedUrl['query'], $secretKey, true));

// Append the URL-encoded signature to the URL.
$urlWithSignature = "{$originalUrl}&signature=" . urlencode($signature);

// Output the final URL with the signature appended.
echo $urlWithSignature;

Example with NodeJS

// Import the crypto module.
import crypto from 'crypto';

// Define the public API key.
const publicKey = 'your_public_key';

// Define the secret API key.
const secretKey = 'your_secret_key';

// Define the currency code.
const currencyCode = 'currency_code';

// Build URL with query parameters.
const originalUrl = `https://widget.swapped.com/sell?apiKey=${publicKey}&currencyCode=${currencyCode}`;

// Create a SHA-256 HMAC signature from the URL's search string, then encode in Base64.
const signature = crypto.createHmac('sha256', secretKey).update(new URL(originalUrl).search).digest('base64');

// Append the URL-encoded signature to the original URL.
const urlWithSignature = `${originalUrl}&signature=${encodeURIComponent(signature)}`;

// Output the final URL with the signature appended.
console.log(urlWithSignature);

iFrame Embed Example

<iframe allow="accelerometer; autoplay; camera; encrypted-media; gyroscope; payment; clipboard-read; clipboard-write" src="https://widget.swapped.com/sell?apiKey={pk_live_key}&currencyCode=btc&signature=lorem" title="Buy crypto with Swapped" style="height: 585px; width: 445px; border-radius: 
0.75rem; margin: auto;"></iframe>

Order Status Flow

payment_pending β†’ order_processing β†’ payout_pending β†’ order_completed β†˜ order_cancelled

Status Definitions:

payment_pending: Waiting for the crypto deposit

order_processing: Crypto detected as sent but not confirmed yet

payout_pending: Crypto has been confirmed on the blockchain, and the payout to the user is pending.

order_completed: Crypto has been received, and the payout has been sent to the user

order_cancelled: The order has been cancelled (with a potential refund)

Last updated