WalletConnect Pay via WalletKit - Swift - WalletConnect Pay Docs
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
This documentation covers integrating WalletConnect Pay through WalletKit. This approach provides a unified API where Pay is automatically configured when you configure WalletKit, simplifying the integration for wallet developers.
Sample Wallet
For a complete working example, check out our sample wallet implementation:
[**Sample Wallet - Swift (WalletKit)**
A reference iOS wallet app demonstrating WalletConnect Pay via WalletKit.](https://github.com/reown-com/reown-swift/tree/develop/Example/WalletApp)
Using AI for Integration? If you’re using an AI IDE or assistant to help with integration, you can provide it with our comprehensive AI integration prompt for better context and guidance.
Requirements
- iOS 13.0+
- Swift 5.7+
- Xcode 14.0+
- WalletKit (ReownWalletKit)
You also need a WCP ID for your project, obtained from the WalletConnect Dashboard.How to obtain a WCP ID
Navigate to the WalletConnect Dashboard.
Select the project that is associated with your wallet (as in, the projectId that is being used for your wallet’s WalletConnect integration).
Click on the “Get Started” button to get a WCP ID associated with your project.
The Dashboard will now show the WCP ID associated with your project.
Click on the three dots on the right of the WCP ID and select “Copy WCP ID”. You will be using this for your wallet’s WalletConnect Pay integration.
Installation
Swift Package ManagerAdd ReownWalletKit to your Package.swift:
dependencies: [\
.package(url: "https://github.com/reown-com/reown-swift", from: "1.0.0")\
]
Then add ReownWalletKit to your target dependencies:
.target(
name: "YourApp",
dependencies: ["ReownWalletKit"]
)
WalletConnectPay is automatically included as a dependency of WalletKit.
Check the GitHub releases for the latest version.
Initialization
When using WalletKit, Pay is automatically configured using your project’s Networking.projectId. No separate configuration is needed.
import ReownWalletKit
func application(_ application: UIApplication, didFinishLaunchingWithOptions...) {
// Configure WalletKit - Pay is automatically configured
WalletKit.configure(
metadata: AppMetadata(
name: "My Wallet",
description: "A crypto wallet",
url: "https://mywallet.com",
icons: ["https://mywallet.com/icon.png"]
),
crypto: DefaultCryptoProvider(),
payLogging: true // Enable Pay debug logging
)
}
Payment Link Detection
Use the static isPaymentLink method to detect payment links before processing:
// Static method - can be called before configure()
if WalletKit.isPaymentLink(scannedString) {
startPaymentFlow(paymentLink: scannedString)
}
// Or via the instance
if WalletKit.instance.Pay.isPaymentLink(scannedString) {
startPaymentFlow(paymentLink: scannedString)
}
The isPaymentLink utility method detects WalletConnect Pay links by checking for:
pay.hosts (e.g., pay.walletconnect.com)pay=parameter in WalletConnect URIspay_prefix in bare payment IDs
Call it wherever your wallet receives a link — from a deep link or a scanned QR code:
// Deep link opened from outside your app (SceneDelegate or AppDelegate)
func scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>) {
guard let url = URLContexts.first?.url else { return }
if WalletKit.isPaymentLink(url.absoluteString) {
startPaymentFlow(paymentLink: url.absoluteString)
}
}
// QR code payload
func handleScannedQR(_ content: String) {
if WalletKit.isPaymentLink(content) {
startPaymentFlow(paymentLink: content)
}
}
}
Payment Flow
The payment flow consists of six main steps:Detect Payment Link -> Get Options -> Collect Data (if required) -> Get Actions -> Sign Actions -> Confirm Payment
Get Payment Options
When a user scans a payment QR code or opens a payment link, fetch available payment options:
// 1. Get payment options
let options = try await WalletKit.instance.Pay.getPaymentOptions(
paymentLink: paymentLink,
accounts: ["eip155:1:\(address)", "eip155:137:\(address)"]
)
// Display merchant info
if let info = options.info {
print("Merchant: \(info.merchant.name)")
print("Amount: \(info.amount.display.assetSymbol) \(info.amount.value)")
}
// Show available payment options to user
for option in options.options {
print("Pay with \(option.amount.display.assetSymbol) on \(option.amount.display.networkName ?? "Unknown")")
}
// Check which options require data collection
for option in options.options {
if option.collectData != nil {
print("Option \(option.id) requires info capture")
}
}
Collect User Data (If Required)
After the user selects an option, check for collectData on it. If present, collect the data before fetching the required actions.
Embedded Data Collection Form
When a payment requires user information (e.g., for Travel Rule compliance), the SDK returns a collectData field on individual payment options. Each option may independently require data collection — some options may require it while others don’t.The form is loaded from selectedOption.collectData.url and embedded in your wallet (a WebView on mobile, an iframe on web). It handles field rendering, validation, Terms & Conditions and Privacy Policy acceptance, and submits data directly to the backend.Collect this data before fetching the required actions. For an option that requires Information Capture, getRequiredPaymentActions fails with 400 IC data required until the data has been submitted.
Recommended Flow
The recommended approach is to display all payment options upfront, then handle data collection only when the user selects an option that requires it:
- Call
getPaymentOptionsand display all available options to the user - Show a visual indicator (e.g., “Info required” badge) on options where
option.collectDatais present - When the user selects an option, check
selectedOption.collectData - If present, load
selectedOption.collectData.urlin the embedded form - Optionally append query parameters to the form URL —
prefill(known user data),theme, andthemeVariables(appearance). - Listen for completion messages:
IC_COMPLETE(success) orIC_ERROR(failure) - On
IC_COMPLETE, continue the flow — fetch the required actions, sign, and confirm the payment.
Decision Matrix
Response collectData |
option.collectData |
Behavior |
|---|---|---|
| present | present | Option requires IC — use option.collectData.url |
| present | null |
Option does NOT require IC (others might) — skip IC for this option |
null |
null |
No IC needed for any option |
Form URL parameters
The form URL accepts the following optional query parameters. Append them to selectedOption.collectData.url before loading it, preserving any existing query parameters.
| Parameter | Format | Description |
|---|---|---|
prefill |
base64url-encoded JSON | Pre-populates known user fields so the user doesn’t re-enter them. Keys must match the required fields from collectData.schema (e.g. fullName, dob, pobAddress). |
theme |
light or dark |
Sets the form’s base color mode. |
themeVariables |
base64url-encoded JSON | Overrides design tokens to match your brand — font, font size, select colors, button border radius, and input border radius. Generate and export this value from the WalletConnect Pay Dashboard. |
collectData.schema is a JSON schema string — parse it and read its required array to discover the field keys for prefill. For example, a required array of `[