feat(gateway,core): recurring/subscription payment flows - #48
Merged
aguilar1x merged 12 commits intoJul 19, 2026
Conversation
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 a recurring/subscription payment primitive to Connect, so merchants with subscription business models can charge on a schedule through Pacto. Closes #41.
A subscription is a DB-backed plan (amount, interval, asset, FX pair) tied to a merchant + payer. A polling scheduler creates a new escrow on each billing cycle, reusing the quote engine (#18) for FX pricing at charge time, and the subscription lifecycle is surfaced through the existing signed-webhook pipeline. Test mode only for now (live returns
501 not_implemented, consistent with escrows).What's included
Subscription+SubscriptionChargePrisma models, enums, and a migration.subscriptions/charge.ts) — re-prices viacreateQuote(), creates an escrow via the test-mode simulator, records the charge, emits events, with bounded retry (SUBSCRIPTION_MAX_ATTEMPTS, default 3) →past_due+ stop.subscriptions/runner.ts) — polling runner mirroring the webhook delivery runner; wired intoindex.ts./v1/subscriptions— create / retrieve / list / cancel (session-scoped auth like escrows; idempotency on create).subscription.created,subscription.charged,subscription.failed,subscription.canceledthrough the existingdispatchEvent()pipeline./v1/test/subscriptions/:id/advance(deterministic synchronous charge) and/fail-next(simulate insufficient funds).subscriptionsresource (create/retrieve/list/cancel) + test-mode helpers in@pacto-connect/core.WEBHOOKS.md.Acceptance criteria
TESTMODE_SUB_INTERVAL_MS);advanceprovides a deterministic path for tests.subscription.failedand does not retry indefinitely — bounded retry with backoff, thenpast_due+ a singlesubscription.failed; the runner never re-selects a non-activesubscription.subscription.canceled— cancel is terminal and the event is emitted exactly once, only on a realactive → canceledtransition.Testing
type-checkclean (8/8 workspaces);biome checkclean.Notes / scope