Phase 4 Stage 3: payment shell (multi-screen flow)

Six new screens under /payment/* + a paymentDraftProvider holding
mode/durationId/durationMinutes/priceIDR/paymentId/isFirstSessionDiscount
across the flow. PaymentEntryScreen handles the routing decision
(eligible+enabled -> /payment/discount-paywall, else /payment/method-pick)
and clears the draft on fresh entry.

Screens:
- discount_paywall_screen: S6 first-session discount with struck-through
  gimmick price + actual price + 'mulai · Rp{actual}' CTA -> /payment/method
- method_pick_screen: chat vs call cards
- duration_pick_screen: tier list with chat|call mode toggle that resets
  the selection on swap
- payment_method_screen: QRIS-first list, posts to existing
  /api/client/payment-sessions with mode/duration/price/discount/method
- waiting_payment_screen: qr_flutter QR (encodes paymentId in mock mode),
  20-min countdown header, 3s polling for status, pauses on background
  via WidgetsBindingObserver
- payment_expired_screen: retry CTA -> /payment/method with draft retained

Status mapping: real payment_sessions.status uses 'confirmed'/'consumed'
for paid (not 'paid' as in plan) and 'expired'/'abandoned' as terminal.

home_screen 'Mulai Curhat' CTA now pushes /payment/entry.

Dev-only /internal/_test/force-expire-payment endpoint to drive Maestro
flow 04_payment_expired.yaml without waiting 20 minutes. Gated behind
NODE_ENV !== 'production'.

chat_opening_provider PricingData extended to carry Phase 4 chat/call
groups + firstSessionDiscount, back-compat with the Phase 3 shape.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-10 16:28:59 +08:00
parent 2645bcd0e5
commit 706149c75e
19 changed files with 2209 additions and 15 deletions

View File

@@ -0,0 +1,94 @@
# Stage 3 acceptance: drive a payment session into the expired state and
# verify the expired screen renders.
#
# Flow:
# home → tap CTA → /payment/entry → /payment/method-pick (or
# discount-paywall — both arrive at /payment/method) → /payment/method →
# tap bayar → /payment/waiting/:id → force-expire via dev endpoint →
# poller transitions to /payment/expired/:id.
#
# Pre-req:
# 1. The customer is already onboarded + on /home (run flow 01 first, or
# launchApp with clearState=false on a state past onboarding).
# 2. At least one mitra is ONLINE on the target backend (so the CTA is
# enabled). Use mitra_app or the manual seed.
# 3. Backend reachable at BACKEND_INTERNAL_URL with NODE_ENV != 'production'
# (so the _test routes register).
#
# Run:
# maestro test client_app/.maestro/flows/04_payment_expired.yaml
appId: ${APP_ID_ANDROID}
env:
BACKEND_INTERNAL_URL: http://localhost:3001
---
- launchApp:
clearState: false
- assertVisible: "Mulai Curhat"
# Step 1: tap CTA — home routes to /payment/entry which decides the next leg
# based on first-session-discount eligibility.
- tapOn: "Mulai Curhat"
# Step 2: regardless of which entry path was chosen, the customer ends up at
# /payment/method-pick (non-eligible) or /payment/discount-paywall (eligible).
# Both have a way forward to /payment/method. Wait for either landmark.
- extendedWaitUntil:
visible:
text: "pilih cara curhat|sesi pertama|pilih durasi"
timeout: 10000
# Step 3: pick chat (if on method-pick) and a tier (if on duration-pick),
# or tap mulai (if on discount paywall). Each branch funnels into
# /payment/method.
- runFlow:
when:
visible:
text: "pilih cara curhat"
commands:
- tapOn: "chat"
- extendedWaitUntil:
visible:
text: "pilih durasi"
timeout: 5000
- tapOn:
text: "5 menit"
retryTapIfNoChange: true
- tapOn:
text: "bayar"
retryTapIfNoChange: true
- runFlow:
when:
visible:
text: "sesi pertama"
commands:
- tapOn:
text: "mulai"
retryTapIfNoChange: true
# Step 4: on the cara-bayar screen, QRIS is preselected. Tap pay.
- extendedWaitUntil:
visible:
text: "cara bayar"
timeout: 10000
- tapOn:
text: "bayar"
retryTapIfNoChange: true
# Step 5: we should now be on the QR/waiting screen. The header shows the
# countdown ("kedaluwarsa dalam"). Force-expire via the dev endpoint.
- extendedWaitUntil:
visible:
text: "kedaluwarsa dalam"
timeout: 10000
- runScript:
file: ../scripts/force_expire_latest_payment.js
env:
BACKEND_INTERNAL_URL: ${BACKEND_INTERNAL_URL}
# Step 6: poller picks up `expired` within ~3s and routes to expired screen.
- extendedWaitUntil:
visible:
text: "pembayaran kedaluwarsa"
timeout: 10000
- assertVisible: "coba lagi"
- assertVisible: "kembali ke home"