diff --git a/.env.example b/.env.example index 5d7c785..a281c39 100644 --- a/.env.example +++ b/.env.example @@ -1 +1,5 @@ VITE_ORGANIZATION_ID= + +# Manual UPI payments shown on the order page (QR image goes in public/upi-qr.png) +VITE_UPI_ID= +VITE_UPI_NAME=Mani Candles diff --git a/README.md b/README.md index 2e892ce..83b37b2 100644 --- a/README.md +++ b/README.md @@ -36,3 +36,16 @@ See [delivery phases](docs/PHASES.md) and [UAT evidence](docs/UAT-RESULTS.md). Phase 2 commands: `npm run check` runs lint, strict types, contract/component/workflow tests and the measured production build. Dependency security is checked with `npm audit --audit-level=high` in CI. See [Phase 2 evidence](docs/UAT-PHASE2.md) and [release checklist](docs/RELEASE-CHECKLIST.md). Set the backend RECOVERY_URL to your HTTPS frontend /reset-password route. Pending checkout and stock commands survive navigation within an active session; reload discards local credentials and intents. If interrupted, check orders/ledger before starting a new command. + +## Cash on delivery and UPI + +Checkout requires a payment method. Cash on delivery confirms the order at once. UPI orders wait up to 48 hours: the order page shows the exact payable total, the UPI ID and QR code, and a form for the customer's UTR. Staff confirm the payment, then record shipment (courier and tracking note, shown to the customer) and delivery under Admin orders. + +Set these at build time (for example in `.env.production.local`, which is not committed): + +```sh +VITE_UPI_ID=yourname@bank +VITE_UPI_NAME=Mani Candles +``` + +Put the QR image for that UPI ID at `public/upi-qr.png` before building. Without `VITE_UPI_ID` the order page asks the customer to contact you instead. Tax and shipping must be configured as an active pricing policy, or paid checkout is refused. diff --git a/docs/RELEASE-CHECKLIST.md b/docs/RELEASE-CHECKLIST.md index acd0a5b..ad9e89a 100644 --- a/docs/RELEASE-CHECKLIST.md +++ b/docs/RELEASE-CHECKLIST.md @@ -38,4 +38,4 @@ Record the active and previous build/commit release IDs before rollout. The SSH ## Operational limits -Pending intents exist only within the active browser session; reloading signs out and discards them. After interruption, inspect orders or the stock ledger before beginning a new intent. The backend currently has no live gateway/carrier or contact delivery; customer self-registration is available. Staff catalog/role writes follow the backend's existing concurrency policy; coordinate overlapping administration edits. Never reinterpret finalized merchandise as proof of payment or fulfillment. +Pending intents exist only within the active browser session; reloading signs out and discards them. After interruption, inspect orders or the stock ledger before beginning a new intent. The backend currently has no live payment gateway, carrier integration or contact delivery; cash on delivery and manually confirmed UPI are available; customer self-registration is available. Staff catalog/role writes follow the backend's existing concurrency policy; coordinate overlapping administration edits. Never reinterpret finalized merchandise as proof of payment or fulfillment. diff --git a/src/lib/commerce.ts b/src/lib/commerce.ts index aef9c61..5f35152 100644 --- a/src/lib/commerce.ts +++ b/src/lib/commerce.ts @@ -55,8 +55,14 @@ export const checkoutInput = z addressId: uuid, idempotencyKey: uuid, couponCode: couponCode.optional(), + paymentMethod: z.enum(["COD", "UPI_MANUAL"]).optional(), }) .strict(); +export const paymentReference = z + .string() + .trim() + .toUpperCase() + .regex(/^[A-Z0-9]{6,40}$/, "Enter the 6–40 letter or digit UPI reference (UTR)."); export type CheckoutIntent = z.infer; export function checkoutIntent( input: Omit, @@ -80,7 +86,15 @@ export function moneyTotal(lines: { price: string; quantity: number }[]) { } export const orderSummary = z.object({ id: uuid, - status: z.enum(["PENDING_PAYMENT", "CANCELLED", "EXPIRED"]), + status: z.enum([ + "PENDING_PAYMENT", + "CONFIRMED", + "SHIPPED", + "DELIVERED", + "CANCELLED", + "EXPIRED", + ]), + paymentMethod: z.enum(["COD", "UPI_MANUAL"]).nullable().default(null), currency, merchandiseTotal: decimal, createdAt: z.string(), @@ -94,6 +108,15 @@ export const order = orderSummary.extend({ shippingTotal: decimal.nullable(), payableTotal: decimal.nullable(), paymentAvailable: z.literal(false), + history: z + .array( + z.object({ + status: z.string(), + note: z.string(), + createdAt: z.string(), + }), + ) + .default([]), address: addressInput.omit({ isDefault: true }).strip(), lines: z.array( z.object({ diff --git a/src/pages/CartPage.tsx b/src/pages/CartPage.tsx index 2f8d00f..5795c2b 100644 --- a/src/pages/CartPage.tsx +++ b/src/pages/CartPage.tsx @@ -33,6 +33,7 @@ function Cart() { [error, setError] = useState(null), [addressId, setAddressId] = useState(""), [coupon, setCoupon] = useState(""), + [paymentMethod, setPaymentMethod] = useState<"COD" | "UPI_MANUAL" | "">(""), [uncertain, setUncertain] = useState(Boolean(attempt.current)), [review, setReview] = useState(false); const [reviewedVersion, setReviewedVersion] = useState(null); @@ -86,6 +87,7 @@ function Cart() { cartVersion: reviewedVersion, addressId, couponCode: coupon.trim() ? coupon : undefined, + paymentMethod: paymentMethod || undefined, }, crypto.randomUUID(), ); @@ -246,15 +248,33 @@ function Cart() { inputProps={{ maxLength: 40 }} disabled={busy || uncertain || review} /> + { + setPaymentMethod(e.target.value as "COD" | "UPI_MANUAL"); + setReview(false); + }} + disabled={busy || uncertain || review} + helperText={ + paymentMethod === "UPI_MANUAL" + ? "After placing the order you will see the exact amount and our UPI QR code." + : paymentMethod === "COD" + ? "Pay the courier in cash or UPI when your order arrives." + : undefined + } + > + Cash on delivery + Pay now by UPI (QR code) + )} )} - - Payment collection is unavailable. Creating an order reserves stock; - it does not charge you or confirm fulfillment. - {uncertain ? ( <> @@ -276,8 +296,9 @@ function Cart() { ) : review ? ( <>

- Review the selected address, coupon and cart quantities above. - Confirm to create a pending order using the current server prices. + Review the selected address, coupon, payment method and cart + quantities above. Confirm to place the order at the current + server prices, including tax and shipping.