Repository navigation
Recurring payments: record the gateway reference at checkout and ignore reports on another one - #1082
Merged
KrzysztofPajak merged 2 commits intoNov 22, 2026
Conversation
…re reports on another one A provider can now record the gateway's reference of a recurring payment as soon as it learns it (RecordRecurringPaymentReferenceCommand), under the recurring payment's lock. A cancel made before the first paid cycle then stops the gateway at once; a payment cancelled before the reference was known is stopped when the reference arrives. The cycle, failure and ended reports are checked against the recorded reference: a report on another subscription (for example a second one started for the same order) records nothing and leaves a note on the initial order. RecordRecurringPaymentEndedCommand gains ProviderReference.
…other subscription The recurring payment service now returns the outcome of every gateway report (Recorded, NotFound, Duplicate, OtherReference, Ended) with the payment it read under the lock, so the provider commands no longer read it again to guess why nothing was recorded. - The first reported reference is recorded whichever report brings it: a failure or an end reported before the reference was known now records it, as a paid cycle already did. - The reference command stops the gateway of an ended payment only when it records the reference, so a resent checkout event no longer asks the gateway to cancel again. - A failure on an ended payment records the missing reference under the lock before the gateway is asked to stop, instead of patching it in memory. - A paid cycle, a failure or a reference reported on another subscription asks the provider to stop that subscription and leaves one note per report on the initial order; another subscription that ended is only logged. - RecordRecurringPaymentFailureCommand returns true when the failure was recorded, also while the payment is already past due.
KrzysztofPajak
deleted the
feature/recurring-payments-provider-reference
branch
November 22, 2026 07:44
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
Two shop-side pieces the Stripe stage needs (stacked PR on top: Stripe subscriptions).
RecordRecurringPaymentReferenceCommand— a provider records the gateway's reference (the subscription id) as soon as it learns it, typically when the customer completes the checkout, before the first paid cycle is reported.IRecurringPaymentService.RecordProviderReferencewrites it under the recurring payment's lock and keeps a reference recorded already.Pending, now asks the gateway to stop (until now aPendingpayment without a reference was cancelled in the shop only, and the first cycle report stopped the gateway).RecordRecurringPaymentEndedCommandgainsProviderReference;RecordFailure/RecordEndedtake it.Calls made (please check)
Tests
Grand.Business.Checkout.Tests: 1109 passed (service tests on the Mongo test repository + handler tests with mocks).