Appearance
Example
End-to-end Cash App deposit with client.cashApp: pick a destination asset, create an order, show checkout, wait for completion.
Session must be loaded and active before createOrder. After a completed payment, call restartSession() before starting again.
1. Set up the client
ts
import {
createSwappedConnectClient,
IntegrationProvider,
Network,
TokenSymbol,
} from '@swapped/connect-sdk';
const client = createSwappedConnectClient({
sessionId: 'your-session-id', // from your backend
});
await client.loadSession();2. Confirm Cash App is available
Filter payment methods by provider. Cash App is not in the exchanges category.
ts
const method = await client.paymentMethods.getOne({
provider: IntegrationProvider.CashApp,
});
if (!method) {
throw new Error('Cash App is not available');
}3. Load assets and validate amount
Use minAmountFiat for the amount field. Pass asset + chain into createOrder (enums, not raw strings).
ts
const assets = await client.cashApp.getSupportedAssets();
const asset = assets.find(
item =>
item.asset === TokenSymbol.USDT && item.chain === Network.Ethereum,
);
if (!asset) {
throw new Error('Selected asset is not available');
}
const amountFiat = '25.00'; // USD string from your form
if (Number(amountFiat) < asset.minAmountFiat) {
throw new Error(`Minimum is $${asset.minAmountFiat}`);
}4. Create the order
Creating a new order replaces any previous active order.
ts
const order = await client.cashApp.createOrder({
amountFiat,
destinationAsset: asset.asset,
destinationChain: asset.chain,
});
// order.id, order.expiresAt, order.cashAppUrl, order.invoice5. Show checkout (Cash App / Lightning)
Encode cashAppUrl as a Cash App QR (or open it as a link). Encode invoice as a Lightning QR. Use shortUrl as a compact share/open link.
ts
const { cashAppUrl, shortUrl, invoice } = order;
// Encode cashAppUrl as a QR, or:
// <a href={cashAppUrl}>Open Cash App</a>
if (shortUrl) {
// Compact link — same destination as cashAppUrl
}
// Encode invoice as a Lightning QR6. Wait for completion, failure, or expiry
ts
const offCompleted = client.cashApp.onOrderCompleted(() => {
const summary = client.cashApp.getCompletedTransactionSummary();
console.log(summary);
// Show success UI, then restart before another payment
// await client.restartSession()
});
const offFailed = client.cashApp.onOrderFailed(() => {
// Payment failed — send the user back to the amount form
});
const offExpired = client.cashApp.onOrderExpired(() => {
// Active order cleared — send the user back to the amount form
});
// Optional: drive a countdown from expiresAt
const expiresAt = client.cashApp.getActiveOrderExpiresAt();
// When leaving the page / tearing down:
// offCompleted(); offFailed(); offExpired();Full walkthrough
Minimal script that runs the happy path (replace UI prompts with your own form).
ts
import {
createSwappedConnectClient,
IntegrationProvider,
Network,
TokenSymbol,
} from '@swapped/connect-sdk';
const client = createSwappedConnectClient({ sessionId: 'your-session-id' });
await client.loadSession();
const method = await client.paymentMethods.getOne({
provider: IntegrationProvider.CashApp,
});
if (!method) {
throw new Error('Cash App not available');
}
const assets = await client.cashApp.getSupportedAssets();
const asset = assets.find(
item =>
item.asset === TokenSymbol.USDT && item.chain === Network.Ethereum,
);
if (!asset) throw new Error('USDT on Ethereum unavailable');
const order = await client.cashApp.createOrder({
amountFiat: '25.00',
destinationAsset: asset.asset,
destinationChain: asset.chain,
});
// Render order.cashAppUrl / order.invoice / order.shortUrl in your UI
client.cashApp.onOrderCompleted(async () => {
const summary = client.cashApp.getCompletedTransactionSummary();
console.log('paid', summary);
await client.restartSession();
});
client.cashApp.onOrderFailed(() => {
console.log('payment failed — create a new order');
});
client.cashApp.onOrderExpired(() => {
console.log('order expired — create a new one');
});Next
| Topic | Docs |
|---|---|
| Asset fields & mins | Assets |
| Checkout fields / status | Orders & checkout |
| Countdown helpers | Expiry |
| Success screen data | Summary |
| Lifecycle listeners | Events |
| Error codes | Errors |