Skip to content

feat: implement multi-token payment method management with priority ordering#453

Merged
Smartdevs17 merged 3 commits into
Smartdevs17:mainfrom
Junman140:feat/payment-method-multi-token
May 28, 2026
Merged

feat: implement multi-token payment method management with priority ordering#453
Smartdevs17 merged 3 commits into
Smartdevs17:mainfrom
Junman140:feat/payment-method-multi-token

Conversation

@Junman140
Copy link
Copy Markdown
Contributor

@Junman140 Junman140 commented May 27, 2026

Closes #366


Summary

Implements a comprehensive multi-token payment method management system with priority ordering and automatic fallback.

Changes

TypeScript (Frontend)

  • src/types/wallet.ts - Added PaymentMethod, PaymentPriority, TokenType (XLM, USDC, ETH, NATIVE, MATIC, ARB), PaymentAttempt, PaymentMethodValidationResult types
  • src/services/walletService.ts - Added PaymentMethodService class with CRUD, priority ordering, validation, fallback, expiry tracking, balance checks, gas spike detection, token contract upgrade detection
  • src/store/walletStore.ts - Zustand store with persistent async storage for payment methods per user

Rust (Smart Contracts)

  • contracts/types/src/lib.rs - Added PaymentMethod, PaymentPriority, TokenType, PaymentAttempt, PaymentAttemptStatus contract types
  • contracts/subscription/src/payment_methods.rs - New Soroban contract module with multi-method storage, priority sorting, charge-with-fallback, expiry auto-deactivation, event emission
  • contracts/subscription/src/lib.rs - Wired payment method module as public contract API

Edge Cases Handled

  • Token balance insufficient at charge time
  • Gas price spikes
  • Token contract upgrade detection
  • All methods exhausted fallback

Acceptance Criteria

  • Multi-payment-method storage per user
  • Payment method priority (primary, backup, fallback)
  • Token type support (XLM, USDC, ETH, NATIVE)
  • Payment method validation and verification
  • Automatic fallback on primary payment failure
  • Payment method expiry tracking and notification

Junman140 added 2 commits May 27, 2026 11:54
- Tax rate lookup by jurisdiction (country, state, city) with hierarchical fallback
- Tax-exempt customer handling with certificate validation and expiry checks
- Mid-cycle tax rate change proration for existing subscriptions
- Reverse-charge flagging and nexus threshold determination
- Multi-jurisdiction: VAT, GST, sales tax, HST, PST, QST, digital services tax
- Digital goods tax classification with country-specific rules
- Tax remittance report generation with jurisdiction aggregation

Contracts (Rust/Soroban):
- types: Add TaxType, TaxJurisdiction, TaxRateEntry, CustomerTaxStatus,
  DigitalGoodsClass, TaxRemittanceLineItem types and 5 StorageKey variants
- invoice: 11 new contract functions for full tax lifecycle + 10 test cases
- subscription: Update generate_invoice signature with jurisdiction params
- proxy: Fix StorageKey variant names for Soroban 32-char limit

Backend (TypeScript):
- TaxService with 17 built-in jurisdiction rates, caching, exemption validation
- Nexus checks, mid-cycle proration, digital goods tax rules
- Remittance report generation with filtering and grouping
- 25 test cases covering all tax scenarios

Frontend (React Native):
- Extended Invoice types with TaxJurisdiction, CustomerTaxStatus, etc.
- invoiceStore: Tax state management with 12 new actions
…rdering

- Add PaymentMethod, PaymentPriority, TokenType, PaymentAttempt types
- Implement PaymentMethodService for CRUD, validation, fallback, expiry
- Add PaymentMethod store with persistent async storage per user
- Add on-chain payment method contract module (Soroban)
- Support automatic fallback on primary payment failure
- Track payment method expiry and notify expiring methods
- Handle edge cases: insufficient balance, gas price spikes, token
  contract upgrades
@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented May 27, 2026

@Junman140 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@Smartdevs17 Smartdevs17 merged commit 71b8ebd into Smartdevs17:main May 28, 2026
5 of 23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement subscription payment method management with multiple tokens

2 participants