Repository navigation
Description
Summary
#76 did this for Paystack: one place to review a second gateway and the core seams it needed. The core changes that make a second gateway possible are merged (#81–#84, #90). We've built Flutterwave on them: six generic core changes and one package, all open.
Hosted checkout runs on merged core today; the core PRs add on-page checkout, multi-vendor splits, in-admin vendor onboarding, split settlement and refunds, a provider-neutral subscription seam, and two checkout/refund safety fixes. This is independent of #85 (Paystack), which is still open. The package was previously split across #98/#100/#102/#104/#106, now closed in favour of #107.
The PRs, in merge order:
| # | PR | What it does |
|---|---|---|
| 1 | #99 feat(core): a public-key credential for payment providers | Core change 1. Independent |
| 2 | #101 feat(core): split payments across vendor payout accounts | Core change 2. The base for 3 and 4 |
| 3 | #103 feat(core): provider-managed payout account onboarding | Core change 3. Builds on 2 |
| 4 | #105 feat(core): split settlement and refunds | Core change 4. Builds on 2. Includes the split-refund guard |
| 5 | #114 feat(core): add a provider-neutral subscription seam | Core change 5. Independent |
| 6 | #115 fix(core): harden checkout and refund safety | Core change 6. Independent |
| 7 | #107 feat(flutterwave): Flutterwave payment provider package | The package. Builds on 1–6 |
#107 is the single review for packages/flutterwave; it carries the features that would otherwise have been five stacked package PRs. #105 includes the split-refund guard; #107 declares splitRefunds: false for Flutterwave.
How this maps to #76's deferred list
| Deferred in #40 / #76 | Here |
|---|---|
Settings UI for settings:paymentProvider |
Already merged in #81; Flutterwave uses the credential fields plus the public key from #99 |
| Per-provider webhook URL path | Not needed. verif-hash plus the saved credentials cover the existing URL |
| POS / async polling | Not in this set |
| Publishing to npm | Question below |
| Split payments (the #76 comment) | Core change 2 and the package |
The core changes
1. A public key credential
Flutterwave Inline needs the account's public key (FLWPUBK-…). Core stored only the secret key and webhook secret, and a provider has no KV access, so the server could not hand the browser the key it needs.
PaymentProviderCredentials.publicKey and credentialFields.publicKey; saved as settings:<id>PublicKey, validated against the declared prefixes and masked like the others. Settings shows the field only for a provider that declares it, and a provider without one cannot have a public key saved.
The derivation shortcut is dead: a real test pair (FLWPUBK_TEST-991d… / FLWSECK_TEST-03d5…) has different hash segments.
2. Split allocations and vendor payout accounts
Core could not hand a provider exact per-vendor amounts, and a cart with vendor items was refused for every non-Stripe provider.
capabilities.splits and InitCheckoutInput.allocations (vendorId, accountReference, amountMinor) + platformRemainderMinor, computed from trusted cart prices and the vendor fee. Vendor.paymentAccounts stores the provider account reference, status, currency and label. Vendor.stripeAccountId is optional and omitted for non-Stripe vendors, so a shop without Stripe can create more than one vendor. A cart-wide discount comes out of the platform remainder; a discount larger than that remainder is a readable 409. Checkout refuses a vendor cart when the provider cannot split or a vendor has no active account. The product editor's vendor picker and save validation accept a split-capable provider's active account, not only Stripe chargesEnabled.
3. Provider-managed payout onboarding
The create-subaccount API makes the "paste an RS_… id" flow a v1.
VendorPaymentAccount gains the resolved account name, verified, bank, country and a masked number. PaymentProvider gains optional listPayoutBanks, resolvePayoutAccount and createPayoutAccount; admin routes and the Vendors page render country → bank or mobile money → account → Verify account (only when the provider can resolve names) → business details → create. An active-but-unverified account (Paystack's is_verified: false) is stored with verified: false and remains usable for splits. The form starts on the store's default-currency country. The full account number is never stored.
4. Split settlement records
Flutterwave's verify response says what each subaccount actually earned; core discarded it.
charge.succeeded gains splitSettlement (per-account minor amounts, platform remainder, provider fee). Order.providerSplits stores it with each account reference mapped to its vendor, and the admin order detail shows a Split settlement card. It never reprices the shares core computed; a failure to record it is logged without making the webhook retry.
The same PR adds capabilities.splitRefunds. A provider that cannot refund a split charge declares false; core refuses before calling it and points the merchant to the provider's dashboard. The Split settlement card also warns that a refund comes from the platform balance and vendor shares are not recovered automatically.
5. Provider-neutral subscriptions
Flutterwave supports subscriptions through Payment Plans, but core's subscription engine was Stripe Billing-specific. PaymentProvider gains optional getSubscription, cancelSubscription and resumeSubscription; charge.succeeded and PaymentStatusResult can carry ProviderSubscriptionInfo; and a normalised subscription.updated event handles a cancellation outside a charge.
subscriptions/provider.ts stores a provider-managed subscription and its invoices in the existing collections. The first charge creates the order and the local subscription; later charges are paid invoices that extend the period, not new orders. Subscription and invoice ids are scoped by provider in the unique storage key. Admin and customer portal hide Pause and the Stripe billing portal for those subscriptions.
6. Checkout and refund safety
taxMode: "stripe_tax"is refused for a non-Stripe provider instead of silently charging the pre-tax total.admin/orders/refundaccepts a stablerefundRequestId;refundOrderreturns the recorded refund for a repeated id instead of calling the provider again. The UI keeps the id across a lost response and shows a failed provider refund as an error.
The package
packages/flutterwave registers itself on import "@dashcommerce/flutterwave".
- Hosted:
POST /v3/payments→ redirect to the hosted link; referencedc-<draftId>. - On-page: Flutterwave Inline via
./checkout-client;v3.jsloads only on Pay;callback/oncloseonly move the customer, and orders still come only from the signed webhook. - Splits: core allocations →
subaccountswithflat_subaccount+ the exact amount, hosted and Inline. The subaccount default may bepercentageorflat; the transaction override keeps the shares exact. Flutterwave fees and the NGN 50 stamp duty come from the platform remainder; if settlement is less than the flat amounts, Flutterwave does not split that payment. - Onboarding:
GET /v3/banks/{country},POST /v3/accounts/resolve,POST /v3/subaccounts; theRS_…id is stored with the masked number. Mobile-money channels such as M-PESA are accepted alongside banks, and the manual id remains as a fallback. - Discounts:
capabilities.coupons: true; the discount is applied to the amount Flutterwave charges. - Settlement: parses
meta.split_settlement_infoandapp_feeinto core'ssplitSettlement. - Split refunds:
capabilities.splitRefunds: false. A split refund returns400with no id, so DashCommerce refuses it and points to the Flutterwave dashboard. - Refund safety: a stable
refundRequestIdis sent as the comment tag; core's local ledger stops a retry from calling the provider again. - Refunds: by transaction id or
tx_ref, duplicate guard via(refundRequestId=…), refund webhook →refund.updated.GET /v3/refundsis unauthorized on some keys, so the guard degrades to a logged warning; one partial refund at a time;disburse_status: failedis logged. - Currencies: NGN, USD, GBP, EUR, KES, GHS, ZAR, UGX, TZS, RWF, XOF, XAF, ZMW, MWK, EGP.
- Connection check: read-only
GET /v3/balances. - Subscriptions: Flutterwave Payment Plans, card-only. One plan per checkout (the plan id is the subscription key);
payment_planon hosted and Inline; the first charge creates the order and local subscription; renewals are idempotent invoices from theplanfield; cancel/resume through the plan. Trials, pause and in-place upgrades are refused. Subscription + vendor items are refused by core. - Tax:
stripe_taxis refused for Flutterwave; flat or table tax works because core includes it in the charged amount. - Not included: country-specific subaccount
metain the form, API-driven split refunds.
Where the package lives
@dashcommerce/flutterwave sits in this monorepo beside core, publishable like core, versioned with the provider interface it depends on, and its tests run against core's real routes in the same CI. The package suite is 113 tests; core is 373, including checkout → webhook → order → refund. One minor changeset takes it to 0.1.0 beside core 0.4.0.
Evidence: end to end in Flutterwave test mode (24 Nov 2026)
Nigerian test account, KES wallet, test keys only.
| Area | Result |
|---|---|
| Hosted link creation | 200; real link |
| Real KES 1,500 M-Pesa through Inline | Paid; callback → finished; transaction 10633614 |
Verify by id and tx_ref |
succeeded, 150000 minor, KES |
| Split, two vendors | 900 to RS_CD57…, 450 to RS_A075…, 76.5 platform after the 73.5 fee; confirmed in split_settlement_info |
| Payout onboarding | 598 NG banks; 0690000033 → Bale Gary; created RS_043B…, probe deleted |
| Partial + settled-max refunds | Succeeded; verify still reports successful (documented) |
| Split refund | 400 "Refund request successfully logged", no id; treated as a failure and surfaced |
| Webhook delivery | Real KES 100 payment 10633692 and two resends accepted; nothing reached the tunnel |
| Subscription plan + first charge | Plan 254811 (KES 100/month); real test-card payment 10634465 through Inline; verify returned plan: 254811 |
| Package-level plan creation | initCheckout created plan 254812 and opened Inline with payment_plan |
| Hosted subscription link | initCheckout created plan 254813 and returned a hosted link; the page opened in test mode |
| Plan cancel / reactivate | PUT /v3/payment-plans/254813/cancel → cancelled; update to active → active; cancelled again |
| Admin | Split settlement card renders the mapped vendors and amounts |
What the run changed in the package: the refund list being unauthorized now degrades to a logged warning instead of blocking refunds; disburse_status: failed is logged; one-partial-refund-at-a-time is documented; the split-refund nested message is surfaced. Verify keeps reporting successful after a refund, so a payment refunded in full before its order exists cannot be distinguished. The subscription probe added Payment Plans; because GET /v3/subscriptions is broken on this account, the plan id is the local key and cancel goes through the plan.
Not yet run: a real renewal cycle, a real subscription.cancelled delivery, whether the plan update actually resumes billing, a completed hosted payment_plan payment, country-specific subaccount meta in the form, a declined payment, and the replay matrix.
Question
Publish @dashcommerce/flutterwave 0.1.0 with the core release that carries #99/#101/#103/#105/#114/#115 (0.4.0), the same way @dashcommerce/paystack plans to? The package peer-depends on @dashcommerce/core ^0.4.0.
And is the merge order right: #99 independently, #101 first among the split work, then #103/#105, #114/#115, then #107? Or would you rather release 0.1.0 with the base seams and take onboarding/settlement in 0.2.0?
Activity
[-]Flutterwave as a second gateway: the package, what it covers, and the one core gap left[/-][+]Flutterwave as a second gateway: the package, and the two core seams it still needs[/+][-]Flutterwave as a second gateway: the package, and the two core seams it still needs[/-][+]Flutterwave as a second gateway: the package and the two core seams, sent as one reviewed set[/+][-]Flutterwave as a second gateway: the package and the two core seams, sent as one reviewed set[/-][+]Flutterwave as a second gateway: the package, three core seams and the live evidence[/+][-]Flutterwave as a second gateway: the package, three core seams and the live evidence[/-][+]Flutterwave as a second gateway: the package, the core changes and the live evidence[/+][-]Flutterwave as a second gateway: the package, the core changes and the live evidence[/-][+]Flutterwave as a different gateway: the package, the core changes and the live evidence[/+]