Flusso QNTerm — casistiche e step debug

Numeri = debug[].step nelle risposte API (con config.debug=true).

Legenda step

StepChiamata / eventoQuando
#69uid_resolve (body | cookie __utp JWT sub | Bearer)QNTerm / QNTermUpgrade
#70subscription/listGià cliente (type=upgrade + uid)
#71term/change/can (una per ogni change_option)Già cliente — sub attive con option
#73term/get (dettaglio completo per ogni term eleggibile)Già cliente — dopo can ok
#72esito upgrade (type=upgrade oppure type="")Già cliente — fine
#1subscription/listProspect Utente loggato
#3/#4skip / term/change/can su change_optionsProspect Utente loggato — sub active
#5riepilogo decisionProspect Utente loggato — dopo i can
#6offer/term/list (+ publisher/user/access/list per filtro rid)Prospect Guest; Prospect loggato active NO → offer; can ko → offer senza rid attivi (sub + access)

Se uid non è nel body, si legge il cookie __utp (alias _utp) e si usa il claim JWT sub. In risposta: uid_source = body | cookie_utp | bearer | none.

A) Già cliente — type=upgrade + uid

Nessun offer/term/list. Candidati = change_options. Dopo term/change/can ok: #73 publisher/term/get sul term di destinazione (to_term_id), non sul term corrente.

flowchart TD REQ["QNTerm type=upgrade + uid"] --> R69["69 uid_resolve"] R69 --> L70["70 subscription/list"] L70 --> ACT{"Sub attive?"} ACT -->|No| E72A["72 type vuoto - no_active_subscription"] ACT -->|Si| OPT{"change_options?"} OPT -->|No| E72B["72 type vuoto - no_change_options"] OPT -->|Si| C71["71 term/change/can per ogni to_term_id"] C71 --> CAN{"Almeno un can ok?"} CAN -->|Si| G73["73 term/get per ogni term eleggibile"] G73 --> OK72["72 type=upgrade + terms dettagliati"] CAN -->|No| E72C["72 type vuoto - upgrade_not_eligible"]
{ "id": "QN", "type": "upgrade", "uid": "PNIlMQ3nqtmne2o" }

Casistiche

#SituazioneChiamateRisposta
A1 Nessuna sub active #70 → #72 type: "", terms: [], reason no_active_subscription
A2 Sub active ma senza change_options #70 → skip #71 → #72 type: "", reason no_change_options
A3 change_options presenti, tutti i can false/errore #70 → N× #71 → #72 type: "", reason upgrade_not_eligible
A4 Almeno un can ok #70 → N× #71 → N× #73 → #72 type: "upgrade", terms[] da term/get (+ subscription_id)

B) Prospect Utente Guest — senza uid

Solo offer/term/list da config (id × type).

flowchart LR B1["type=offer default"] --> T6["6 offer/term/list offer_id config"] B2["type=upgrade"] --> T6b["6 offer/term/list offer_id upgrade"]
#InputChiamateRisposta
B1{} o type=offerterm/list offertype=offer + terms
B2type=upgrade senza uidterm/list upgradetype=upgrade + terms

C) Prospect Utente loggato — uid senza type=upgrade

Auto offer/upgrade. Active SI: can su change_options. Se can ko → #6 offer/term/list con offer_terms.ids.*.offer_active (fallback offer), risposta type=offer. Su ogni type=offer + #6 si escludono i term con resource.rid già attiva da subscription/list e da publisher/user/access/list (granted e non scaduti), e quelli delle testate di quelle risorse (decision.owned_testate, da config.resources): il Local di una testata ha una risorsa diversa dal Full o dall’abbonamento in app della stessa testata.

flowchart TD C0["QNTerm + uid"] --> C1["1 subscription/list"] C1 --> C2{"Active?"} C2 -->|No| CO["type=offer + 6 term/list offer"] C2 -->|Si| C34["3/4 can su change_options"] C34 -->|ok| CU["type=upgrade + terms filtrati"] C34 -->|ko| C6["type=offer + 6 term/list offer senza rid attivi"] CO --> CF["filtro rid: sub + access/list"] C6 --> CF
#SituazioneChiamateRisposta
C1 Nessuna sub active #1 → #6 + access/list type=offer + terms offerta (esclusi rid attivi in access/list)
C2 Active + almeno un can ok #1 → #3/#4 → #5 type=upgrade + terms filtrati (da change_options)
C3 Active ma can ko #1 → #3/#4 → #5 → #6 + access/list type=offer + terms da offer_active, esclusi rid attivi da sub e access/list

Come leggere i log Chrome / debug[]

OTPLOGIN … STEP #70 subscription_list
OTPLOGIN … STEP #71 term_change_can   { subscription_id, to_term_id, allowed }
OTPLOGIN … STEP #72 upgrade_result    { type: "upgrade"|"" }

Flusso A (Già cliente): con type=upgrade + uid non devono comparire step offer_term_list.