Integrate WalletConnect Pay into your Flutter wallet to enable seamless crypto payments for your users.
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.
WalletConnect Pay currently supports the following tokens and networks:
Token
Network
Chain ID
CAIP-10 Format
USDC
Ethereum
1
eip155:1:{address}
USDC
Base
8453
eip155:8453:{address}
USDC
Optimism
10
eip155:10:{address}
USDC
Polygon
137
eip155:137:{address}
USDC
Arbitrum
42161
eip155:42161:{address}
EURC
Ethereum
1
eip155:1:{address}
EURC
Base
8453
eip155:8453:{address}
Support for all EVM chains, Solana, and additional native and non-native assets is coming soon. Include accounts for all supported networks to maximize payment options for your users.
The payment flow consists of four main steps:Get Options -> Get Actions -> Sign Actions -> Confirm Payment
1
Get Payment Options
Retrieve available payment options for a payment link:
final request = GetPaymentOptionsRequest( paymentLink: 'https://pay.walletconnect.com/pay_123', accounts: ['eip155:1:0x...', 'eip155:137:0x...'], // User's wallet CAIP-10 accounts includePaymentInfo: true, // Include payment details in response);final response = await payClient.getPaymentOptions(request: request);// Access payment informationprint('Payment ID: ${response.paymentId}');print('Options available: ${response.options.length}');if (response.info != null) { print('Amount: ${response.info!.amount.formatAmount()}'); print('Status: ${response.info!.status}'); print('Merchant: ${response.info!.merchant.name}');}// Check if data collection is requiredif (response.collectData != null) { print('Data collection required: ${response.collectData!.fields.length} fields');}
2
Get Required Payment Actions
Get the required wallet actions (e.g., transactions to sign) for a selected payment option:
final actionsRequest = GetRequiredPaymentActionsRequest( optionId: response.options.first.id, // Or whatever other option chosen by the user paymentId: response.paymentId,);final actions = await payClient.getRequiredPaymentActions( request: actionsRequest,);// Process each action (e.g., sign transactions)for (final action in actions) { final walletRpc = action.walletRpc; print('Chain ID: ${walletRpc.chainId}'); print('Method: ${walletRpc.method}'); print('Params: ${walletRpc.params}'); // Dispatch based on walletRpc.method — see Sign Actions below}
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.
3
Collect User Data (If Required)
Some payments may require additional user data. Check for collectData in the payment options response:
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:
Call getPaymentOptions and display all available options to the user
Show a visual indicator (e.g., “Info required” badge) on options where option.collectData is present
When the user selects an option, check selectedOption.collectData
If present, open selectedOption.collectData.url in a WebView within your wallet
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.
Listen for JS bridge messages: IC_COMPLETE (success) or IC_ERROR (failure)
On IC_COMPLETE, proceed to confirmPayment()without passing collectedData — the WebView submits data directly to the backend
Option does NOT require IC (others might) — skip IC for this option
null
null
No IC needed for any option
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.
if (response.collectData?.url != null) { // Use the "required" list from response.collectData.schema to determine which fields to prefill final prefillData = { 'fullName': 'John Doe', 'dob': '1990-01-15', 'pobAddress': '123 Main St, New York, NY 10001', }; final prefillJson = jsonEncode(prefillData); final prefillBase64 = base64Url.encode(utf8.encode(prefillJson)); final uri = Uri.parse(response.collectData!.url); final webViewUrl = uri.replace( queryParameters: {...uri.queryParameters, 'prefill': prefillBase64}, ).toString(); // Show WebView — see WebView Implementation section below showDataCollectionWebView(webViewUrl);}
The SDK throws specific exception types for different error scenarios. All errors extend the abstract PayError class, which itself extends PlatformException:
Initialize once: Call init() only once, typically during app startup
Account Format: Always use CAIP-10 format for accounts: eip155:{chainId}:{address}
Multiple Chains: Provide accounts for all supported chains to maximize payment options
Signature Order: Maintain the same order of signatures as the actions array
Error Handling: Always handle errors gracefully and show appropriate user feedback
Loading States: Show loading indicators during API calls and signing operations
Expiration: Check paymentInfo.expiresAt and warn users if time is running low
User Data: Only collect data when collectData is present in the response 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.
WebView Data Collection: When collectData.url is present, display the URL in a WebView using webview_flutter rather than building native forms. The WebView handles form rendering, validation, and T&C acceptance.