Skip to content

feat(flutterwave): record split settlements on the order - #106

Closed
alexasomba wants to merge 19 commits into
emdashCommerce:mainfrom
alexasomba:feat/flutterwave-split-settlement
Closed

alexasomba wants to merge 19 commits into
emdashCommerce:mainfrom
alexasomba:feat/flutterwave-split-settlement

Conversation

@alexasomba

@alexasomba alexasomba commented Nov 24, 2026 •

Copy link
Copy Markdown

Part of the Flutterwave set described in #97. Item 9. Builds on #102, #104 and #105. Review those first.

What

Flutterwave reports what a split payment actually settled in meta.split_settlement_info, a JSON string keyed by subaccount id:

{
  "RS_A…": { "merchant_commission": 0, "subaccount_earning": 900 },
  "RS_B…": { "merchant_commission": 0, "subaccount_earning": 450 },
  "total_merchant_commission": 76.5
}

This parses it, plus app_fee, into core's splitSettlement:

  • each subaccount's subaccount_earning → allocations[].amountMinor (major → minor);
  • total_merchant_commission → platformRemainderMinor;
  • app_fee → providerFeeMinor;
  • the event currency and the raw object.

Core stores it on Order.providerSplits, maps each subaccount reference to its vendor from Vendor.paymentAccounts, and the admin order detail shows a Split settlement card (vendor or “Unmatched account”, account, settled amount, platform remainder, provider fee).

The settlement is recorded for reconciliation only; it never reprices the vendor shares DashCommerce computed.

Tests

  • 98 package tests, including the real split fixture: 90,000 + 45,000 minor to the two subaccounts, 7,650 platform remainder, 7,350 provider fee.
  • 354 core tests, including a full two-vendor checkout → webhook → order with providerSplits mapped to v1/v2.
  • Typecheck clean; changeset minor.

Split refunds

A real refund attempt on the split payment returned 400 {"message":"Some error occured","data":{"message":"Refund request successfully logged"}} with no refund id. The package treats that as a failure so the order is not marked refunded, and now surfaces the nested message instead of “Some error occured”. The README tells the merchant to process it in the Flutterwave dashboard. No subaccount clawback is attempted.

What is left

  • The real webhook delivery (dashboard pointing at the tunnel).
  • Country-specific subaccount meta (SWIFT/routing/branch) in the onboarding form.

@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