Repository navigation
feat(flutterwave): Flutterwave payment provider package - #98
Closed
alexasomba wants to merge 2 commits into
Closed
alexasomba wants to merge 2 commits into
alexasomba wants to merge 2 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
Author
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. Builds on the merged provider seam (#81–#84, #90); no core changes. Independent of #85 (Paystack): both packages sit on the same merged core seam, and either can merge first.
What
packages/flutterwave: aPaymentProviderfor Flutterwave on core's provider interface. It covers card, M-Pesa and mobile money through Flutterwave's hosted checkout, in NGN, USD, GBP, EUR, KES, GHS, ZAR, UGX, TZS, RWF, XOF, XAF, ZMW, MWK and EGP. It registers itself onimport "@dashcommerce/flutterwave". The README covers setup:allowedHosts: ["api.flutterwave.com"], keys, the secret hash, and the webhook URL.How it behaves
1500, and Flutterwave's1500comes back as150000. Unit-tested in both directions, including string amounts.charge.completedwithdata.status = successful, confirmed withGET /v3/transactions/:id/verifybefore core writes the order.failed/cancelledbecomecharge.failedand release the stock lock;pendingcreates nothing. The order stores the numeric transaction id aspaymentReference(refunds need it) andtx_refascheckoutReference.verif-hash, not an HMAC. The package compares it in constant time, trims whitespace, and explains the fix when it does not match. There is no timestamp, so replay protection is core's event-id dedupe plus the live verify; a replay cannot create a second order or an order Flutterwave does not confirm.charge.completed:<transaction id>:<status>andrefund:<refund id>:<status>. A repeat or overlapping delivery runs once. When confirmation fails, core releases the record, so Flutterwave's retry still creates the order.POST /v3/transactions/:id/refundwith(refundRequestId=<id>)at the end ofcomments. Flutterwave takes no idempotency key, so the package lists refunds and returns any non-failed refund already tagged with that request id instead of creating another. A reason cannot pose as a tag (brackets are stripped and the tag is anchored at the end). Atx_refis resolved to the numeric id first. Everycompleted*status maps to succeeded,pending-*/processingto pending,failedto failed.eventfield and capitalisedAmountRefunded/FlwRef/TransactionId. That maps torefund.updatedby the refund id, with each status a separate event id sopendingnever blockscompleted.GET /v3/balancescall and reports test or live mode from the key prefix.mobile_moneyresolves by currency (KES→mpesa,GHS→mobilemoneyghana, …). With no hint, Flutterwave shows what the account has enabled.Deliberately not included
FLWPUBK-…); core stores onlysecretKey/webhookSecretand gives providers no KV access. The public and secret keys do not share a hash segment (checked with a real pair), so the key cannot be derived. Hosted checkout is the equivalent flow today; Inline needs a core credential field first. The package declarescheckoutStyles: ["hosted"]rather than shipping a dead client.connect: falsemakes checkout refuse rather than silently drop a split.falsefor the same reason.Package
publishConfig.access: public, author "DashCommerce contributors". A minor changeset takes it to 0.1.0 beside core 0.4.0.bun.lockgains only the new workspace entry.Tests
charge.completedoutcomes, metadata as object and JSON string, draft recovery fromtx_ref, wrongverif-hash, amount mismatch (order held withpaymentAmountMismatch), verification outage then a successful retry, pending verification (no order), replay, refund retry guard, a failed refund retried, a new request id creating a new refund, the refund webhook moving a pending row to succeeded, and the settings API acceptingFLWSECK_TEST-while refusingFLWPUBK_.bun run typecheckpasses across the monorepo;biome checkis clean on the new files.End to end in Flutterwave test mode (24 Nov 2026)
Nigerian test account, KES wallet, test keys only.
GET /v3/balancesviacheckConnectionPOST /v3/paymentsviainitCheckoutdc-<draftId>;{CHECKOUT_SESSION_ID}strippedcheckout-v3.flutterwave.com;callbackreturnedsuccessful, transaction id10633588tx_refgetPaymentStatusreportedsucceeded,150000minor units, KESstatus: "completed"; the(refundRequestId=…)comment came back exactly as sent115050); verify still reportssuccessful400 "A partial refund is currently processing on this transaction"; surfaced, not swallowedGET /v3/refunds400 {"message":"unauthorized"}on this key, while refund creation worksWhat the run changed: the refund duplicate check now degrades to a logged warning when refund history is not available to the key, instead of blocking every refund;
meta.disburse_status: "failed"is logged becausecompletedcan mean "accepted, not yet paid out"; Flutterwave's one-partial-at-a-time rule is documented; and the README records that verify stayssuccessfulafter a refund.Still to run before release: 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), a declined payment, and the replay/verif-hashmatrix against the starter.Review notes
GET /v3/refunds) and not filterable by transaction, so the duplicate guard walks up to 20 pages (400 recent refunds) and logs when it stops. A retry is always near the top because the list is newest-first. On keys where the endpoint answersunauthorized, the guard is skipped with a warning, so a retried refund can duplicate there.data.idis the refund id or the transaction id; the OpenAPI example, the list endpoint and the refund webhook all treat it as the refund id, which is what the package relies on.