Skip to content

feat(payments): add cross-account payment splitting (#1720) - #1837

Merged
github-actions[bot] merged 3 commits into
Smartdevs17:mainfrom
Clement-coder:feat/1720-cross-account-payment-splitting
Oct 19, 2026
Merged

github-actions[bot] merged 3 commits into
Smartdevs17:mainfrom
Clement-coder:feat/1720-cross-account-payment-splitting

Conversation

@Clement-coder

Copy link
Copy Markdown
Contributor

Summary

Splits a payment across multiple destination accounts by percentage, resolving #1720.

Changes

  • PaymentSplitService – domain service with validateSplits() (enforces ≥2 entries, each % > 0, sum within 0.01 of 100) and split() which issues one charge per destination, derives per-split idempotency keys, and continues through individual gateway failures
  • PaymentSplitController – handles POST /api/v1/payments/split; returns 200 when all splits succeed, 207 Multi-Status on partial failure, 422 when percentages don't sum to 100
  • paymentSplitRouter – wired into createApiServer at /api/v1
  • 005_payment_split_records.sql – migration adding payment_split_records (header) and payment_split_entries (per-destination detail) tables
  • PaymentSplitService.test.ts – 46 passing tests covering validation, arithmetic, partial/full failure, idempotency key derivation, metadata forwarding, and all HTTP response codes

Acceptance criteria

  • Percentages validated to 100 (validateSplits throws SPLIT_VALIDATION_ERROR otherwise)
  • Each split is recorded (payment_split_entries table + full result returned in response)
  • Tested (46/46 tests pass)

Test output

Tests: 46 passed, 46 total

github-actions Bot and others added 3 commits October 19, 2026 11:10
Split a payment across multiple destination accounts by percentage.

- Add PaymentSplitService with validateSplits() enforcing sum=100
- Add PaymentSplitController (POST /api/v1/payments/split)
  - Returns 200 when all splits succeed, 207 on partial failure
  - Returns 422 when percentages do not sum to 100
- Add paymentSplitRouter and mount it in createApiServer
- Add migration 005_payment_split_records.sql with
  payment_split_records + payment_split_entries tables
- Add 46 passing tests covering validation, arithmetic, failure
  handling, idempotency key derivation, and HTTP responses

Closes Smartdevs17#1720
@drips-wave

drips-wave Bot commented Oct 19, 2026

Copy link
Copy Markdown

@Clement-coder 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

@github-actions
github-actions Bot merged commit 4fdbd60 into Smartdevs17:main Oct 19, 2026
13 of 32 checks passed
* Percentages must sum to exactly 100.
* Returns 200 when all splits succeed, 207 when some fail.
*/
router.post('/payments/split', wrap((req, res) => controller.split(req, res)));
@Clement-coder
Clement-coder deployed to security-review October 19, 2026 12:01 — with GitHub Actions Active

This branch was successfully deployed

1 active deployment
security-review — a091a085 Deployed Oct 19, 2026 by Clement-coder via Security Dashboard #1390
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.

2 participants