Repository navigation
Feat/fedapay error reasons - #6
Merged
Merged
Conversation
To check that a real USSD prompt reaches a phone. Real money, so: - explicit opt-in (DEMO_LIVE=yes) and a separate FEDAPAY_LIVE_SECRET_KEY; a sandbox key is refused in live mode and a live key in sandbox mode - amounts capped by DEMO_LIVE_MAX_AMOUNT (default 200, at most 1000 XOF) - warning in the terminal and on the page - the server now only listens on 127.0.0.1 Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Signed-off-by: Jules Mahounou <234069818+jules-mahounou@users.noreply.github.com>
Found with the founder's first live payments (2026-10-05): - a canceled MTN payment carried `last_error_code: INSUFFICIENT_FUND_ERROR`, but Payenv only reported a generic CUSTOMER_DECLINED; - a Celtiis payment canceled on the phone stayed `pending` at FedaPay with `last_error_code: API_ERROR`, and Payenv showed no reason at all. core: PayenvError gains `providerCode`, serialized with the error, so every connector can keep the provider's own code. connector-fedapay: map `last_error_code` (INSUFFICIENT_FUND_ERROR → INSUFFICIENT_FUNDS, API_ERROR → PROVIDER_UNAVAILABLE, others kept as providerCode), also on transactions that stay pending. Status is never changed from what FedaPay reports. Tests reproduce both live transactions; verified against them read-only. docs: QUIRKS (verified live), README guidance for payments stuck in pending. demo: shows the reason while pending and what to do after a minute. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Signed-off-by: Jules Mahounou <234069818+jules-mahounou@users.noreply.github.com>
The full live transaction shows that `last_error_message` is the operator's raw SOAP answer: the status query succeeded and the operator still reported `TransactionStatus: "Initiated"`. API_ERROR therefore means "no final status from the operator", not an outage: map it to UNKNOWN_ERROR with an accurate message. The raw dump is kept in `error.raw` (never serialized). QUIRKS: FedaPay schedules an expiration for pending transactions (`metadata.expire_schedule_jobid`, `expired_at`). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Signed-off-by: Jules Mahounou <234069818+jules-mahounou@users.noreply.github.com>
A live `transaction.canceled` webhook showed the shape
`{ name, object, object_id, account, entity }`, where `entity` is the
full transaction. `parseFedaPayWebhook` normalizes it with the same
mapping as status lookups, deriving the status from the transaction
rather than the event name, so unknown event names still work.
- INSUFFICIENT_FUND_ERROR message now reflects MTN's actual reason
(low balance, or a limit reached, or not allowed)
- demo: a verified webhook triggers payenv.refresh (webhooks are hints);
verified end to end with a signed and a forged webhook
- QUIRKS: webhook shape, and a warning that webhooks carry merchant and
payer personal data
Test fixtures are scrubbed of account details, phone numbers and tokens.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Signed-off-by: Jules Mahounou <234069818+jules-mahounou@users.noreply.github.com>
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.
What & why
Checklist
git commit -s) — see DCOCHANGELOG.md(Unreleased) updated if behavior changed