Repository navigation
feat(flutterwave): split payments across subaccounts - #102
Closed
alexasomba wants to merge 11 commits into
Closed
alexasomba wants to merge 11 commits into
alexasomba wants to merge 11 commits into
Conversation
…able Real test-mode run (24 Nov 2026): GET /v3/refunds answers 400 unauthorized on a key that can create refunds. Degrade the duplicate check to a logged warning for that case, log a failed disbursement, and add fixtures from the real verify and refund responses.
This was referenced Nov 24, 2026
This was referenced Nov 24, 2026
Contributor
Author
cavewebs
added a commit
that referenced
this pull request
Nov 27, 2026
Part of the Flutterwave set described in #97. **Item 2** — a generic core seam, independent of #85 (Paystack) and #98 (the Flutterwave package). No Flutterwave code in core. ## Why Flutterwave Inline, its on-page checkout, is a browser SDK initialised with the account's **public** key (`FLWPUBK-…`). Core's provider settings stored only `secretKey` and `webhookSecret`, and a provider has no KV access, so the server could not hand the browser client the key it needs. The shortcut — deriving the public key from the secret key — is not available. I checked a real test pair: `FLWPUBK_TEST-991d…` and `FLWSECK_TEST-03d5…` have different hash segments. ## What - `PaymentProviderCredentials.publicKey` and `credentialFields.publicKey` (label, prefixes, help). - `settings:<id>PublicKey` in the settings schema, `providerCredentialSetting` and `GET admin/settings` `_providers`, validated against the prefixes the provider declares and masked like the other credentials. - A third field in Settings → Payment provider, rendered **only** for a provider that declares one. - `loadPaymentProviderCredentials` returns `publicKey` when set. ## What does not change - Stripe's fields, keys and behaviour. - Providers that do not declare a public key: their settings row is byte-for-byte the same, and a `publicKey` value is refused for them (so a typo cannot save a key nothing reads). - The secret key and webhook secret are still offered for every provider, as before. ## Tests - `provider-credentials-settings.test.ts`: saves and loads the public key, validates its prefix, refuses one for a provider that does not declare it, never returns the value (only set/hint), and omits the row entirely for such a provider. - 12 tests in that file, 58 across the provider/credentials/webhook-header files, `tsc --noEmit` clean. - Changeset: minor for `@dashcommerce/core`. ## Next Item 3 is [#100](#100): the provider declares the field, returns `on_page` with `{ publicKey, txRef, amount, currency, customer… }`, and ships a `./checkout-client` that loads `checkout.flutterwave.com/v3.js` only when the customer presses Pay. The split seams are [#101](#101) (core) and [#102](#102) (Flutterwave). All are open.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 Flutterwavesubaccountsitem:{ "id": "RS_…", "transaction_charge_type": "flat_subaccount", "transaction_charge": 1350 }flat_subaccountpays 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-sessionclientpayload;./checkout-clientparses 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
subaccounts.Tests
Split behaviour worth knowing
RS_…id into Vendors. A follow-up can add API-driven subaccount creation.End to end in Flutterwave test mode (24 Nov 2026)
RS_CD57…(Access Bank 0690000031) andRS_A075…(0690000032)10633643meta.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-hookcalls 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.