Skip to content

feat(flutterwave): split payments across subaccounts - #102

Closed
alexasomba wants to merge 11 commits into
emdashCommerce:mainfrom
alexasomba:feat/flutterwave-splits
Closed

alexasomba wants to merge 11 commits into
emdashCommerce:mainfrom
alexasomba:feat/flutterwave-splits

Conversation

@alexasomba

@alexasomba alexasomba commented Nov 24, 2026 •

Copy link
Copy Markdown

Part of the Flutterwave set described in #97. Item 5. Builds on #98 (the package), #100 (on-page) and #101 (the split allocation seam). Review those first; this branch contains their commits until they merge.

What

Flutterwave subaccount splits, for hosted and on-page checkout:

  • Declares capabilities.splits: true.

  • When core sends allocations, each becomes a Flutterwave subaccounts item:

    { "id": "RS_…", "transaction_charge_type": "flat_subaccount", "transaction_charge": 1350 }

    flat_subaccount pays the subaccount that exact amount, so core's minor-unit share maps one-to-one after the major-unit conversion. The platform keeps the remainder.

  • Hosted checkout sends the array on POST /v3/payments. On-page sends it as JSON in the create-session client payload; ./checkout-client parses it and passes the array to Inline.

  • Every share is validated before the provider call: no empty account, no non-positive amount, no total above the checkout amount, no negative platform remainder. A malformed split in the browser is refused rather than opening an unsplit payment.

What does not change

  • A cart without vendor items sends no subaccounts.
  • The order still comes only from the signed webhook and the live verify; a split does not change confirmation, dedupe or refunds.
  • Refunds are still taken from the platform balance by Flutterwave; the package does not attempt a subaccount clawback.

Tests

  • 90 package tests (was 82): hosted mapping, Inline JSON mapping, no allocations, empty account, zero share, shares above the total, and the browser parsing/refusing a split.
  • 346 core tests pass in this branch, including the split allocation seam and the product-to-vendor assignment fix from feat(core): split payments across vendor payout accounts #101.
  • Typecheck clean; build emits both entries; Biome clean on the touched files.

Split behaviour worth knowing

  • Flutterwave's transaction fee and the NGN 50 stamp duty (over NGN 10,000) come out of the platform remainder, not the vendor shares.
  • If the settlement is less than the sum of the flat amounts, Flutterwave does not split that payment and sends the whole settlement to the main account. The package cannot detect that before the provider's fee is known; the README tells the merchant to watch the dashboard for it.
  • Creating subaccounts via the Flutterwave API (bank details, KYC) is out of scope here: the merchant creates the subaccount in the dashboard and pastes the RS_… id into Vendors. A follow-up can add API-driven subaccount creation.

End to end in Flutterwave test mode (24 Nov 2026)

Check Result
Two collection subaccounts created RS_CD57… (Access Bank 0690000031) and RS_A075… (0690000032)
KES 1,500 two-vendor payment through the package's Inline client Succeeded, transaction 10633643
Vendor A share 900 KES
Vendor B share 450 KES
Platform remainder 76.5 KES, after Flutterwave's 73.5 KES fee
Flutterwave's own settlement metadata meta.split_settlement_info = { RS_CD57…: { subaccount_earning: 900 }, RS_A075…: { subaccount_earning: 450 }, total_merchant_commission: 76.5 }

The split is confirmed by Flutterwave's settlement record, not only by the payload we sent. A real verify response is committed as a fixture and parsed in the test suite.

Still to run: the real webhook delivery (a real KES 100 payment and two resend-hook calls were accepted on 24 Nov 2026, but nothing reached the test tunnel yet — the dashboard configuration is under review), and a refund on a split payment — Flutterwave refunds come from the platform balance and this package does not attempt a subaccount clawback.

@alexasomba

Copy link
Copy Markdown
Author

Superseded by #107 — the Flutterwave package is now reviewed as one PR. The commits are preserved on the consolidated branch, and the core PRs (#99, #101, #103, #105) stay separate.

@alexasomba alexasomba closed this Nov 24, 2026
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.

1 participant