> ## Documentation Index
> Fetch the complete documentation index at: https://walletconnect-pay-docs-rtomas-improve-docs-sidebar.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# WalletConnect Pay SDK - Flutter

> 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.

## Sample Wallet

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

<Card title="Sample Wallet - Flutter" icon="github" href="https://github.com/reown-com/reown_flutter/tree/develop/packages/reown_walletkit/example">
  A reference Flutter wallet app demonstrating WalletConnect Pay integration.
</Card>

## Requirements

* Flutter 3.0+
* iOS 13.0+
* Android API 23+

## Installation

Add `walletconnect_pay` package to your `pubspec.yaml` or simply run:

```bash theme={null}
flutter pub add walletconnect_pay
```

## Initialization

Initialize the `WalletConnectPay` client with your WCP ID and client ID or API key:

```dart theme={null}
import 'package:walletconnect_pay/walletconnect_pay.dart';

// Initialize WalletConnect Pay. Either apiKey or appId must be passed
final payClient = WalletConnectPay(
  apiKey: 'YOUR_API_KEY', // Optional
  appId: 'YOUR_WCP_ID', // Optional
  clientId: 'OPTIONAL_CLIENT_ID', // Optional
  baseUrl: 'https://api.pay.walletconnect.com', // Optional
);

// Initialize the SDK
try {
  await payClient.init();
} on PayInitializeError catch (e) {
  // Handle initialization error
}
```

**Configuration Parameters**

| Parameter  | Type      | Required | Description                                   |
| ---------- | --------- | -------- | --------------------------------------------- |
| `apiKey`   | `String?` | No\*     | WalletConnect Pay API key                     |
| `appId`    | `String?` | No\*     | WCP ID                                        |
| `clientId` | `String?` | No       | Client identifier                             |
| `baseUrl`  | `String?` | No       | Base URL for the API (defaults to production) |

<Note>
  Either `apiKey` or `appId` must be provided for authentication.
</Note>

<Info>
  Don't have a project ID? Create one at the [WalletConnect Dashboard](https://dashboard.walletconnect.com) by signing up and creating a new project.
</Info>

## Supported Networks & Tokens

WalletConnect Pay currently supports the following tokens and networks:

| Token | Network  | Chain ID | CAIP-10 Format           |
| ----- | -------- | -------- | ------------------------ |
| USDC  | Arbitrum | 42161    | `eip155:42161:{address}` |
| USDC  | Base     | 8453     | `eip155:8453:{address}`  |
| USDC  | Polygon  | 137      | `eip155:137:{address}`   |
| USDC  | Ethereum | 1        | `eip155:1:{address}`     |
| USDC  | Optimism | 10       | `eip155:10:{address}`    |
| USDC  | Monad    | 143      | `eip155:143:{address}`   |
| USDC  | Celo     | 42220    | `eip155:42220:{address}` |
| USDC  | BSC      | 56       | `eip155:56:{address}`    |
| EURC  | Ethereum | 1        | `eip155:1:{address}`     |
| EURC  | Base     | 8453     | `eip155:8453:{address}`  |
| USDT0 | Arbitrum | 42161    | `eip155:42161:{address}` |
| PYUSD | Ethereum | 1        | `eip155:1:{address}`     |
| PYUSD | Arbitrum | 42161    | `eip155:42161:{address}` |
| USDG  | Ethereum | 1        | `eip155:1:{address}`     |
| USDT  | Ethereum | 1        | `eip155:1:{address}`     |
| USDT  | Polygon  | 137      | `eip155:137:{address}`   |
| USDT  | BSC      | 56       | `eip155:56:{address}`    |

<Note>
  Include accounts for all supported networks to maximize payment options for your users.
</Note>

## Payment Flow

The payment flow consists of five main steps:

**Get Options -> Collect Data (if required) -> Get Actions -> Sign Actions -> Confirm Payment**

```mermaid theme={null}
sequenceDiagram
    participant User
    participant Wallet
    participant PaySDK as Pay SDK
    participant Backend as WalletConnect Pay
    participant WebView

    User->>Wallet: Scan QR / Open payment link
    Wallet->>PaySDK: getPaymentOptions(link, accounts)
    PaySDK->>Backend: Fetch payment options
    Backend-->>PaySDK: Payment options + merchant info
    PaySDK-->>Wallet: PaymentOptionsResponse
    Wallet->>User: Display payment options

    User->>Wallet: Select payment option

    alt Data collection required
        Wallet->>WebView: Load collectDataAction.url in WebView
        WebView->>User: Display data collection form
        User->>WebView: Fill form & accept T&C
        WebView-->>Wallet: IC_COMPLETE message
    end

    Wallet->>PaySDK: getRequiredPaymentActions(paymentId, optionId)
    PaySDK->>Backend: Get signing actions
    Backend-->>PaySDK: Required wallet RPC actions
    PaySDK-->>Wallet: List of actions to sign

    Wallet->>User: Request signature(s)
    User->>Wallet: Approve & sign

    Wallet->>PaySDK: confirmPayment(signatures)
    PaySDK->>Backend: Submit payment
    Backend-->>PaySDK: Payment status
    PaySDK-->>Wallet: ConfirmPaymentResponse
    Wallet->>User: Show result
```

<Steps>
  <Step title="Get Payment Options" titleSize="h3">
    Retrieve available payment options for a payment link:

    ```dart theme={null}
    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 information
    print('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 which options require data collection (per-option)
    for (final option in response.options) {
      if (option.collectData != null) {
        print('Option ${option.id} requires info capture');
      }
    }
    ```
  </Step>

  <Step title="Collect User Data (If Required)" titleSize="h3">
    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:

    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, load `selectedOption.collectData.url` in the embedded form
    5. Optionally append query parameters to the form URL — `prefill` (known user data), `theme`, and `themeVariables` (appearance). See [Form URL parameters](#form-url-parameters) below. Use proper URL building so existing query parameters are preserved.
    6. Listen for completion messages: `IC_COMPLETE` (success) or `IC_ERROR` (failure)
    7. On `IC_COMPLETE`, continue the flow — fetch the required actions, sign, and confirm the payment. Don't pass `collectedData` to `confirmPayment()`; the form submits data directly to the backend

    ### 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](https://dashboard.walletconnect.com). |

    <Info>
      `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 `["fullName", "dob", "pobAddress"]` maps to a prefill object of `{"fullName": "...", "dob": "...", "pobAddress": "..."}`.
    </Info>

    #### Customizing the form appearance

    `theme` and `themeVariables` are optional and independent — pass either, both, or neither:

    * **`theme`** switches the form between `light` and `dark` base color modes. Match it to your wallet's active mode for a seamless transition.
    * **`themeVariables`** applies brand-level overrides (font, font size, select colors, button border radius, and input border radius). Generate the theme in the [WalletConnect Pay Dashboard](https://dashboard.walletconnect.com), export it as a base64url string, and append it to the form URL verbatim — you don't need to encode it at runtime.

    <Note>
      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.
    </Note>

    <Warning>
      Do **not** pass `collectedData` to `confirmPayment()` when using the embedded form. The form handles data submission directly.
    </Warning>

    ```dart theme={null}
    if (selectedOption.collectData?.url != null) {
      // Use the "required" list from selectedOption.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',
      };
      // Encode prefill as base64url
      final prefillBase64 = base64Url.encode(utf8.encode(jsonEncode(prefillData))).replaceAll('=', '');
      final uri = Uri.parse(selectedOption.collectData!.url);
      final webViewUrl = uri.replace(
        queryParameters: {
          ...uri.queryParameters,
          'prefill': prefillBase64,
          // Optional appearance params (see "Form URL parameters"):
          'theme': 'dark', // "light" | "dark"
          // themeVariables is a base64url string exported from the Pay Dashboard:
          // 'themeVariables': themeVariables,
        },
      ).toString();

      // Show WebView — see Data Collection Implementation section below
      showDataCollectionWebView(webViewUrl);
    }
    ```

    ### WebView Message Types

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

    | Message Type  | Payload                                      | Description                                                               |
    | ------------- | -------------------------------------------- | ------------------------------------------------------------------------- |
    | `IC_COMPLETE` | `{ "type": "IC_COMPLETE", "success": true }` | User completed the form successfully. Proceed to payment confirmation.    |
    | `IC_ERROR`    | `{ "type": "IC_ERROR", "error": "..." }`     | An error occurred. Display the error message and allow the user to retry. |

    **Platform-Specific Bridge Names**

    | Platform         | Bridge Name                                   | Handler                                                       |
    | ---------------- | --------------------------------------------- | ------------------------------------------------------------- |
    | Kotlin (Android) | `AndroidWallet`                               | `@JavascriptInterface onDataCollectionComplete(json: String)` |
    | Swift (iOS)      | `payDataCollectionComplete`                   | `WKScriptMessageHandler.didReceive(message:)`                 |
    | Flutter          | `ReactNativeWebView` (injected via JS bridge) | `JavaScriptChannel.onMessageReceived`                         |
    | React Native     | `ReactNativeWebView` (native)                 | `WebView.onMessage` prop                                      |
  </Step>

  <Step title="Get Required Actions" titleSize="h3">
    Get the required wallet actions (e.g., transactions to sign) for a selected payment option:

    ```dart theme={null}
    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
    }
    ```
  </Step>

  <Step title="Sign Actions" titleSize="h3">
    Sign each action using your wallet's signing implementation, dispatching on the RPC method:

    ```dart theme={null}
    // Sign each action based on its RPC method
    final signatures = <String>[];
    for (final action in actions) {
      final rpc = action.walletRpc;
      switch (rpc.method) {
        case 'eth_signTypedData_v4':
          signatures.add(await signTypedData(rpc.chainId, rpc.params));
          break;
        case 'eth_sendTransaction':
          signatures.add(await sendTransaction(rpc.chainId, rpc.params));
          break;
        case 'personal_sign':
          signatures.add(await personalSign(rpc.chainId, rpc.params));
          break;
        default:
          throw UnimplementedError('Unsupported RPC method: ${rpc.method}');
      }
    }
    ```

    <Note>
      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](/payments/wallets/token-chain-support/usdt-support).
    </Note>

    <Warning>
      Signatures must be in the same order as the actions array.
    </Warning>
  </Step>

  <Step title="Confirm Payment" titleSize="h3">
    Confirm a payment with the collected signatures:

    ```dart theme={null}
    final confirmRequest = ConfirmPaymentRequest(
      paymentId: response.paymentId,
      optionId: response.options.first.id,
      signatures: ['0x...', '0x...'], // Signatures from wallet actions
      maxPollMs: 60000, // Optional: max polling time in milliseconds
    );

    final confirmResponse = await payClient.confirmPayment(request: confirmRequest);

    print('Payment Status: ${confirmResponse.status}');
    print('Is Final status: ${confirmResponse.isFinal}');

    if (!confirmResponse.isFinal && confirmResponse.pollInMs != null) {
      // Poll again after the specified interval
      await Future.delayed(Duration(milliseconds: confirmResponse.pollInMs!));
      // Re-confirm or check status
    }
    ```

    <Note>
      When using the WebView data-collection approach, you do **not** pass `collectedData` to `confirmPayment`. The WebView submits the collected data directly to the backend during the earlier Collect User Data step.
    </Note>
  </Step>
</Steps>

## Data Collection Implementation

When `selectedOption.collectData.url` is present, display the URL in a WebView using the `webview_flutter` package (v4.10.0+). Add it to your `pubspec.yaml`:

```yaml theme={null}
dependencies:
  webview_flutter: ^4.10.0
  url_launcher: ^6.1.0
```

**Data Collection Best Practices**

* **Display prominently**: Show the form full-screen or as a prominent modal so users can interact with it easily
* **Loading indicator**: Show a loading indicator while the form loads
* **Handle errors**: Listen for `IC_ERROR` messages and display a user-facing error message with an option to retry
* **External links**: Open Terms & Conditions and Privacy Policy links in the system browser rather than navigating within the form
* **Domain restriction**: Only allow navigation to WalletConnect pay domains and HTTPS URLs
* **Back navigation**: Handle back/dismiss gracefully — confirm cancellation with the user before closing the form mid-flow
* **Keyboard behavior**: Test that the soft keyboard appears and behaves correctly when users tap on form inputs
* **Theme to match your brand**: Pass `theme=light` or `theme=dark` to match your wallet's active color mode, and apply brand tokens with `themeVariables` exported from the [WalletConnect Pay Dashboard](https://dashboard.walletconnect.com). See [Form URL parameters](#form-url-parameters).

```dart theme={null}
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:webview_flutter/webview_flutter.dart';
import 'package:url_launcher/url_launcher.dart';

class PayDataCollectionWebView extends StatefulWidget {
  final String url;
  final VoidCallback onComplete;
  final ValueChanged<String> onError;

  const PayDataCollectionWebView({
    super.key,
    required this.url,
    required this.onComplete,
    required this.onError,
  });

  @override
  State<PayDataCollectionWebView> createState() =>
      _PayDataCollectionWebViewState();
}

class _PayDataCollectionWebViewState extends State<PayDataCollectionWebView> {
  late final WebViewController _controller;
  bool _isLoading = true;

  @override
  void initState() {
    super.initState();
    _controller = WebViewController()
      ..setJavaScriptMode(JavaScriptMode.unrestricted)
      ..setNavigationDelegate(NavigationDelegate(
        onPageFinished: (_) => setState(() => _isLoading = false),
        onNavigationRequest: (request) {
          if (!request.url.contains('pay.walletconnect.com')) {
            launchUrl(Uri.parse(request.url),
                mode: LaunchMode.externalApplication);
            return NavigationDecision.prevent;
          }
          return NavigationDecision.navigate;
        },
      ))
      ..addJavaScriptChannel(
        'ReactNativeWebView',
        onMessageReceived: (message) {
          try {
            final data = jsonDecode(message.message) as Map<String, dynamic>;
            switch (data['type']) {
              case 'IC_COMPLETE':
                widget.onComplete();
                break;
              case 'IC_ERROR':
                widget.onError(data['error'] ?? 'Unknown error');
                break;
            }
          } catch (_) {
            // Ignore non-JSON messages
          }
        },
      )
      ..loadRequest(Uri.parse(widget.url));

    // Inject JS bridge for compatibility
    _controller.runJavaScript('''
      window.ReactNativeWebView = {
        postMessage: function(data) {
          ReactNativeWebView.postMessage(data);
        }
      };
    ''');
  }

  @override
  Widget build(BuildContext context) {
    return Stack(
      children: [
        WebViewWidget(controller: _controller),
        if (_isLoading)
          const Center(child: CircularProgressIndicator()),
      ],
    );
  }
}

String buildFormUrl(
  String baseUrl, {
  Map<String, String> prefillData = const {},
  String? theme,           // "light" or "dark"
  String? themeVariables,  // base64url string exported from the Pay Dashboard
}) {
  final uri = Uri.parse(baseUrl);
  final params = {...uri.queryParameters};
  if (prefillData.isNotEmpty) {
    params['prefill'] = base64Url.encode(utf8.encode(jsonEncode(prefillData))).replaceAll('=', '');
  }
  if (theme != null) params['theme'] = theme;
  if (themeVariables != null) params['themeVariables'] = themeVariables;
  return uri.replace(queryParameters: params).toString();
}
```

## Complete Example

Here's a complete implementation example:

```dart theme={null}
import 'package:walletconnect_pay/walletconnect_pay.dart';

class PaymentService {
  late final WalletConnectPay _payClient;

  Future<void> initialize() async {
    _payClient = WalletConnectPay(
      appId: 'YOUR_WCP_ID',
    );
    await _payClient.init();
  }

  Future<ConfirmPaymentResponse> processPayment(
    String paymentLink,
    List<String> accounts,
  ) async {
    // Step 1: Get payment options
    final optionsResponse = await _payClient.getPaymentOptions(
      request: GetPaymentOptionsRequest(
        paymentLink: paymentLink,
        accounts: accounts,
        includePaymentInfo: true,
      ),
    );

    if (optionsResponse.options.isEmpty) {
      throw Exception('No payment options available');
    }

    // Step 2: Select payment option (simplified - use first option)
    final selectedOption = optionsResponse.options.first;

    // Step 3: Collect data via WebView if required.
    // This must happen BEFORE fetching the required payment actions —
    // the backend rejects the actions request with 400 "IC data required"
    // for options needing Information Capture if data wasn't collected first.
    // The WebView submits the data directly to the backend, so it is NOT
    // passed to confirmPayment later.
    if (selectedOption.collectData?.url != null) {
      // Show WebView and wait for IC_COMPLETE
      await showDataCollectionWebView(selectedOption.collectData!.url);
    }

    // Step 4: Get required payment actions
    final actions = await _payClient.getRequiredPaymentActions(
      request: GetRequiredPaymentActionsRequest(
        optionId: selectedOption.id,
        paymentId: optionsResponse.paymentId,
      ),
    );

    // Step 5: Sign all actions
    final signatures = <String>[];
    for (final action in actions) {
      final signature = await signAction(action.walletRpc);
      signatures.add(signature);
    }

    // Step 6: Confirm payment
    final confirmResponse = await _payClient.confirmPayment(
      request: ConfirmPaymentRequest(
        paymentId: optionsResponse.paymentId,
        optionId: selectedOption.id,
        signatures: signatures,
        maxPollMs: 60000,
      ),
    );

    // Step 7: Poll until final status (if needed)
    var response = confirmResponse;
    while (!response.isFinal && response.pollInMs != null) {
      await Future.delayed(Duration(milliseconds: response.pollInMs!));
      response = await _payClient.confirmPayment(
        request: ConfirmPaymentRequest(
          paymentId: optionsResponse.paymentId,
          optionId: selectedOption.id,
          signatures: signatures,
          maxPollMs: 60000,
        ),
      );
    }

    return response;
  }

  Future<String> signAction(WalletRpcAction walletRpc) async {
    switch (walletRpc.method) {
      case 'eth_signTypedData_v4':
        return await signTypedData(walletRpc.chainId, walletRpc.params);
      case 'eth_sendTransaction':
        return await sendTransaction(walletRpc.chainId, walletRpc.params);
      case 'personal_sign':
        return await personalSign(walletRpc.chainId, walletRpc.params);
      default:
        throw UnimplementedError('Unsupported RPC method: ${walletRpc.method}');
    }
  }
}
```

## API Reference

**WalletConnectPay**

The main class for interacting with the WalletConnect Pay SDK.

**Constructor**

```dart theme={null}
WalletConnectPay({
  String? apiKey,
  String? appId,
  String? clientId,
  String? baseUrl,
})
```

**Methods**

| Method                                                                                                | Description                                                                                                                 |
| ----------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------- |
| `Future<bool> init()`                                                                                 | Initializes the SDK. Returns `true` on success or throw `PayInitializeError` on error                                       |
| `Future<PaymentOptionsResponse> getPaymentOptions({required GetPaymentOptionsRequest request})`       | Retrieves available payment options                                                                                         |
| `Future<List<Action>> getRequiredPaymentActions({required GetRequiredPaymentActionsRequest request})` | Gets the required wallet actions for a selected option (to be called if the selected option does not have actions included) |
| `Future<ConfirmPaymentResponse> confirmPayment({required ConfirmPaymentRequest request})`             | Confirms a payment                                                                                                          |

## Data Models

**GetPaymentOptionsRequest**

```dart theme={null}
GetPaymentOptionsRequest({
  required String paymentLink,
  required List<String> accounts,
  @Default(false) bool includePaymentInfo,
})
```

**PaymentOptionsResponse**

```dart theme={null}
PaymentOptionsResponse({
  required String paymentId,
  PaymentInfo? info,
  required List<PaymentOption> options,
  CollectDataAction? collectData,
  PaymentResultInfo? resultInfo,     // Transaction result details (present when payment already completed)
})
```

**PaymentResultInfo**

```dart theme={null}
class PaymentResultInfo {
  final String txId;               // Transaction ID
  final PayAmount optionAmount;    // Token amount details
}
```

**PaymentInfo**

```dart theme={null}
PaymentInfo({
  required PaymentStatus status,
  required PayAmount amount,
  required int expiresAt,
  required MerchantInfo merchant,
  BuyerInfo? buyer,
})
```

**PaymentOption**

```dart theme={null}
PaymentOption({
  required String id,
  required String account,
  required PayAmount amount,
  @JsonKey(name: 'etaS') required int etaSeconds,
  required List<Action> actions,
  CollectDataAction? collectData,  // Per-option data collection (null if not required)
})
```

**ConfirmPaymentRequest**

```dart theme={null}
ConfirmPaymentRequest({
  required String paymentId,
  required String optionId,
  required List<String> signatures,
  List<CollectDataFieldResult>? collectedData,
  int? maxPollMs,
})
```

**ConfirmPaymentResponse**

```dart theme={null}
ConfirmPaymentResponse({
  required PaymentStatus status,
  required bool isFinal,
  int? pollInMs,
})
```

**PaymentStatus**

```dart theme={null}
enum PaymentStatus {
  requires_action,
  processing,
  succeeded,
  failed,
  expired,
}
```

**Action & WalletRpcAction**

```dart theme={null}
class Action {
  final WalletRpcAction walletRpc;
}

class WalletRpcAction {
  final String chainId;   // CAIP-2 chain ID (e.g., "eip155:8453")
  final String method;    // RPC method (e.g., "eth_signTypedData_v4", "eth_sendTransaction")
  final String params;    // JSON-encoded parameters
}
```

**CollectDataAction**

```dart theme={null}
class CollectDataAction {
  final String url;                // WebView URL for data collection
  final String? schema;            // JSON schema describing required fields
}
```

## Error Handling

The SDK throws specific exception types for different error scenarios. All errors extend the abstract `PayError` class, which itself extends `PlatformException`:

```dart theme={null}
abstract class PayError extends PlatformException {
  PayError({
    required super.code,
    required super.message,
    required super.details,
    required super.stacktrace,
  });
}
```

| Exception                 | Description                          |
| ------------------------- | ------------------------------------ |
| `PayInitializeError`      | Initialization failures              |
| `GetPaymentOptionsError`  | Errors when fetching payment options |
| `GetRequiredActionsError` | Errors when getting required actions |
| `ConfirmPaymentError`     | Errors when confirming payment       |

All errors include:

* `code`: Error code
* `message`: Error message
* `details`: Additional error details
* `stacktrace`: Stack trace

**Example Error Handling**

```dart theme={null}
try {
  await payClient.init();
} on PayInitializeError catch (e) {
  print('Initialization failed: ${e.code} - ${e.message}');
}

try {
  final response = await payClient.getPaymentOptions(request: request);
} on GetPaymentOptionsError catch (e) {
  print('Error code: ${e.code}');
  print('Error message: ${e.message}');
} on PayError catch (e) {
  // Catch any Pay-related error
  print('Pay error: ${e.message}');
} catch (e) {
  print('Unexpected error: $e');
}
```

## Best Practices

1. **Initialize once**: Call `init()` only once, typically during app startup

2. **Account Format**: Always use CAIP-10 format for accounts: `eip155:{chainId}:{address}`

3. **Multiple Chains**: Provide accounts for all supported chains to maximize payment options

4. **Signature Order**: Maintain the same order of signatures as the actions array

5. **Error Handling**: Always handle errors gracefully and show appropriate user feedback

6. **Loading States**: Show loading indicators during API calls and signing operations

7. **Expiration**: Check `paymentInfo.expiresAt` and warn users if time is running low

8. **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.

9. **WebView Data Collection**: When `selectedOption.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.
