feat: add one-off charge support (POST /billing/payments/charge/)#11
Merged
Conversation
Adds a builder for `POST /billing/payments/charge/` (one-off charge) alongside the existing recurring builder. Items omit the recurring-only `Duration_Months` and `Recurrence` fields; everything else (Credentials, Customer envelope, SingleUseToken, VATIncluded, OnlyDocument, AuthoriseOnly) is shared via a small `baseChargeEnvelope` helper. Response normalization is unchanged — the existing logic already handles both shapes since one-off and recurring responses share the `Payment.*` envelope. Exposed as `normalizeChargeResponse` to make the one-off use case discoverable; `normalizeRecurringChargeResponse` stays as an alias for back-compat. Updated README, CLAUDE.md, and API reference. All 16 tests pass. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
3 tasks
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.
Summary
Adds
buildOneOffChargePayloadfor SUMIT's one-off charge endpoint (/billing/payments/charge/), alongside the existing recurring builder. The sameSingleUseTokenproduced by<SumitCheckout />works for both endpoints.What's new
buildOneOffChargePayload(params)— builds the one-off request body. Items includeItem.Name/Item.Description,Quantity,UnitPrice,Currency— noDuration_Months/Recurrence.normalizeChargeResponse(response)— exposes the existing normalizer under a name that reflects what it actually does (handles both one-off and recurring responses).normalizeRecurringChargeResponseis kept as an alias for back-compat.baseChargeEnvelopehelper to keepCredentials/Customer/SingleUseToken/VATIncluded/OnlyDocument/AuthoriseOnlyconsistent across builders.OneOffChargeItem/RecurringChargeItem/BuildOneOffChargePayloadParams/SumitOneOffChargePayload.Why
Response normalization was already provider-shape-agnostic, so the only real gap was the request builder. A one-off success now naturally surfaces as
eventType: "payment.succeeded"(norecurringItemId).Test plan
pnpm test— 16/16 passing (3 new tests: one-off payload shape, alias identity, one-off success normalization)pnpm typecheckcleanpnpm buildcleanFollow-up (separate PR)
sumit-react'screateSumitChargeRoutewill get amode: "recurring" | "oneOff"option that switches both the builder and the upstream URL.🤖 Generated with Claude Code