### Install Sample Application on Device Source: https://github.com/reown-com/reown-kotlin/blob/develop/ReadMe.md Install a specific sample application onto a connected Android device using the Gradle command. ```bash ./gradlew :sample:{sample_name}:installDebug ``` -------------------------------- ### Setup Maestro E2E tests Source: https://github.com/reown-com/reown-kotlin/blob/develop/AGENTS.md Prepare the environment for Maestro E2E tests by downloading flows, configuring environment variables, and building/installing the wallet app. ```bash # 1. Download test flows from WalletConnect/actions repo ./scripts/setup-maestro-pay-tests.sh ``` ```bash # 2. Create .env.maestro from the example and fill in merchant credentials cp .env.maestro.example .env.maestro ``` ```bash # 3. Build and install the wallet app with test mode enabled ENABLE_TEST_MODE=true ./gradlew :sample:wallet:assembleDebug adb install sample/wallet/build/outputs/apk/debug/*.apk ``` -------------------------------- ### Build and Install Wallet App with Test Mode Source: https://github.com/reown-com/reown-kotlin/blob/develop/sample/wallet/README.md Build the debug version of the wallet application with test mode enabled and then install it on an Android device or emulator. Test mode allows for manual URL input, which is useful for automated testing. ```bash ENABLE_TEST_MODE=true ./gradlew :sample:wallet:assembleDebug adb install sample/wallet/build/outputs/apk/debug/*.apk ``` -------------------------------- ### Configure Maestro Environment Variables Source: https://github.com/reown-com/reown-kotlin/blob/develop/sample/wallet/README.md Copy the example environment file for Maestro and populate it with your WalletConnect Pay merchant credentials. These are required for the E2E tests to function correctly. ```bash cp .env.maestro.example .env.maestro ``` -------------------------------- ### Gradle Setup for Reown Kotlin SDK Source: https://github.com/reown-com/reown-kotlin/blob/develop/ReadMe.md Integrate the Reown Kotlin SDK into your Android project by adding the Bill of Materials (BOM) and core dependencies to your build.gradle.kts file. ```kotlin dependencies { implementation(platform("com.reown:android-bom:{BOM version}")) // Core SDK implementation("com.reown:android-core") // For wallet applications implementation("com.reown:walletkit") // For dApp applications implementation("com.reown:appkit") } ``` -------------------------------- ### Use Case Pattern Implementation Source: https://github.com/reown-com/reown-kotlin/blob/develop/AGENTS.md An example of a Use Case implementation following the single-responsibility principle, executing a suspend function and handling results. ```kotlin internal class FeatureUseCase(...) : FeatureUseCaseInterface { override suspend fun execute(): Result = supervisorScope { runCatching { ... } } } ``` -------------------------------- ### Handle GetPaymentOptions Errors Source: https://github.com/reown-com/reown-kotlin/blob/develop/product/pay/README.md Example of how to handle various errors returned by the getPaymentOptions function using a when statement. ```kotlin val result = WalletConnectPay.getPaymentOptions(paymentLink, accounts) result.onFailure { error -> when (error) { is Pay.GetPaymentOptionsError.InvalidPaymentLink -> { showError("Invalid payment link") } is Pay.GetPaymentOptionsError.PaymentExpired -> { showError("Payment has expired") } is Pay.GetPaymentOptionsError.PaymentNotFound -> { showError("Payment not found") } is Pay.GetPaymentOptionsError.InvalidAccount -> { showError("Invalid account address") } is Pay.GetPaymentOptionsError.Http -> { showError("Network error: ${error.message}") } else -> { showError("An error occurred: ${error.message}") } } } ``` -------------------------------- ### Get Payment Options Source: https://github.com/reown-com/reown-kotlin/blob/develop/product/pay/README.md Retrieves available payment options for a given payment link and a list of accounts. Use this to see how a user can pay for a specific link. ```kotlin suspend fun getPaymentOptions( paymentLink: String, accounts: List ): Result ``` -------------------------------- ### Install WalletConnect Pay SDK Source: https://github.com/reown-com/reown-kotlin/blob/develop/product/pay/README.md Add the WalletConnect Pay SDK dependency to your Android project's build.gradle.kts file. Ensure your project meets the minimum SDK requirements. ```kotlin implementation("com.walletconnect:pay:1.0.0") ``` -------------------------------- ### Get Required Payment Actions Source: https://github.com/reown-com/reown-kotlin/blob/develop/product/pay/README.md Fetches the wallet RPC actions necessary to complete a payment, given a payment ID and a selected option ID. This is a prerequisite for confirming the payment. ```kotlin suspend fun getRequiredPaymentActions( paymentId: String, optionId: String ): Result> ``` -------------------------------- ### Get Payment Options Source: https://github.com/reown-com/reown-kotlin/blob/develop/AGENTS.md Retrieves available payment options and merchant information for a given payment link and user accounts. ```APIDOC ## getPaymentOptions ### Description Fetches the available payment options, merchant details, and any required data collection fields for a given payment link. ### Method `suspend fun getPaymentOptions(paymentLink: String, accounts: List): Result` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters - **paymentLink** (String) - Required - The payment link to process. - **accounts** (List) - Required - A list of user accounts in CAIP-10 format (e.g., "eip155:1:0x..."). ### Response #### Success Response - **Pay.PaymentOptionsResponse**: Contains merchant info, payment options, and optional data collection fields. #### Response Example (Response structure depends on `Pay.PaymentOptionsResponse` definition) ``` -------------------------------- ### Get Required Payment Actions Source: https://github.com/reown-com/reown-kotlin/blob/develop/AGENTS.md Retrieves the necessary cryptographic actions (e.g., signatures) required to proceed with a payment. ```APIDOC ## getRequiredPaymentActions ### Description Retrieves a list of required cryptographic actions, such as transaction signatures, needed to confirm a payment. ### Method `suspend fun getRequiredPaymentActions(paymentId: String, optionId: String): Result>` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters - **paymentId** (String) - Required - The ID of the payment. - **optionId** (String) - Required - The ID of the selected payment option. ### Response #### Success Response - **List**: A list of actions that need to be signed, typically RPC actions like `eth_signTypedData_v4` or `personal_sign`. #### Response Example (Response structure depends on `Pay.RequiredAction` definition) ``` -------------------------------- ### Get Required Payment Actions Source: https://github.com/reown-com/reown-kotlin/blob/develop/product/pay/README.md Retrieve the necessary wallet RPC actions to complete a payment, given a payment ID and a selected option ID. Iterates through actions, specifically handling `WalletRpc` types. ```kotlin val actionsResult = WalletConnectPay.getRequiredPaymentActions( paymentId = paymentId, optionId = selectedOption.id ) actionsResult.onSuccess { actions -> actions.forEach { action -> when (action) { is Pay.RequiredAction.WalletRpc -> { val rpcAction = action.action // rpcAction.chainId - e.g., "eip155:8453" // rpcAction.method - e.g., "eth_signTypedData_v4" or "personal_sign" // rpcAction.params - JSON string with signing parameters } } } }.onFailure { error -> // Handle error } ``` -------------------------------- ### Build All Sample Applications Source: https://github.com/reown-com/reown-kotlin/blob/develop/ReadMe.md Build all sample applications included in the repository using the Gradle command. ```bash ./gradlew :sample:assembleDebug ``` -------------------------------- ### Build sample apps with Gradle Source: https://github.com/reown-com/reown-kotlin/blob/develop/AGENTS.md Build debug versions of various sample applications. Mock configuration files are auto-generated if missing. ```bash # Build sample apps ./gradlew :sample:wallet:assembleDebug ``` ```bash ./gradlew :sample:dapp:assembleDebug ``` ```bash ./gradlew :sample:modal:assembleDebug ``` ```bash ./gradlew :sample:pos:assembleDebug ``` -------------------------------- ### Build Wallet Sample Application Source: https://github.com/reown-com/reown-kotlin/blob/develop/ReadMe.md Build the debug version of the wallet sample application using the provided Gradle command. ```bash ./gradlew :sample:wallet:assembleDebug ``` -------------------------------- ### Build Specific Sample Application Source: https://github.com/reown-com/reown-kotlin/blob/develop/ReadMe.md Build a specific sample application by providing its name to the Gradle command. ```bash ./gradlew :sample:{sample_name}:assembleDebug ``` -------------------------------- ### Build POS Sample Application Source: https://github.com/reown-com/reown-kotlin/blob/develop/ReadMe.md Build the debug version of the POS sample application using the provided Gradle command. ```bash ./gradlew :sample:pos:assembleDebug ``` -------------------------------- ### Build dApp Sample Application Source: https://github.com/reown-com/reown-kotlin/blob/develop/ReadMe.md Build the debug version of the dApp sample application using the provided Gradle command. ```bash ./gradlew :sample:dapp:assembleDebug ``` -------------------------------- ### Run Unit Tests for Sample Application Source: https://github.com/reown-com/reown-kotlin/blob/develop/ReadMe.md Execute the unit tests for a specific sample application using the Gradle command. ```bash ./gradlew :sample:{sample_name}:testDebugUnitTest ``` -------------------------------- ### Build Sample Wallet App Source: https://github.com/reown-com/reown-kotlin/blob/develop/CLAUDE.md Builds the debug version of the wallet sample application. Mock configuration files are auto-generated if missing. ```bash # Build sample apps ./gradlew :sample:wallet:assembleDebug ``` -------------------------------- ### Build Modal Sample Application Source: https://github.com/reown-com/reown-kotlin/blob/develop/ReadMe.md Build the debug version of the modal sample application using the provided Gradle command. ```bash ./gradlew :sample:modal:assembleDebug ``` -------------------------------- ### Initialize WalletConnect Pay SDK Source: https://github.com/reown-com/reown-kotlin/blob/develop/product/pay/README.md Initialize the SDK with your API key, project ID, and application package name. This should be done early in your application's lifecycle. ```kotlin import com.walletconnect.pay.Pay import com.walletconnect.pay.WalletConnectPay WalletConnectPay.initialize( Pay.SdkConfig( apiKey = "your-api-key", projectId = "your-project-id", packageName = "com.your.app" ) ) ``` -------------------------------- ### Build all modules with Gradle Source: https://github.com/reown-com/reown-kotlin/blob/develop/AGENTS.md Use this command to compile and package all modules within the project. ```bash # Build all modules ./gradlew build ``` -------------------------------- ### initialize Source: https://github.com/reown-com/reown-kotlin/blob/develop/product/pay/README.md Initializes the WalletConnectPay SDK with the provided configuration. This method should be called before any other SDK operations. ```APIDOC ## initialize(config: Pay.SdkConfig) ### Description Initializes the WalletConnectPay SDK. ### Method `initialize` ### Parameters #### Path Parameters - `config` (Pay.SdkConfig) - Required - SDK configuration containing API key, project ID, and package name ### Throws - `IllegalStateException` if already initialized ``` -------------------------------- ### Initialize WalletConnectPay SDK Source: https://github.com/reown-com/reown-kotlin/blob/develop/product/pay/README.md Initializes the WalletConnectPay SDK with the provided configuration. Ensure this is called before other SDK methods. It throws an IllegalStateException if the SDK has already been initialized. ```kotlin fun initialize(config: Pay.SdkConfig) ``` -------------------------------- ### Configure Project Repositories Source: https://github.com/reown-com/reown-kotlin/blob/develop/product/walletkit/ReadMe.md Add Maven Central and Jitpack repositories to your root build.gradle.kts file to resolve dependencies. ```gradle allprojects { repositories { mavenCentral() maven { url "https://jitpack.io" } } } ``` -------------------------------- ### Clean build with Gradle Source: https://github.com/reown-com/reown-kotlin/blob/develop/AGENTS.md Run this command to remove all generated build artifacts, preparing for a fresh build. ```bash # Clean build ./gradlew clean ``` -------------------------------- ### Download Test Flows with Git Source: https://github.com/reown-com/reown-kotlin/blob/develop/sample/wallet/README.md Use this command to download the necessary test flows from the WalletConnect/actions repository. Ensure you are in the correct directory before executing. ```bash ./scripts/setup-maestro-pay-tests.sh ``` -------------------------------- ### Clean and Build Project Source: https://github.com/reown-com/reown-kotlin/blob/develop/ReadMe.md Perform a clean build of the project to resolve potential dependency or build issues. ```bash ./gradlew clean build ``` -------------------------------- ### Run all unit tests with Gradle Source: https://github.com/reown-com/reown-kotlin/blob/develop/AGENTS.md Execute this command to run all unit tests across all modules in the project. ```bash # Run all unit tests ./gradlew test ``` -------------------------------- ### Build specific module with Gradle Source: https://github.com/reown-com/reown-kotlin/blob/develop/AGENTS.md Execute this command to build an individual module. Replace ':core:android' with the desired module path. ```bash # Build specific module ./gradlew :core:android:build ``` ```bash ./gradlew :protocol:sign:build ``` ```bash ./gradlew :product:walletkit:build ``` -------------------------------- ### Run a single test class with Gradle Source: https://github.com/reown-com/reown-kotlin/blob/develop/AGENTS.md To execute tests for a single class, append the '--tests' flag followed by the fully qualified class name. ```bash # Run single test class ./gradlew :protocol:sign:testDebugUnitTest --tests "com.reown.sign.SomeTest" ``` -------------------------------- ### Run All Maestro Pay E2E Tests Source: https://github.com/reown-com/reown-kotlin/blob/develop/sample/wallet/README.md Execute all available E2E tests for the WalletConnect Pay flow. Ensure the APP_ID environment variable is set to the correct debug application ID. ```bash APP_ID=com.reown.sample.wallet.debug ./scripts/run-maestro-pay-tests.sh ``` -------------------------------- ### Configure Repositories in root build.gradle.kts Source: https://github.com/reown-com/reown-kotlin/blob/develop/product/appkit/ReadMe.md Add Maven Central and Jitpack repositories to your project's root build.gradle.kts file to resolve dependencies. ```kotlin allprojects { repositories { mavenCentral() maven { url "https://jitpack.io" } } } ``` -------------------------------- ### WalletConnectPay Initialization and Shutdown Source: https://github.com/reown-com/reown-kotlin/blob/develop/AGENTS.md Initializes the WalletConnectPay SDK with the provided configuration and can be shut down when no longer needed. ```APIDOC ## WalletConnectPay Object ### Description Provides methods for initializing, checking initialization status, and shutting down the WalletConnectPay SDK. ### Methods - **initialize(config: Pay.SdkConfig)**: Initializes the SDK. - **isInitialized**: Boolean property to check if the SDK is initialized. - **shutdown()**: Shuts down the SDK. ``` -------------------------------- ### Run a single test method with Gradle Source: https://github.com/reown-com/reown-kotlin/blob/develop/AGENTS.md Execute a specific test method by providing its fully qualified name after the '--tests' flag. ```bash # Run single test method ./gradlew :protocol:sign:testDebugUnitTest --tests "com.reown.sign.SomeTest.testMethod" ``` -------------------------------- ### Run a specific Maestro E2E test file Source: https://github.com/reown-com/reown-kotlin/blob/develop/AGENTS.md Execute a single Maestro test file by specifying its path. The APP_ID environment variable must be set. ```bash # Run a specific test file maestro test --env APP_ID=com.reown.sample.wallet.debug .maestro/pay_single_option_nokyc.yaml ``` -------------------------------- ### Gradle Publishing Commands Source: https://github.com/reown-com/reown-kotlin/blob/develop/AGENTS.md Commands to publish artifacts to Maven Central via Sonatype. Includes publishing to staging, closing, and releasing the repository. ```bash # Publish to staging ./gradlew publishToSonatype # Close and release staging repository ./gradlew closeAndReleaseSonatypeStagingRepository # Bump versions (custom task) ./gradlew bumpVersion -PnewVersion=1.6.0 ``` -------------------------------- ### Add WalletKit Dependencies Source: https://github.com/reown-com/reown-kotlin/blob/develop/product/walletkit/ReadMe.md Include the WalletKit and core Android dependencies in your app's build.gradle.kts file. Ensure you are using the correct BOM version. ```gradle implementation(platform("com.reown:android-bom:{BOM version}")) implementation("com.reown:android-core") implementation("com.reown:walletkit") ``` -------------------------------- ### reown-kotlin Repository Structure Source: https://github.com/reown-com/reown-kotlin/blob/develop/AGENTS.md Provides an overview of the directory structure for the reown-kotlin project, detailing the purpose of each main directory. ```text reown-kotlin/ ├── foundation/ # Pure Kotlin/JVM - crypto, JWT, HTTP utilities ├── core/ │ ├── android/ # Android core - relay, pairing, verification │ ├── modal/ # Shared modal UI components │ └── bom/ # Bill of Materials for version management ├── protocol/ │ ├── sign/ # WalletConnect Sign protocol implementation │ └── notify/ # Notification protocol implementation ├── product/ │ ├── walletkit/ # High-level wallet SDK │ ├── appkit/ # High-level dApp SDK with Compose UI │ ├── pay/ # Payment SDK (standalone, uses Rust/UniFFI) │ └── pos/ # Point of Sale application ├── sample/ │ ├── wallet/ # Wallet reference implementation │ ├── dapp/ # dApp reference implementation │ ├── modal/ # Modal integration example │ └── pos/ # POS example ├── buildSrc/ # Custom Gradle plugins and build logic ├── gradle/ │ ├── libs.versions.toml # Version catalog (dependencies) │ ├── proguard-rules/ # ProGuard configurations │ └── consumer-rules/ # Consumer ProGuard rules ├── .claude/skills/ # AI agent skills for this project └── docs/ # Documentation files ``` -------------------------------- ### Singleton SDK Clients Source: https://github.com/reown-com/reown-kotlin/blob/develop/AGENTS.md Public SDKs expose singleton objects that delegate to internal protocol implementations for core functionalities. ```kotlin object SignClient : SignInterface by SignProtocol.instance object CoreClient : CoreInterface by CoreProtocol.instance object WalletKit : WalletInterface by WalletKitProtocol.instance ``` -------------------------------- ### Run Maestro E2E Pay Tests Source: https://github.com/reown-com/reown-kotlin/blob/develop/CLAUDE.md Execute the E2E tests using Maestro. Ensure the APP_ID is set correctly for your debug build. ```bash # Run all Pay E2E tests APP_ID=com.reown.sample.wallet.debug ./scripts/run-maestro-pay-tests.sh ``` ```bash # Run a specific test file maestro test --env APP_ID=com.reown.sample.wallet.debug .maestro/pay_single_option_nokyc.yaml ``` -------------------------------- ### Add WalletConnect Sign Dependencies Source: https://github.com/reown-com/reown-kotlin/blob/develop/protocol/sign/ReadMe.md Include the WalletConnect Sign library and its core dependencies in your app's build.gradle.kts file. ```kotlin implementation(platform("com.reown:android-bom:{BOM version}")) implementation("com.reown:android-core") implementation("com.reown:sign") ``` -------------------------------- ### Enable Test Mode for Wallet App Source: https://github.com/reown-com/reown-kotlin/blob/develop/CLAUDE.md Set the ENABLE_TEST_MODE environment variable to true when building the wallet app to enable the manual URL input field for testing. ```bash ENABLE_TEST_MODE=true ./gradlew :sample:wallet:assembleDebug ``` -------------------------------- ### Run lint checks with Gradle Source: https://github.com/reown-com/reown-kotlin/blob/develop/AGENTS.md Execute lint checks to identify potential issues and enforce code quality standards. ```bash # Run lint ./gradlew lint ``` -------------------------------- ### Run unit tests for a specific module Source: https://github.com/reown-com/reown-kotlin/blob/develop/AGENTS.md Use this command to run unit tests for a particular module. Specify the module and variant (e.g., 'testDebugUnitTest'). ```bash # Run unit tests for specific module ./gradlew :protocol:sign:testDebugUnitTest ``` -------------------------------- ### Retrieve Payment Options Source: https://github.com/reown-com/reown-kotlin/blob/develop/product/pay/README.md Fetch available payment options for a given payment link and user accounts. Handles success by extracting payment details and failure by logging errors. ```kotlin val result = WalletConnectPay.getPaymentOptions( paymentLink = "https://pay.walletconnect.com/pay_123", accounts = listOf("eip155:8453:0xYourAddress") ) result.onSuccess { response -> val paymentId = response.paymentId val options = response.options val paymentInfo = response.info val collectDataAction = response.collectDataAction }.onFailure { error -> // Handle error } ``` -------------------------------- ### getPaymentOptions Source: https://github.com/reown-com/reown-kotlin/blob/develop/product/pay/README.md Retrieves the available payment options for a given payment link and a list of accounts. This is a crucial step before proceeding with a payment. ```APIDOC ## getPaymentOptions(paymentLink: String, accounts: List) ### Description Retrieves available payment options for a payment link. ### Method `getPaymentOptions` ### Parameters #### Path Parameters - `paymentLink` (String) - Required - The payment link URL (e.g., `"https://pay.walletconnect.com/pay_xxx"`) - `accounts` (List) - Required - List of account addresses in CAIP-10 format (e.g., `"eip155:1:0x..."`) ### Returns - `Result` ``` -------------------------------- ### Add AppKit Dependencies in app build.gradle.kts Source: https://github.com/reown-com/reown-kotlin/blob/develop/product/appkit/ReadMe.md Include the AppKit and Android Core libraries, along with the Bill of Materials (BOM) for version management, in your app's build.gradle.kts file. ```kotlin implementation(platform("com.reown:android-bom:$BOM_VERSION")) implementation("com.reown:android-core") implementation("com.reown:appkit") ``` -------------------------------- ### Run instrumented tests with Gradle Source: https://github.com/reown-com/reown-kotlin/blob/develop/AGENTS.md This command runs instrumented tests on an connected Android device or emulator. ```bash # Run instrumented tests (requires emulator/device) ./gradlew connectedAndroidTest ``` -------------------------------- ### Run a Specific Maestro Pay E2E Test Source: https://github.com/reown-com/reown-kotlin/blob/develop/sample/wallet/README.md Execute a single Maestro test flow by specifying its YAML file. The APP_ID environment variable should be set for the test to run correctly. ```bash maestro test --env APP_ID=com.reown.sample.wallet.debug .maestro/pay_single_option_nokyc.yaml ``` -------------------------------- ### SdkConfig Data Class Source: https://github.com/reown-com/reown-kotlin/blob/develop/product/pay/README.md Configuration object for the Pay SDK, requiring API key, project ID, and package name. ```kotlin data class SdkConfig( val apiKey: String, val projectId: String, val packageName: String ) ``` -------------------------------- ### WalletConnectPay Public API Source: https://github.com/reown-com/reown-kotlin/blob/develop/AGENTS.md The main entry point for the WalletConnectPay SDK. Use `initialize` before other calls and `shutdown` when done. `getPaymentOptions` fetches payment details, `getRequiredPaymentActions` retrieves actions to be signed, and `confirmPayment` finalizes the transaction. ```kotlin object WalletConnectPay { fun initialize(config: Pay.SdkConfig) val isInitialized: Boolean suspend fun getPaymentOptions( paymentLink: String, accounts: List // CAIP-10 format: "eip155:1:0x..." ): Result suspend fun getRequiredPaymentActions( paymentId: String, optionId: String ): Result> suspend fun confirmPayment( paymentId: String, optionId: String, signatures: List, collectedData: List? = null ): Result fun shutdown() } ``` -------------------------------- ### Add reown Android Core dependency Source: https://github.com/reown-com/reown-kotlin/blob/develop/core/android/ReadMe.md Include the reown Android Core SDK as an implementation dependency in the app's build.gradle.kts file. ```kotlin implementation("com.reown:android-core:release_version") ``` -------------------------------- ### Amount and AmountDisplay Data Classes Source: https://github.com/reown-com/reown-kotlin/blob/develop/product/pay/README.md Defines the structure for monetary amounts, including value, unit, and display details like asset symbol and icon. ```kotlin data class Amount( val value: String, val unit: String, val display: AmountDisplay? ) data class AmountDisplay( val assetSymbol: String, val assetName: String, val decimals: Int, val iconUrl: String?, val networkName: String? ) ``` -------------------------------- ### PaymentOptionsResponse Data Class Source: https://github.com/reown-com/reown-kotlin/blob/develop/product/pay/README.md Response object containing payment information, available options, and actions needed to collect data. ```kotlin data class PaymentOptionsResponse( val info: PaymentInfo?, val options: List, val paymentId: String, val collectDataAction: CollectDataAction? ) ``` -------------------------------- ### Sign and Confirm Payment Source: https://github.com/reown-com/reown-kotlin/blob/develop/product/pay/README.md Sign required actions using a wallet implementation and then confirm the payment with the collected signatures and optional data. Handles different payment statuses upon confirmation. ```kotlin // Sign each action using your wallet implementation val signatures = actions.map { action -> when (action) { is Pay.RequiredAction.WalletRpc -> { val rpc = action.action when (rpc.method) { "eth_signTypedData_v4" -> wallet.signTypedData(rpc.chainId, rpc.params) "personal_sign" -> wallet.personalSign(rpc.chainId, rpc.params) else -> throw UnsupportedOperationException("Unsupported method: ${rpc.method}") } } } } // Confirm the payment with signatures val confirmResult = WalletConnectPay.confirmPayment( paymentId = paymentId, optionId = selectedOption.id, signatures = signatures, collectedData = collectedData // Optional, if collectDataAction was present ) confirmResult.onSuccess { response -> when (response.status) { Pay.PaymentStatus.SUCCEEDED -> { // Payment completed successfully } Pay.PaymentStatus.PROCESSING -> { // Payment is being processed // response.pollInMs indicates when to check again } Pay.PaymentStatus.FAILED -> { // Payment failed } else -> { /* Handle other statuses */ } } }.onFailure { error -> // Handle error } ``` -------------------------------- ### Koin Dependency Injection Module Source: https://github.com/reown-com/reown-kotlin/blob/develop/AGENTS.md Defines a feature module using Koin for dependency injection, including core modules and singletons. ```kotlin fun featureModule() = module { includes(coreModule()) single { UseCase(get(), get()) } } ``` -------------------------------- ### PaymentInfo and MerchantInfo Data Classes Source: https://github.com/reown-com/reown-kotlin/blob/develop/product/pay/README.md Contains detailed payment information such as status, amount, expiration, and merchant details. ```kotlin data class PaymentInfo( val status: PaymentStatus, val amount: Amount, val expiresAt: Long, val merchant: MerchantInfo ) data class MerchantInfo( val name: String, val iconUrl: String? ) ``` -------------------------------- ### Generate coverage report with Gradle Source: https://github.com/reown-com/reown-kotlin/blob/develop/AGENTS.md Generate a JaCoCo test coverage report to analyze the extent of test coverage in the project. ```bash # Generate coverage report (JaCoCo) ./gradlew jacocoTestReport ``` -------------------------------- ### Centralized Version Management in Kotlin Source: https://github.com/reown-com/reown-kotlin/blob/develop/AGENTS.md Versions for all modules are managed in a single Kotlin file. This ensures consistency across the project. ```kotlin const val BOM_VERSION = "1.5.2" const val FOUNDATION_VERSION = "1.5.2" const val CORE_VERSION = "1.5.2" const val SIGN_VERSION = "1.5.2" // ... all modules share the same version ``` -------------------------------- ### Shutdown WalletConnect Pay SDK Source: https://github.com/reown-com/reown-kotlin/blob/develop/product/pay/README.md Release SDK resources when they are no longer needed to prevent memory leaks and ensure proper cleanup. ```kotlin WalletConnectPay.shutdown() ``` -------------------------------- ### getRequiredPaymentActions Source: https://github.com/reown-com/reown-kotlin/blob/develop/product/pay/README.md Fetches the necessary wallet RPC actions required to complete a payment, based on the selected payment option. ```APIDOC ## getRequiredPaymentActions(paymentId: String, optionId: String) ### Description Returns wallet RPC actions needed to complete a payment. ### Method `getRequiredPaymentActions` ### Parameters #### Path Parameters - `paymentId` (String) - Required - The payment ID from `PaymentOptionsResponse` - `optionId` (String) - Required - The selected payment option ID ### Returns - `Result>` ``` -------------------------------- ### PaymentOption Data Class Source: https://github.com/reown-com/reown-kotlin/blob/develop/product/pay/README.md Represents a single payment option with its ID, amount, and estimated transaction count. ```kotlin data class PaymentOption( val id: String, val amount: Amount, val estimatedTxs: Int? ) ``` -------------------------------- ### WalletRpcAction Data Class Source: https://github.com/reown-com/reown-kotlin/blob/develop/product/pay/README.md Represents parameters for a Wallet RPC action, including chain ID, method, and JSON parameters. ```kotlin data class WalletRpcAction( val chainId: String, // e.g., "eip155:8453" val method: String, // e.g., "eth_signTypedData_v4" val params: String // JSON string ) ``` -------------------------------- ### Collect Additional Payment Data Source: https://github.com/reown-com/reown-kotlin/blob/develop/product/pay/README.md Use this code to check for and collect additional user data required by a payment option. It maps fields to user input and passes the collected data to confirm the payment. ```kotlin result.onSuccess { response -> response.collectDataAction?.let { collectAction -> val collectedData = collectAction.fields.map { field -> // Collect data from user based on field type val value = when (field.fieldType) { Pay.CollectDataFieldType.TEXT -> getUserTextInput(field.name) Pay.CollectDataFieldType.DATE -> getUserDateInput(field.name) } Pay.CollectDataFieldResult( id = field.id, value = value ) } // Pass collectedData to confirmPayment WalletConnectPay.confirmPayment( paymentId = response.paymentId, optionId = selectedOptionId, signatures = signatures, collectedData = collectedData ) } } ``` -------------------------------- ### Accessing Design Tokens in Composables Source: https://github.com/reown-com/reown-kotlin/blob/develop/AGENTS.md Access all design tokens, including colors, typography, spacing, and border radius, via the `WCTheme` object within any `@Composable` function. Ensure `WCTheme` is properly set up in your composition. ```kotlin val colors = WCTheme.colors // WCColors - semantic light/dark colors val typography = WCTheme.typography // WCTypography - KH Teka font styles val spacing = WCTheme.spacing // WCSpacing - spacing scale (0dp–64dp) val borderRadius = WCTheme.borderRadius // WCBorderRadius - radius scale + pre-built shapes ``` -------------------------------- ### confirmPayment Source: https://github.com/reown-com/reown-kotlin/blob/develop/product/pay/README.md Submits the necessary signatures and collected data to finalize the payment transaction. ```APIDOC ## confirmPayment(paymentId: String, optionId: String, signatures: List, collectedData: List? = null) ### Description Submits signatures and finalizes the payment. ### Method `confirmPayment` ### Parameters #### Path Parameters - `paymentId` (String) - Required - The payment ID - `optionId` (String) - Required - The selected payment option ID - `signatures` (List) - Required - List of signature strings from wallet RPC actions - `collectedData` (List) - Optional - Optional list of collected data field results ### Returns - `Result` ``` -------------------------------- ### ConfirmPaymentResponse Data Class Source: https://github.com/reown-com/reown-kotlin/blob/develop/product/pay/README.md Response object after confirming a payment, indicating the status, finality, and recommended polling interval. ```kotlin data class ConfirmPaymentResponse( val status: PaymentStatus, val isFinal: Boolean, val pollInMs: Long? ) ``` -------------------------------- ### WalletConnectPay Public API Source: https://github.com/reown-com/reown-kotlin/blob/develop/CLAUDE.md The WalletConnectPay SDK provides a set of functions for initiating and managing crypto payments through payment links. It allows developers to integrate crypto payment functionalities into their applications without dependencies on other WalletConnect modules. ```APIDOC ## WalletConnectPay Object ### Description Provides access to the WalletConnectPay SDK functionalities. ### Methods - **initialize(config: Pay.SdkConfig)**: Initializes the SDK with the provided configuration. - **isInitialized**: Boolean property indicating if the SDK has been initialized. - **getPaymentOptions(paymentLink: String, accounts: List)**: Suspended function that retrieves payment options for a given payment link and user accounts. Accounts should be in CAIP-10 format (e.g., "eip155:1:0x..."). Returns a `Result`. - **getRequiredPaymentActions(paymentId: String, optionId: String)**: Suspended function that retrieves the required cryptographic actions (e.g., signatures) for a payment. Returns a `Result>`. - **confirmPayment(paymentId: String, optionId: String, signatures: List, collectedData: List? = null)**: Suspended function that confirms a payment with the provided signatures and any collected user data. Returns a `Result`. - **shutdown()**: Shuts down the SDK and releases resources. ``` -------------------------------- ### PaymentStatus Enum Source: https://github.com/reown-com/reown-kotlin/blob/develop/product/pay/README.md Enumerates the possible states of a payment transaction. ```kotlin enum class PaymentStatus { REQUIRES_ACTION, PROCESSING, SUCCEEDED, FAILED, EXPIRED } ``` -------------------------------- ### GetPaymentOptionsError Sealed Class Source: https://github.com/reown-com/reown-kotlin/blob/develop/product/pay/README.md Defines specific error types that can occur when fetching payment options. ```kotlin sealed class GetPaymentOptionsError : Exception() { data class InvalidPaymentLink(override val message: String) data class PaymentExpired(override val message: String) data class PaymentNotFound(override val message: String) data class InvalidRequest(override val message: String) data class OptionNotFound(override val message: String) data class PaymentNotReady(override val message: String) data class InvalidAccount(override val message: String) data class Http(override val message: String) data class InternalError(override val message: String) } ``` -------------------------------- ### ConfirmPaymentError Sealed Class Source: https://github.com/reown-com/reown-kotlin/blob/develop/product/pay/README.md Defines specific error types that can occur when confirming a payment. ```kotlin sealed class ConfirmPaymentError : Exception() { data class PaymentNotFound(override val message: String) data class PaymentExpired(override val message: String) data class InvalidOption(override val message: String) data class InvalidSignature(override val message: String) data class RouteExpired(override val message: String) data class Http(override val message: String) data class InternalError(override val message: String) data class UnsupportedMethod(override val message: String) } ``` -------------------------------- ### Confirm Payment Source: https://github.com/reown-com/reown-kotlin/blob/develop/product/pay/README.md Submits the necessary signatures and collected data to finalize a payment. This method is called after obtaining the required payment actions. ```kotlin suspend fun confirmPayment( paymentId: String, optionId: String, signatures: List, collectedData: List? = null ): Result ``` -------------------------------- ### Confirm Payment Source: https://github.com/reown-com/reown-kotlin/blob/develop/AGENTS.md Confirms the payment after all required actions (signatures) have been completed and optionally collected user data is provided. ```APIDOC ## confirmPayment ### Description Confirms the payment by submitting the required signatures and any collected user data to the payment service. ### Method `suspend fun confirmPayment(paymentId: String, optionId: String, signatures: List, collectedData: List? = null): Result` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters - **paymentId** (String) - Required - The ID of the payment. - **optionId** (String) - Required - The ID of the selected payment option. - **signatures** (List) - Required - A list of signatures corresponding to the required actions. - **collectedData** (List?) - Optional - Data collected from the user, if any. ### Response #### Success Response - **Pay.ConfirmPaymentResponse**: Contains the final status of the payment (e.g., SUCCEEDED, PROCESSING, FAILED, EXPIRED). #### Response Example (Response structure depends on `Pay.ConfirmPaymentResponse` definition) ``` -------------------------------- ### Shutdown WalletConnectPay SDK Source: https://github.com/reown-com/reown-kotlin/blob/develop/product/pay/README.md Shuts down the WalletConnectPay SDK and releases any associated resources. Call this when the SDK is no longer needed to prevent memory leaks. ```kotlin fun shutdown() ``` -------------------------------- ### RequiredAction Sealed Class Source: https://github.com/reown-com/reown-kotlin/blob/develop/product/pay/README.md A sealed class representing different types of required actions for payment processing, currently supporting WalletRpc actions. ```kotlin sealed class RequiredAction { data class WalletRpc(val action: WalletRpcAction) : RequiredAction() } ``` -------------------------------- ### shutdown Source: https://github.com/reown-com/reown-kotlin/blob/develop/product/pay/README.md Shuts down the WalletConnectPay SDK, releasing any associated resources. This should be called when the SDK is no longer needed. ```APIDOC ## shutdown() ### Description Shuts down the SDK and releases resources. ### Method `shutdown` ``` -------------------------------- ### Exclude and Add JNA Dependency in Gradle Source: https://github.com/reown-com/reown-kotlin/blob/develop/product/pay/README.md Use this snippet to exclude the default JNA dependency and explicitly add the Android-specific JNA variant to resolve dependency conflicts. ```kotlin implementation("com.walletconnect:pay:1.0.0") { exclude(group = "net.java.dev.jna", module = "jna") } implementation("net.java.dev.jna:jna:5.17.0@aar") ``` -------------------------------- ### GetPaymentRequestError Sealed Class Source: https://github.com/reown-com/reown-kotlin/blob/develop/product/pay/README.md Defines specific error types that can occur when requesting payment details. ```kotlin sealed class GetPaymentRequestError : Exception() { data class OptionNotFound(override val message: String) data class PaymentNotFound(override val message: String) data class InvalidAccount(override val message: String) data class Http(override val message: String) data class FetchError(override val message: String) data class InternalError(override val message: String) } ``` -------------------------------- ### Data Collection Field Data Class Source: https://github.com/reown-com/reown-kotlin/blob/develop/product/pay/README.md Represents a field that needs to be collected from the user, including its ID, name, type, and whether it's required. ```kotlin data class CollectDataField( val id: String, val name: String, val fieldType: CollectDataFieldType, val required: Boolean ) ``` -------------------------------- ### PayError Sealed Class Source: https://github.com/reown-com/reown-kotlin/blob/develop/product/pay/README.md Defines general error types for payment operations, including HTTP errors, API errors, and timeouts. ```kotlin sealed class PayError : Exception() { data class Http(override val message: String) data class Api(override val message: String) data object Timeout // Polling exceeded maximum duration } ``` -------------------------------- ### Data Collection Field Types Enum Source: https://github.com/reown-com/reown-kotlin/blob/develop/product/pay/README.md Defines the types of data fields that can be collected from the user during a payment process. ```kotlin enum class CollectDataFieldType { TEXT, DATE } ``` -------------------------------- ### Data Collection Field Result Data Class Source: https://github.com/reown-com/reown-kotlin/blob/develop/product/pay/README.md Represents the collected value for a specific data field. ```kotlin data class CollectDataFieldResult( val id: String, val value: String ) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.