wealth/docs/decisions/0030-checkout-draft-survive...

1.2 KiB

0030 The last checkout's period and code survive the bank

Status: Proposed · Area: architecture · Date: 2026-10-08 · Decided by: agent

Context

Back from the gateway and «تلاش دوباره» on a failed result must reopen checkout with the same period and invite code (U10 ۶.۳, ۹.۲). The browser leaves the app for the bank, so memory is lost unless bfcache keeps the page.

Decision

  • stores/checkout-draft is a persisted zustand store, session.checkout-draft, holding one { creatorId, tierId, referralCode, paymentId }; paymentId is the payment sent to the bank, kept until it is settled (0033).
  • startCheckout and startRenewal write it once a payment exists (redirect or grant); the result page clears it on success; checkout restores it once, for the same creator, when the form is untouched; logout clears it.
  • A page restored from bfcache resets its pay button and reads its screen again (pageshow).

Alternatives

  • Period and code in the URL: an invite code would land in history, logs and shares.
  • Ask the API to return the code with the payment: not available.

Consequences

  • The invite code sits in local storage until success or logout; it is a creator's shared invitation, not personal data.