Repository navigation
Recurring payments: record, provider contract and checkout rules (slice 1 of 5) - #1075
Merged
Merged
Conversation
added 4 commits
November 20, 2026 08:23
…s for a recurring cart
…recurring payment write from leading to a second order - RecurringPaymentRuleProvider blocks a recurring order with nothing to pay or with a payment method that cannot charge in cycles, at the payment step, the confirm step and order placement alike - the recurring payment is written after the cart is cleared - a guest with a recurring product is sent to log in from the cart and the checkout - IRecurringPaymentService.HasRecurringProducts is the one recurring-cart check - the recurring message is no longer replaced by the approval one; no account warning on a wishlist - unique InitialOrderId index; CyclesPaid counts cycles the provider reported, the first one included
This was referenced Nov 20, 2026
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.
Type: feature
Issue
A product can be marked recurring (cycle length, period, total cycles), and the admin and the cart show it as "billed every N months", but the shop charges once and nothing repeats: no payment method can run a schedule, and nothing records one. Any payment method is offered for such a cart, so the customer is promised cycles the shop never charges.
This is slice 1 of 5 of recurring payments (payments roadmap P5). The provider (gateway) runs the schedule; the shop records what it reports.
Solution
RecurringPaymentcollection (store, customer, initial order, payment method, cycle, cycles paid, statusPending/Active/PastDue/Cancelled/Completed, provider reference, last error, embedded paid cycles).OrdergetsInitialOrderId(set on cycle orders, later slice) andRecurringCycleNumber(1 on the initial order of a recurring payment, 0 otherwise).IRecurringPaymentServicewith insert, update, get by id, get by initial order, andHasRecurringProducts(cart), the one recurring-cart check.Order.RecurringUseCyclesis left untouched.IPaymentProvider.SupportRecurringPayment()(defaultfalse) andCancelRecurringPayment(RecurringPayment)(default: error result), as default interface members, so every existing payment plugin compiles and behaves unchanged.IPaymentService.SupportRecurringPayment(systemName).ShoppingCartWarningsValidator), so the cart page, the checkout and order placement all enforce it. Not on a wishlist, which buys nothing. Checkout from the cart, and the checkout pages, send such a guest to log in (back to the cart afterwards).SupportRecurringPayment()istrue. When none is left, the payment step shows why, and an approval rule no longer replaces that reason.RecurringPaymentRuleProvider, blocks a recurring order with a total of 0 (full discount, gift voucher, loyalty points) or with a method that cannot charge in cycles (a stale tab or a crafted post). Being a rule, it is checked wherever the rules are: when a payment method is saved, on the single-method shortcut, on the confirm step (shown before Confirm), and authoritatively at order placement, before any claim or payment.PendingRecurringPaymentis created for it (cycle copied from the order;TotalCycles = 0stays 0, meaning until cancelled). Written after the cart is cleared, so a failed write cannot leave a full cart for a second paid order. It exists before the provider's post-process step, so a provider can pass its id to the gateway.CyclesPaidstays 0 until the provider reports the first cycle (the initial order's payment), even when the initial order is already paid; the provider contract says it reports every cycle, the first one included.Consequence: until a provider supports recurring payments (slice 2: Stripe subscriptions), recurring products cannot be bought. Slices 1 and 2 should reach the same release.
Persisted data:
RecurringPayment, unique indexInitialOrderIdin the installer and inMigrationRecurringPaymentIndex(2.5).DefaultLanguage.xmlandUpgrade/en_250.xml:ShoppingCart.RecurringProductsRequireAccount,Checkout.RecurringPayment.NoPaymentMethod,Checkout.RecurringPayment.PaymentMethodNotSupported,Checkout.RecurringPayment.NothingToPay.Breaking changes
IPaymentServicehas a new memberSupportRecurringPayment(string). This only affects custom implementations of the service, not payment plugins.ShoppingCartWarningsValidator(IGroupService),GetPaymentMethodHandler,PlaceOrderCommandHandler,CheckoutControllerandShoppingCartController(IRecurringPaymentService). This only affects code that subclasses or constructs them by hand.IPaymentProvideris not broken: the new members have defaults.Testing
RecurringCycleNumber = 0and theRecurringPaymentcollection is empty.SupportRecurringPayment() => true: place an order for the recurring product.RecurringPaymentholds onePendingdocument withInitialOrderId= the order id,TotalCycles = 0andCyclesPaid = 0. The order hasRecurringCycleNumber = 1.InitialOrderIdindex exists onRecurringPayment, and the four resources are present.Automated:
dotnet build GrandNode.slnx(0 errors);Grand.Business.Checkout.Tests972/972,Grand.Web.Tests624/624,Grand.Modules.Tests420/420.