Skip to main content
The WalletConnect Pay SDK allows wallet users to pay merchants using their crypto assets. The SDK handles payment option discovery, permit signing coordination, and payment confirmation while leveraging your wallet’s existing signing infrastructure.

Sample Wallet

For a complete working example, check out our sample wallet implementation:

Sample Wallet - Swift

A reference iOS wallet app demonstrating WalletConnect Pay integration.

Requirements

  • iOS 13.0+
  • Swift 5.7+
  • Xcode 14.0+

Installation

Swift Package Manager

Add WalletConnectPay to your Package.swift:
Then add WalletConnectPay to your target dependencies:
The version shown above may not be the latest. Check the GitHub releases for the most recent version.

Configuration

Configure the Pay client during app initialization, typically in your AppDelegate or SceneDelegate:

Configuration Parameters

At least one of apiKey or appId must be provided.
Don’t have a project ID? Create one at the WalletConnect Dashboard by signing up and creating a new project.

Supported Networks & Tokens

WalletConnect Pay currently supports the following tokens and networks:
Include accounts for all supported networks to maximize payment options for your users.
The isPaymentLink utility method detects WalletConnect Pay links by checking for:
  • pay. hosts (e.g., pay.walletconnect.com)
  • pay= parameter in WalletConnect URIs
  • pay_ prefix in bare payment IDs

Payment Flow

The payment flow consists of four main steps: Get Options -> Get Actions -> Sign Actions -> Confirm Payment
1

Get Payment Options

When a user scans a payment QR code or opens a payment link, fetch available payment options:
2

Get Required Actions

After the user selects a payment option, get the signing actions:
3

Sign Actions

Each action contains a walletRpc describing the RPC call to execute. Your wallet must check the method field and dispatch accordingly — for example, a payment option may require an eth_sendTransaction to approve a token allowance followed by an eth_signTypedData_v4 to sign Permit2 typed data.
Payment options may include multiple actions with different RPC methods. For example, a Permit2 payment where the user lacks sufficient allowance returns two actions: an eth_sendTransaction to approve the token allowance, followed by an eth_signTypedData_v4 to sign the Permit2 transfer. Your wallet must check action.walletRpc.method and dispatch to the appropriate handler. For full implementation guidance, see USDT support.
Signatures must be in the same order as the actions array.
4

Collect User Data (If Required)

If the selected option has collectData set, you must collect user information before confirming:

WebView-Based Data Collection

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 recommended approach is to display all payment options upfront, then handle data collection only when the user selects an option that requires it:
  1. Call getPaymentOptions and display all available options to the user
  2. Show a visual indicator (e.g., “Info required” badge) on options where option.collectData is present
  3. When the user selects an option, check selectedOption.collectData
  4. If present, open selectedOption.collectData.url in a WebView within your wallet
  5. Optionally append a prefill=<base64-json> query parameter with known user data (e.g., name, date of birth, address). Use proper URL building to handle existing query parameters.
  6. Listen for JS bridge messages: IC_COMPLETE (success) or IC_ERROR (failure)
  7. On IC_COMPLETE, proceed to confirmPayment() without passing collectedData — the WebView submits data directly to the backend

Decision Matrix

The collectData also includes a schema field — a JSON schema string describing the required fields. The required list in this schema tells you which fields the form expects. Wallets can use these field names as keys when building the prefill JSON object. For example, if the schema’s required array contains ["fullName", "dob", "pobAddress"], you can prefill with {"fullName": "...", "dob": "...", "pobAddress": "..."}.
The top-level collectData on the payment options response is still available for backward compatibility. However, the per-option collectData is the recommended approach as it provides more granular control over the flow.
When using the WebView approach, do not pass collectedData to confirmPayment(). The WebView handles data submission directly.

WebView Message Types

The WebView communicates with your wallet through JavaScript bridge messages. The message payload is a JSON string with the following structure:

Platform-Specific Bridge Names

5

Confirm Payment

Submit the signatures and collected data to complete the payment:

WebView Implementation

When a selected option has collectData.url present, display the URL in a WKWebView. The WebView handles form rendering, validation, and T&C acceptance.

Complete Example

Here’s a complete implementation example:
To handle payment links opened from outside your app:

QR Code Scanning

Payment links can be encoded as QR codes. Use the isPaymentLink utility for detection:

Error Handling

The SDK throws specific error types for different failure scenarios:

GetPaymentOptionsError

GetPaymentRequestError

ConfirmPaymentError

API Reference

WalletConnectPay

Static configuration class for the Pay SDK.

PayClient

Main client for payment operations.

Data Types

PaymentOptionsResponse

PaymentInfo

PaymentOption

PayAmount

Action & WalletRpcAction

CollectDataAction & CollectDataField

ConfirmPaymentResultResponse

Best Practices

  1. Account Format: Always use CAIP-10 format for accounts: eip155:{chainId}:{address}
  2. Multiple Chains: Provide accounts for all supported chains to maximize payment options
  3. Signature Order: Maintain the same order of signatures as the actions array
  4. Error Handling: Always handle errors gracefully and show appropriate user feedback
  5. Loading States: Show loading indicators during API calls and signing operations
  6. Expiration: Check paymentInfo.expiresAt and warn users if time is running low
  7. User Data: Only collect data when collectData is present on the selected payment option and you don’t already have the required user data. If you already have the required data, you can submit this without collecting from the user. You must make sure the user accepts WalletConnect Terms and Conditions and Privacy Policy before submitting user information to WalletConnect.
  8. WebView Data Collection: When selectedOption.collectData?.url is present, display the URL in a WKWebView rather than building native forms. The WebView handles form rendering, validation, and T&C acceptance.
  9. Per-Option Data Collection: When displaying payment options, check each option’s collectData field. Show a visual indicator (e.g., “Info required” badge) on options that require data collection. Only open the WebView when the user selects an option with collectData present — use the option’s collectData.url which is already scoped to that option’s account.