Skip to content

feat: implement split payment distribution engine with concurrent exe… - #1037

Merged
Kingsman-99 merged 1 commit into
Stellar-split:mainfrom
kingsrichie79-cmyk:feature/split-payment-distribution-engine
Oct 21, 2026
Merged

Kingsman-99 merged 1 commit into
Stellar-split:mainfrom
kingsrichie79-cmyk:feature/split-payment-distribution-engine

Conversation

@kingsrichie79-cmyk

Copy link
Copy Markdown
Contributor

Closes #971

Overview

Enables single payments to be automatically split and distributed to multiple recipients with rule validation, concurrent execution, failure handling, and confirmation tracking.

Requirements & Implementation

  • Split Payment Data Structures: Defined SplitPaymentRequest, SplitPaymentConfirmation, SplitPaymentResult, RecipientPaymentResult, SplitRule, SplitRuleConfig, and related types in src/types/splitPayment.ts.
  • Split Calculation Logic: Implemented in src/lib/splitPayment.ts ensuring stroop-scale precision, proper deduction of taxes and fixed fees, and allocation of remainder rounding to maintain exact totals.
  • Split Rule Validation: Built src/lib/splitPaymentRules.ts with validation functions:
    • Minimum recipient amount check (validateMinAmount)
    • Maximum total payment amount check (validateMaxAmount)
    • Maximum recipient threshold check (validateMaxRecipients)
    • Minimum share percentage check (validateMinSharePercent)
    • Address uniqueness validation (validateUniqueAddresses)
    • Stellar public key validity check (validateAddresses)
    • Payer balance verification (validateSufficientBalance)
    • Master rule runner (validateSplitRules)
  • Concurrent Payment Execution: Implemented executeSplitPayment in src/lib/splitPayment.ts dispatching payments to all recipients concurrently using Promise.all with retry backoff.
  • Failure Handling: Comprehensive state handling (completed, partial_failure, failed) tracking successful and failed payments, amounts distributed, individual transaction hashes, and error messages.
  • Confirmation Workflow: Created buildSplitConfirmation, useSplitPayment hook, and SplitPaymentConfirmationModal UI component to preview allocations and require rule validation prior to execution.

Testing & Verification

  • Comprehensive unit test suite in src/__tests__/splitPayment.test.ts covering calculation accuracy, rule validations, concurrent payments, retry handling, partial failures, and complete failures.
  • React hook tests in src/__tests__/useSplitPayment.test.ts.
  • Modal UI tests in src/__tests__/SplitPaymentConfirmation.test.tsx.

@drips-wave

drips-wave Bot commented Oct 20, 2026

Copy link
Copy Markdown

@kingsrichie79-cmyk 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

@vercel

vercel Bot commented Oct 20, 2026

Copy link
Copy Markdown

@kingsrichie79-cmyk is attempting to deploy a commit to the kingsman-99's projects Team on Vercel.

A member of the Team first needs to authorize it.

@Kingsman-99
Kingsman-99 merged commit d58beac into Stellar-split:main Oct 21, 2026
1 check failed
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.

Add split payment functionality across multiple recipients

2 participants