Skip to content

Orders & checkout

Create a Cash App onramp order and show checkout (Cash App URL / Lightning invoice).

When to use

After the user picks an asset and amount. Session must be active.

Methods

MethodPurpose
createOrder(request)Create onramp order; returns CashAppOrder
getActiveOrder()In-memory active order, or null
reset()Clear local active order (also happens on session refresh)

There is no closeOrder or status-poll method. Listen for events while checkout is showing.

Request

ts
type CreateCashAppOrderRequest = {
  amountFiat: string; // fiat USD amount, e.g. '25.00'
  destinationChain: Network;
  destinationAsset: TokenSymbol;
};

Creating a new order replaces any previous active order.

Example — create

ts
import { Network, TokenSymbol } from '@swapped/connect-sdk';

const order = await client.cashApp.createOrder({
  amountFiat: '25.00',
  destinationAsset: TokenSymbol.USDT,
  destinationChain: Network.Ethereum,
});

console.log(order.id, order.expiresAt, order.cashAppUrl);

Checkout UI fields

FieldUse for
order.cashAppUrlOpen Cash App / encode as a Cash App QR
order.shortUrlCompact share / open link
order.invoiceBTC Lightning invoice — encode as a Lightning QR
order.fiatAmount / order.fiatCurrencyDeposit value (excluding fees)
order.amountTotal fiat the user pays (includes fees)
order.estimatedOutExpected destination amount
order.destinationAsset / order.destinationChainReceive token + network
order.recipientAddressDestination address
order.providerFee / order.merchantFeeFee breakdown
order.expiresAtExpiry timestamp (ms since epoch) — see Expiry
ts
const { cashAppUrl, shortUrl, invoice } = order;

// Encode cashAppUrl as a QR, or open it:
// <a href={cashAppUrl}>Open Cash App</a>

if (shortUrl) {
  // <a href={shortUrl}>Open</a>
}

// Encode invoice as a Lightning QR

Starting a new order clears the previous active order automatically.

Status

Prefer events for live updates. Status values are 'pending' | 'success' | 'failure'.

Read the in-memory order with getActiveOrder() when you need the current checkout payload.

Errors

CodeWhenWhat to do
SESSION_REQUIREDNo loaded sessionloadSession()
SESSION_NOT_ACTIVESession cannot start a new paymentrestartSession() first
API_ERRORCreate network failureRetry; keep user on a safe step

See Errors.