Skip to content

Recurring payments: Admin and Store screens, order links and menu (slice 5 of 5) - #1079

Merged
KrzysztofPajak merged 5 commits into
developfrom
feature/recurring-payments-admin
Nov 22, 2026
Merged

KrzysztofPajak merged 5 commits into
developfrom
feature/recurring-payments-admin

Conversation

@KrzysztofPajak

Copy link
Copy Markdown
Member

Type: feature

Issue

Slices 1–4 (#1075–#1078) record recurring payments, react to the gateway, cancel them and show them to the customer. Staff still have no screen for them:

  • no list;
  • no way to see the last failure;
  • no Cancel button;
  • no link on the order screen between a cycle order and the order the customer placed.

This is slice 5 of 5 of recurring payments (payments roadmap P5): the Admin and Store panels.

Solution

Sales → Recurring payments (Admin and Store)

  • BaseRecurringPaymentController lives in AdminShared, with thin Admin and Store subclasses. It follows the shape of the payment transaction screens.

    • It runs under the existing Orders permission (List, Preview and Cancel actions). There is no new permission.
  • List. Filters:

    • a quick search by customer e-mail;
    • a status filter;
    • a store filter, in the Admin only.

    Columns:

    • customer;
    • status chip;
    • cycle ("Every month");
    • payments made;
    • next payment, shown only while the gateway is still charging;
    • initial order, linked unless the order is deleted;
    • store, in the Admin only;
    • created on.
  • Details. The screen shows:

    • status, customer, initial order, store and payment method;
    • provider reference, cycle and payments made;
    • next payment, and cancelled on/by;
    • a Last error card when the last cycle failed;
    • the paid cycles, each linked to its order.
  • Cancel. The button is outline danger and asks for confirmation first. It sends the existing CancelRecurringPaymentCommand, with the staff member as CancelledBy.

    • Staff see the provider's own refusal text. Customers still get the fixed message from slice 4.
  • GetRecurringPaymentsQuery. A new query in Grand.Business.Core, with its handler, sorted newest first. It filters by:

    • store;
    • status;
    • customer e-mail: an exact match over every account with that e-mail, so per-store identities are included;
    • sales employee, through the initial orders.

Who sees what

  • Store panel. The recurring payment's StoreId must match the staff member's store, whatever the list posts or the URL says.
    • A crafted Edit or Cancel of another store's payment redirects to the list and changes nothing.
  • Every detail action also requires IAdminDataScope<Order>.HasAccess on the initial order, so the order screen's rule applies here too.
    • A sales manager has the Orders permission by default. They see only the recurring payments of their own orders.
    • The list narrows by SeId, the same way the order list does.
  • Missing initial order. A recurring payment whose initial order is missing is shown to no one. Orders are soft-deleted, so such a record is broken.
  • Vendor panel. Nothing, as the spec says.

Order screen

  • The initial order shows "Recurring payment → View the recurring payment".
  • A cycle order shows "Recurring payment of order N" and its cycle number. The order number is linked unless that order is deleted.
  • From the recurring payment screen, the cycle table links every cycle order, so the link works in both directions.
  • OrderViewModelService.PrepareOrderRecurringPayment prepares these fields. It is skipped in the Vendor panel.

Persisted data

  • Menu. "Recurring payments" goes under Sales, right after Payment transactions:
    • in StandardAdminSiteMap, where the later entries move down by one;
    • in MigrationRecurringPaymentMenu (2.5), for existing installations. The migration is idempotent, and a menu without a Sales section gets nothing.
  • Resources. 34 resources go into DefaultLanguage.xml and en_250.xml.
    • The cycle and payments-made texts reuse slice 4's RecurringPayment.Cycle.* and RecurringPayment.CyclesPaid.*.

Breaking changes

  • OrderViewModelService takes one more constructor argument (IRecurringPaymentService).

Testing

Automated:

  • dotnet build src/Web/Grand.Web → 0 errors.
  • Grand.Web.Admin.Tests 2097/2097.
  • Grand.Web.Store.Tests 245/245.
  • Grand.Modules.Tests migration tests 101/101.
  • GetRecurringPaymentsQueryHandlerTests 6/6.

The new tests cover:

  • the query: store, status, exact e-mail across accounts (and an unknown e-mail), sales employee, sort order;
  • the controller:
    • the Store panel forces its own store;
    • the Admin passes the posted store, status, e-mail and page;
    • sales employee narrowing;
    • row mapping and cycle links;
    • another store's payment, and one whose initial order is out of scope, redirect to the list;
    • Cancel is refused out of scope and for an ended payment;
    • Cancel names the staff member;
  • the order screen links: initial order, cycle order, deleted initial order, ordinary order, Vendor panel;
  • the menu migration: placement after Payment transactions, the shift of later entries, idempotence, no Sales section;
  • routing: the Admin and Store controller attributes.

E2E on a throwaway installation (Mongo, sample data, Playwright): 31/31 checks pass.

Setup:

  • One order was placed through checkout.
  • A seed script turned it into an initial order with a cycle order.
  • It added three recurring payments: a PastDue one, a Pending one and one from another store.
  • It added a store manager and a sales manager.

Results:

  1. Admin list. The menu entry is there and the list has 3 rows.
    • The status filter gives 1 row, the store filter 2.
    • An unknown e-mail gives 0 rows, a known e-mail typed in a different case gives 3.
  2. Details. The Last error card shows, the cycles link to both orders, and the initial order is linked.
  3. Refused cancel. The Cash on delivery payment has a provider reference. Cancel shows "Recurring payment method not supported", and the status stays Payment failed.
  4. Cancel without a reference. Cancelling the Pending payment, which has no reference, sets it to Cancelled by the staff e-mail. The Cancel button is gone.
  5. Order screens. The initial order links its recurring payment, and the cycle order links the initial order.
  6. Store manager.
    • The list has 2 rows, with no other-store row and no store filter.
    • Opening another store's details redirects to the list, and so does a crafted Cancel POST. That payment is still Active afterwards.
    • Links stay in the Store panel.
  7. Sales manager with no orders. The list is empty, and opening details redirects to the list.
  8. Console. Clean in the Admin and Store panels.

Copilot AI balanced review requested due to automatic review settings November 21, 2026 15:37

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

query = query.Where(x => x.StoreId == request.StoreId);

if (request.Status.HasValue)
query = query.Where(x => x.Status == request.Status.Value);
Comment on lines +53 to +57
catch (Exception ex)
{
logService.LogError(ex, "UpgradeProcess - RecurringPaymentMenu (2.5)");
return false;
}
Comment on lines +30 to +34
catch (Exception ex)
{
logService.LogError(ex, "UpgradeProcess - RecurringPaymentCreatedOnIndex (2.5)");
return false;
}
@KrzysztofPajak
KrzysztofPajak merged commit 2af0e74 into develop Nov 22, 2026
9 checks passed
@KrzysztofPajak
KrzysztofPajak deleted the feature/recurring-payments-admin branch November 25, 2026 09:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants