Skip to content

feat: integrate WalletConnectPay SDK into WalletKit#252

Merged
jakubuid merged 5 commits intofeat/wc_payfrom
wcpay_in_wk
Jan 20, 2026
Merged

feat: integrate WalletConnectPay SDK into WalletKit#252
jakubuid merged 5 commits intofeat/wc_payfrom
wcpay_in_wk

Conversation

@jakubuid
Copy link
Collaborator

@jakubuid jakubuid commented Jan 19, 2026

Summary

  • Integrate WalletConnectPay SDK into WalletKit with explicit API approach
  • Add WalletKit.Pay.isPaymentLink() utility to detect payment links
  • Add WalletKit.Pay.getPaymentOptions() for explicit payment flow initiation
  • Sample wallet explicitly routes to payment or WC pairing based on isPaymentLink()

Architecture

sequenceDiagram
    participant App as Sample Wallet
    participant VM as Web3WalletViewModel
    participant WK as WalletKit
    participant Pay as WalletConnectPay
    participant PVM as PaymentViewModel

    App->>VM: pair(uri)
    VM->>WK: Pay.isPaymentLink(uri)
    
    alt Payment Link
        WK-->>VM: true
        VM->>WK: Pay.getPaymentOptions(uri, accounts)
        WK->>Pay: getPaymentOptions()
        Pay-->>WK: PaymentOptionsResponse
        WK-->>VM: Result<PaymentOptionsResponse>
        VM->>VM: emit to paymentOptionsEvent
        VM-->>App: Navigate to PaymentRoute
        PVM->>PVM: collect paymentOptionsEvent
        PVM-->>App: UI State updated
    else WC Pairing
        WK-->>VM: false
        VM->>WK: pair(uri)
        WK-->>VM: Standard WC pairing flow
    end
Loading

Key Changes from Previous Approach

Previous (Callback) New (Explicit API)
pair() auto-detects payment links pair() only does WC pairing
accounts param in Wallet.Params.Pair No accounts in pair()
onPaymentRequest callback in delegate App explicitly calls getPaymentOptions()
Automatic fallback logic App uses isPaymentLink() to decide flow

API Usage

// In ViewModel when receiving a URI:
val uri = "..." // from QR or deeplink

if (WalletKit.Pay.isPaymentLink(uri)) {
    // Explicitly call payment API
    val result = WalletKit.Pay.getPaymentOptions(uri, accounts)
    result.fold(
        onSuccess = { response -> /* show payment UI */ },
        onFailure = { error -> /* handle error */ }
    )
} else {
    // Standard WC pairing
    WalletKit.pair(Wallet.Params.Pair(uri))
}

Changes

WalletKit SDK (product/walletkit/)

  • Wallet.kt: Simplified Params.Pair (removed accounts param), added payment models
  • WalletKit.kt:
    • Added WalletKit.Pay.isPaymentLink() utility function
    • Added WalletKit.Pay.getPaymentOptions() for explicit calls
    • Simplified pair() - now only does standard WC pairing
    • Removed onPaymentRequest callback from WalletDelegate
  • PayMapper.kt: Type conversion functions between Pay and Wallet.Model types

Sample Wallet (sample/wallet/)

  • Web3WalletViewModel.kt:
    • Updated pair() to use isPaymentLink() for routing
    • Added handlePaymentLink() that explicitly calls getPaymentOptions()
  • WalletKitDelegate.kt: Removed onPaymentRequest callback override
  • PaymentViewModel.kt: Collects from shared event flow

Test plan

  • Scan a WCPay QR code → verify isPaymentLink() returns true
  • Verify getPaymentOptions() is called explicitly
  • Verify payment options modal appears
  • Complete payment flow
  • Scan standard WC QR code → verify isPaymentLink() returns false
  • Verify standard WC pairing flow works

🤖 Generated with Claude Code

jakubuid and others added 5 commits January 19, 2026 14:23
- Add Pay module dependency to WalletKit build.gradle.kts
- Add payment models to Wallet.kt (PaymentStatus, PaymentInfo, PaymentOption, etc.)
- Create PayMapper.kt for Pay <-> Wallet.Model type conversions
- Add onPaymentRequest callback to WalletDelegate interface
- Update WalletKit.initialize() to init WalletConnectPay silently
- Add WalletKit.Pay object with getRequiredPaymentActions() and confirmPayment()
- Update pair() to try Pay first when accounts provided, fallback to WC pairing
- Update sample wallet to use WalletKit.Pay instead of direct WalletConnectPay calls
- Add event-based payment flow via paymentOptionsEvent SharedFlow with replay

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@sonarqubecloud
Copy link

@jakubuid jakubuid merged commit 70c8f1a into feat/wc_pay Jan 20, 2026
8 of 10 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Jan 20, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant