Skip to main content

WalletConnect Pay Integration Guide for Flutter (via WalletKit)

This guide enables Flutter wallet developers to integrate WalletConnect Pay for processing crypto payment links through reown_walletkit. The integration allows wallet applications to accept and process payment requests from merchants using the WalletConnect Pay protocol.

Important Approach

Study and adapt, don’t blindly copy. Before implementing, examine how your existing wallet app handles:
  • Deep links and QR code scanning
  • Modal/bottom sheet presentation
  • State management patterns
  • Signing implementations for different methods
Maintain consistent architecture and naming conventions with your existing codebase.

Prerequisites

Before starting, ensure your wallet app has:
  1. WalletKit SDK integrated (reown_walletkit: ^1.4.0 package or newer)
  2. EVM signing capability supporting:
    • eth_signTypedData_v4 (EIP-712 typed data signing)
    • personal_sign (message signing)
  3. Async/await patterns for handling asynchronous operations
  4. UI modal/bottom sheet system for presenting payment flows
  5. Understanding of CAIP-10 account format: {namespace}:{chainId}:{address} (e.g., eip155:1:0x1234...)

Core Concepts

Payment Flow Overview

  1. Payment Link Detection: Identify incoming payment links from QR codes, deep links, or text input
  2. Get Payment Options: Retrieve available payment methods with merchant information
  3. WebView Data Collection (optional): Display WebView form for KYC/compliance data if required by the payment. The WebView submits data directly to the backend, so this must happen BEFORE fetching actions.
  4. Get Actions: Fetch the required signing actions via getRequiredPaymentActions (only needed when the selected option’s actions are empty)
  5. Sign Actions: Execute wallet signing operations (typically eth_signTypedData_v4)
  6. Confirm Payment: Submit signatures to complete the transaction
  7. Handle Result: Display success/failure and handle polling if needed

Key Data Models


Step-by-Step Integration

Step 1: Dependency Setup

The walletconnect_pay package is already a dependency of reown_walletkit and is re-exported. No additional dependencies are needed.
All Pay-related types are exported from reown_walletkit:

Step 2: WalletKit Initialization

Pay is automatically initialized when you call walletKit.init(). No separate Pay configuration is required.
Use walletKit.isPaymentLink() to detect payment links. This check must occur at ALL URI entry points in your app.
CRITICAL: Add payment link detection to:
  • QR code scanner results
  • Deep link handlers (cold start and warm start)
  • Paste/text input handlers
  • Universal link handlers
Important: Payment links are HTTPS URLs. Ensure the isPaymentLink() check happens BEFORE any generic HTTPS URL handling to prevent opening payment links in a browser.

Step 4: Get Payment Options

Retrieve available payment options using the wallet’s accounts in CAIP-10 format.
Response Structure:

Step 5: Handle Data Collection via WebView

If the selected option’s collectData is not null and has a url, display the URL in a WebView for data collection. The hosted form handles rendering, validation, and T&C acceptance. The form URL accepts optional query parameters — append them to selectedOption.collectData.url before loading, preserving existing query parameters:
  • prefill — base64url-encoded JSON of known user fields. Keys must match the required fields from collectData.schema (e.g. fullName, dob, pobAddress).
  • themelight or dark, to match your wallet’s color mode.
  • themeVariables — a base64url string exported from the WalletConnect Pay Dashboard that overrides design tokens (font, font size, some colors, button/input border radius). Append it verbatim.
Important: When using the WebView approach, do not pass collectedData to confirmPayment(). The WebView submits data directly to the backend.
Add webview_flutter and url_launcher to your dependencies:

Step 6: Get Required Payment Actions

If the selected payment option has empty actions, fetch them explicitly.
Action Structure:

Step 7: Sign Payment Actions

CRITICAL: The params field contains a JSON string. Handle it appropriately for your signing library.

EIP-712 Typed Data Signing (eth_signTypedData_v4)

Personal Sign

Step 8: Confirm Payment

Submit signatures to complete the payment.
CRITICAL: Signatures array must match actions array order exactly. Misalignment causes payment failures.

Step 9: Handle Payment Result


Complete Payment Flow Example


UI Implementation Guidelines

  1. Loading State: Show while fetching payment options
  2. Payment Details: Display merchant info, amount, and payment options
  3. Data Collection (conditional): Collect required fields
  4. Processing State: Show while confirming payment
  5. Result Screen: Success or failure with details

Example Modal Structure


Utility Functions

Format Payment Amount

Format Expiration Time

Date Formatting for Data Collection


Error Handling

Error Types

Common Error Codes

GetPaymentOptions:
  • PaymentExpired - Payment link has expired
  • PaymentNotFound - Invalid payment link
  • InvalidAccount - Provided account format is invalid
  • ComplianceFailed - Compliance check failed
ConfirmPayment:
  • InvalidSignature - Signature verification failed
  • PaymentExpired - Payment expired during process
  • RouteExpired - Selected payment route expired
  • UnsupportedMethod - Signing method not supported

Error Handling Pattern


Common Pitfalls

1. Account Format

Wrong: 0x1234... Correct: eip155:1:0x1234... (CAIP-10 format)

2. Signature Order

CRITICAL: Signatures must be in the same order as actions.

3. JSON Params Handling

The walletRpc.params is a JSON string. Parse appropriately:

4. Hex Value Normalization

Some hex values may have odd length. Normalize before signing:
Check for payment links BEFORE generic URL handling:

6. Empty Actions

Payment options may have empty actions array initially. Always check and fetch if needed:

Testing

Contact WalletConnect for test payment links or use the WalletConnect Pay sandbox environment.

Debug Logging

Enable logging during development:

Summary

Quick Reference - API Methods

Integration Checklist

  • WalletKit initialized with await walletKit.init()
  • Payment link detection added to all URI entry points
  • isPaymentLink() check occurs BEFORE generic URL handling
  • Accounts formatted in CAIP-10 format
  • eth_signTypedData_v4 signing implemented
  • Hex value normalization for typed data signing
  • Signature order matches action order
  • WebView data collection for compliance (using webview_flutter)
  • Error handling for all error types
  • Loading states during API calls
  • Success/failure result screens
  • Polling handled for non-final responses

Reference Implementation

See the complete working implementation in the WalletKit example app:
  • packages/reown_walletkit/example/lib/dependencies/walletkit_service.dart
  • packages/reown_walletkit/example/lib/walletconnect_pay/ (UI modals)
  • packages/reown_walletkit/example/lib/dependencies/chain_services/evm_service.dart (signing)

Resources