Skip to main content

Installation

Add the Cherp SDK via Swift Package Manager:
https://github.com/cherp-dev/cherp-ios-sdk

Setup

Initialize the SDK at app startup:
import CherpSDK

let sdk = PaymentSDK.init(
  apiKey: "pk_live_...",
  debug: false
)

Wallet interface

Implement the PaymentWallet protocol for your wallet provider:
class MyWallet: PaymentWallet {
  var address: String { get { return walletAddress } }
  var chain: CAIP2ChainId { get { return .solana } }

  func signTransaction(_ tx: UnsignedTransaction) async throws -> SignedTransaction {
    // Sign with your wallet provider
  }
}

Requesting a payment

// 1. Create an intent
let intent = try await sdk.createIntent(
  chain: "solana:5eykt4UsFv8P8NJdTREpY1vzqKq2Kvdp",
  token: "USDC",
  amount: "10.50",
  requestor: wallet.address,
  idempotencyKey: "order_982734"
)

// 2. Start audio broadcast
let broadcast = sdk.broadcast(intent)

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

Fulfilling a payment

// 1. Listen for audio signal
let received = try await sdk.listen()

// 2. Handle with default UI
sdk.onIntentReceived(received.intentId, wallet: wallet)

// Or headless mode for custom UI
sdk.onIntentReceived(received.intentId, wallet: wallet,
  headless: true,
  onDetails: { intent, summary in
    // Render payment details
  },
  onComplete: { intent in
    // Payment confirmed
  },
  onError: { error in
    // Handle error
  }
)