fix(storefront): show unpaid payment state and continue CTA on profile#302

merged2
payment-addorder-reuse
payment-profile-cta
openedAug 29, 2026byAAviddaram
View on GitHubTwo-way sync enabledPR last imported 19d ago

Profile order cards hid Payment state, so unpaid attempts looked like normal purchases with no next step.

Load the latest Payment on each order, badge from Payment status (Төлөөгүй / Шалгаж байна / Төлсөн), map Order created, and add a continue-payment CTA for pending or claimed rows.

Depends on #301. Stack: #300 → #301 → #302

Test plan

  • Profile with a pending Payment order shows Төлөөгүй and Төлбөр үргэлжлүүлэх
  • Claimed payment shows Шалгаж байна + continue link
  • Paid order has no continue CTA
  • Continue link opens /payment/{paymentNumber}

Checks

4 successful · 1 skipped
All checks passed
64d5523
Synced from GitHub

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

🗂️ Base branches to auto review (1)
  • v2

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 93615a5c-1e54-414e-88dc-bd167b15ddb6

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Synced from GitHub

Greptile Summary

This PR adds the latest non-deleted payment details to profile-order responses and uses them to display payment badges and continuation links.

  • Loads payments in descending creation order and exposes the latest payment number, status, and provider.
  • Replaces profile order badges with payment-state badges when payment data exists.
  • Adds a continuation CTA for pending and customer-claimed payments.

Confidence Score: 4/5

The PR should not merge until payment badges and continuation links are suppressed for cancelled and refunded orders.

Independently editable order and payment statuses allow a cancelled or refunded order to retain an open payment, after which the profile presents it as payable and routes the customer to still-enabled payment actions.

Files Needing Attention: apps/storev2/src/pages/profile.astro

Important Files Changed

FilenameOverview
apps/storev2/src/pages/profile.astroAdds payment badges and continuation links, but fails to gate payment presentation and actions on the order lifecycle state.
packages/api/src/queries/orders.tsLoads non-deleted payments newest-first alongside profile orders using the repository's established latest-payment ordering.
packages/api/src/routers/store/order.tsShapes the latest loaded payment into nullable profile-order response fields.

Sequence Diagram

mermaid
1sequenceDiagram
2 participant Admin
3 participant API
4 participant Profile
5 participant Customer
6 participant PaymentPage
7 Admin->>API: Save cancelled/refunded order with pending payment
8 API-->>Profile: Order status plus latest payment status
9 Profile-->>Customer: Show unpaid badge and continue CTA
10 Customer->>PaymentPage: Continue payment
11 PaymentPage-->>Customer: Present payment actions

Reviews (1): Last reviewed commit: "fix(storefront): show unpaid payment sta..." | Re-trigger Greptile

Cchatgpt-codex-connectorBotreviewed · 1 inline threadAug 29, 2026
Synced from GitHub

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a1aeeddf81

ℹ️ 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".

apps/storev2/src/pages/profile.astroline 191Outdated · a1aeeddOpen thread
……@@ -171,11 +188,19 @@ const statusLabels: Record<string, string> = {
176- >
177- {statusLabels[order.status]}
178- </span>
191+ {order.paymentStatus ? (

P1 Badge Keep fulfillment status visible after payment

For every order with a Payment—including all successfully paid orders—this condition selects the payment badge and suppresses the order badge. Consequently, a paid order continues to display only “Төлсөн” even when its order status advances to shipped, delivered, cancelled, or refunded, so customers lose fulfillment tracking on the profile page. Let payment state override the order state only while the order is actually awaiting payment, such as when order.status === "created".

Useful? React with 👍 / 👎.

Fixed: payment badge only when order.status === \"created\". After pay/fulfillment, Order status shows again.

apps/storev2/src/pages/profile.astroline 267Outdated · a1aeeddOpen thread
……@@ -238,6 +263,15 @@ const statusLabels: Record<string, string> = {
239264 </div>
240265 )}
266+
267+ {canContinuePayment(order.paymentStatus) && order.paymentNumber && (
Ggreptile-appsBoton line 267Aug 29, 2026

P1 Cancelled orders remain payable

When an order is cancelled or refunded while its latest payment remains pending or claimed, this condition still displays the continuation CTA and the payment badge hides the order state, causing customers to see a non-payable order as unpaid and access payment actions for it.

Fixed: continue CTA requires order.status === \"created\" plus pending/claimed Payment.

Added 2 commits

  • fix(storefront): only show payment badge and CTA while awaiting pay64d5523
  • fix(storefront): show unpaid payment state and continue CTA on profile91b5b7c