Skip to content

Exchange Pay (React)

Deposit via an exchange provider using hooks from @swapped/connect-sdk/react. Route here when the payment method has type: exchange_pay (see Payment methods).

Supported providers:

  • Binance Pay
  • KuCoin Pay
  • Gate Pay
  • Bybit Pay
  • Krak Pay
  • OKX Pay

Prerequisites

  1. Create a core client with a Swapped Connect sessionId (from your backend).
  2. Call loadSession() and wrap your tree with SwappedConnectProvider.
  3. Wrap the deposit UI with ExchangePayContextProvider.
tsx
import { createSwappedConnectClient } from '@swapped/connect-sdk'
import {
  ExchangePayContextProvider,
  SwappedConnectProvider,
} from '@swapped/connect-sdk/react'

const client = createSwappedConnectClient({
  sessionId: 'your-session-id',
})

void client.loadSession()

function App() {
  return (
    <SwappedConnectProvider client={client}>
      <ExchangePayContextProvider>
        <DepositScreen />
      </ExchangePayContextProvider>
    </SwappedConnectProvider>
  )
}

Flow overview

StepWhat happensHook
1. ProviderPick an exchangeuseExchangePayProviders
2. CurrenciesLoad tokens for the selectionuseExchangePaySupportedCurrencies, useExchangePayCurrency
3. AmountValidate fiat amount (currently USD)useExchangePayAmount
4. Create ordercreateOrder() from selectionuseExchangePayOrder, useExchangePaySelection
5. CheckoutShow QR / links; optional closeuseExchangePayOrder
6. WaitStatus + countdownExpiry & countdown, Event hooks
7. DoneSummary; restartSession()useExchangePayCompletedTransactionSummary

Session must be loaded and active before createOrder. After a completed payment, call restartSession() before starting again.

Step-by-step walkthrough: Example.

Providers

ProviderEnum
Binance PayIntegrationProvider.Binance
KuCoin PayIntegrationProvider.Kucoin
Gate PayIntegrationProvider.Gate
Bybit PayIntegrationProvider.Bybit
Krak PayIntegrationProvider.KrakPay
OKX PayIntegrationProvider.Okx

Hooks

Full list: Exchange Pay hooks. Use state hooks for UI and event hooks for side effects (navigate, toast).