feat: support one-off charges via mode: oneOff#11
Conversation
`createSumitChargeRoute` previously hardcoded the recurring endpoint and required `item.durationMonths`. It now accepts `mode: "recurring" | "oneOff"` (default `"recurring"` for back-compat). One-off mode: - Targets `POST /billing/payments/charge/` instead of `/billing/recurring/charge/`. - Calls `buildOneOffChargePayload` from sumit-api — Items omit `Duration_Months` / `Recurrence`. - Drops the `durationMonths` validation requirement. Same `<SumitCheckout />`, same `SingleUseToken` — only the route's `mode` changes. Switches the response normalizer to the new `normalizeChargeResponse` alias (was `normalizeRecurringChargeResponse`); behaviour is identical since the underlying logic always handled both shapes. 3 new tests cover the oneOff happy path, the relaxed durationMonths requirement, and the still-enforced recurring requirement. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e744cda233
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| buildOneOffChargePayload, | ||
| buildRecurringChargePayload, | ||
| normalizeRecurringChargeResponse, | ||
| normalizeChargeResponse, |
There was a problem hiding this comment.
Bump required sumit-api version for new imports
This change adds static imports for buildOneOffChargePayload and normalizeChargeResponse, but package.json still allows sumit-api >=0.1.0; any install that resolves an older compatible version will fail module loading before the handler runs (including recurring-only usage) because ESM imports are resolved eagerly. Please raise the peer/dev dependency minimum to the first sumit-api release that exports these symbols so consumers do not hit runtime/boot-time import errors.
Useful? React with 👍 / 👎.
Summary
Adds one-off charge support to
createSumitChargeRoutevia a newmodeoption, paired with the new builder/alias landing in sumit-api#11 (`buildOneOffChargePayload` + `normalizeChargeResponse`).What's new
```ts
createSumitChargeRoute({
companyId,
apiKey,
mode: "oneOff", // default "recurring" — back-compat
onResult,
});
```
The same `` and `SingleUseToken` work for both — only the route's `mode` changes. The validator no longer requires `durationMonths` in one-off mode but still requires it in recurring mode.
Internally, response normalization switched from `normalizeRecurringChargeResponse` to its new alias `normalizeChargeResponse` (same function, clearer name).
Test plan
Depends on
sumit-api#11 — must merge first since this PR imports the new `buildOneOffChargePayload` and `normalizeChargeResponse`.
🤖 Generated with Claude Code