Repository navigation
Send reservationId on settle and map final 409 hold refusals - #8
Merged
Merged
Conversation
0.2.0 is still unpublished, so this stays on that version. A reservation id from reserve, an approval, or the caller is sent on settle. Final hold refusals are errors you do not retry with a new idempotency key. settlement_unknown and an unrecognized 409 stay retryable with the same key. Co-authored-by: splinterone <splinterone@users.noreply.github.com>
The machine code is code, then errorReason, then error. 404 reservation_not_found is a final refusal. reservation_awaiting_approval stays pending and tells you to retry the same idempotency key. settlement_unknown keeps retryAfterMs. Co-authored-by: splinterone <splinterone@users.noreply.github.com>
splinterone
marked this pull request as ready for review
October 8, 2026 07:45
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 this is
Draft only. Not merged, not published. Still 0.2.0, because that version is not on npm yet (0.1.1 is the published one).
When you have a reservation id, settle sends
reservationId. Optional onwardpass_settle_paymentand onWardPassClient.settlePayment. Leave it out and the field is absent.How a settle response is read
The gateway puts the machine code in
codeand a reason inerrorReason. Example:409 { success: false, errorReason: "settlement_in_progress", code: "settlement_unknown", idempotencyKey, retryAfterMs }. This client mapscode, thenerrorReason, thenerror, so an older gateway that only senterrorstill works.reservation_awaiting_approvalreservationIdis passed through.settlement_unknownoutcome_unknown. Retry only with the same idempotency key.retryAfterMs, when present, is how long to wait.settlement_in_progresson an older body)outcome_unknown. Same retry rule.isError, plain English, one request. Do not invent a new idempotency key.reservation_not_foundFinal 409 codes:
reservation_already_settled,reservation_released,reservation_expired,reservation_not_open,reservation_passport_mismatch,reservation_bound_to_other_payment,amount_exceeds_hold,amount_below_hold,reservation_agent_mismatch. A later gateway may answer another agent's id with the same 404reservation_not_found. Both stay final.HTTP 200 failure bodies stay denials. A screening miss or a per-payment cap refusal is not an unknown outcome.
Tests
node --test: 35 passed, 0 failed. That covers each final code, 404reservation_not_foundwith areservationId,reservation_awaiting_approvalas pending, thecode/errorReason/errororder, andretryAfterMsonsettlement_unknown. No network. CI is Node 18 and 20.What a 0.1.1 user would notice
Nothing, until they upgrade.
screenBeforeSettleandassertScreenAlloware unchanged. 0.1.1 has no settle helper.