Skip to main content

Installation

npm install @cherp/react-native-sdk

Setup

Initialize the SDK at app startup:
import { PaymentSDK } from '@cherp/react-native-sdk';

const sdk = PaymentSDK.init({
  apiKey: 'pk_live_...',
  debug: __DEV__,
});

Requesting a payment

// 1. Create an intent
const intent = await sdk.createIntent({
  chain: 'solana:5eykt4UsFv8P8NJdTREpY1vzqKq2Kvdp',
  token: 'USDC',
  amount: '10.50',
  requestor: wallet.address,
  idempotencyKey: 'order_982734',
  metadata: { orderId: '982734' },
});

// 2. Start audio broadcast
const broadcast = sdk.broadcast(intent);

// 3. Watch for fulfillment
sdk.onStatusChange(intent, (status, context) => {
  if (status === 'confirmed') {
    broadcast.stop();
    // Payment complete
  }
});

Fulfilling a payment

// 1. Listen for audio signal
const received = await sdk.listen();

// 2a. Default UI — SDK renders bottom sheet
sdk.onIntentReceived(received.intentId, wallet);

// 2b. Headless mode — render your own UI
sdk.onIntentReceived(received.intentId, wallet, {
  headless: true,
  onDetails: (intent, summary) => {
    // Render payment details
  },
  onComplete: (intent) => {
    // Payment confirmed
  },
  onError: (error) => {
    // Handle error
  },
});

// When user confirms in headless mode:
await sdk.confirm();
// Deep link
const link = sdk.getDeepLink(intent);
// "yourapp://pay?intent_id=pi_abc123"

// QR code payload
const qrPayload = sdk.getQRPayload(intent);