Skip to content

Cash App (React)

Deposit with Cash App using hooks from @swapped/connect-sdk/react. Route here when the payment method has type: cash_app (see Payment methods).

The user picks a destination asset and a fiat amount (currently USD), then pays in Cash App or with a Lightning invoice.

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 CashAppProvider.
tsx
import { createSwappedConnectClient } from '@swapped/connect-sdk'
import {
  CashAppProvider,
  SwappedConnectProvider,
} from '@swapped/connect-sdk/react'

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

void client.loadSession()

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

Flow overview

StepWhat happensHook
1. AssetsLoad destination tokensuseCashAppSupportedAssets, useCashAppAsset
2. AmountValidate fiat amount (currently USD)useCashAppAmount
3. Create ordercreateOrder() from selectionuseCashAppOrder, useCashAppSelection
4. CheckoutShow Cash App URL / Lightning invoiceuseCashAppOrder
5. WaitCompletion, failure, or countdownExpiry & countdown, Event hooks
6. DoneSummary; restartSession()useCashAppCompletedTransactionSummary

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

Step-by-step walkthrough: Example.

Hooks

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