Web: productChangeInfo on PurchaseParams.package is dropped before reaching purchases-js, so a plan change creates a second subscription

Aperta
#2,002 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
48/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
dart, javascript
Ambito
api, mobile

Direzione di ricerca

Read lib/web/purchases_flutter_web.dart _purchasePackage and purchases-common.ts purchasePackage / createNativePurchaseParams in purchases-hybrid-common to trace the parameter flow and agree on the web-specific type shape. Add coverage for forwarding productChangeInfo through both layers; done means a web purchase reaches purchases-js with the subscription ID and subscriber token, and the relevant tests pass.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Summary

On web, Purchases.purchase(PurchaseParams.package(pkg, productChangeInfo: …)) silently ignores productChangeInfo. The underlying @revenuecat/purchases-js SDK supports product changes (purchase({ rcPackage, productChangeInfo: { subscriptionId, subscriberToken } }), per https://www.revenuecat.com/docs/web/product-changes), but the parameter is dropped twice before it gets there:

  1. purchases_flutter web plugin — lib/web/purchases_flutter_web.dart, _purchasePackage forwards only packageIdentifier, presentedOfferingContext and customerEmail (10.19.0; unchanged in 11.0.0).
  2. purchases-hybrid-common JS mappings — purchases-js-hybrid-mappings/src/purchases-common.ts, purchasePackage(purchaseParams) accepts only packageIdentifier, presentedOfferingContext, optionIdentifier, customerEmail, selectedLocale, defaultLocale, and createNativePurchaseParams never sets productChangeInfo on the PurchaseParams it passes to purchases.purchase (current main, after the 20.3.0 release).

So a Flutter web app whose customer holds an active Web Billing subscription and buys a different package gets a second subscription instead of the configured upgrade/downgrade path, even with change paths configured in the dashboard.

Expected

The same productChangeInfo parameter that is already accepted on the Dart side reaches purchases-js, so a product change on web behaves like it does when calling purchases-js directly: upgrades apply immediately with proration, downgrades at the end of the cycle.

The existing Dart type StoreProductChangeInfo is Play-shaped (oldProductIdentifier, prorationMode), so web needs a shape with subscriptionId / productIdentifier + subscriberToken. Either a web variant of the type, or a dedicated web-only field on PurchaseParams, would work.

Steps to reproduce

  1. Flutter web app on purchases_flutter 10.19.0 (or 11.0.0), configured with a Web Billing (Stripe Billing) API key.
  2. Configure an upgrade path A → B in the RevenueCat dashboard Product Catalog.
  3. Customer holds an active subscription to A.
  4. Mint a subscriber token server-side (POST /v2/projects/{p}/apps/{a}/authenticate) and call Purchases.purchase(PurchaseParams.package(packageB, productChangeInfo: …)).
  5. Observe a new subscription to B is created alongside A; no product change occurs. The dropped parameter is visible in the two functions above.

Environment

  • purchases_flutter 10.19.0 (also checked 11.0.0 source)
  • purchases-hybrid-common JS mappings at current main (20.3.0, 2026-11-02)
  • Flutter web (CanvasKit), Chrome; Stripe Billing engine

Related

  • RevenueCat/purchases-js#182 and RevenueCat/purchases-js#938 track the SDK-level feature, which now exists. This issue is only about the hybrid layers not forwarding it.

Happy to open a PR for the Dart side if the hybrid-common side gets a productChangeInfo field.

Lingua principale
Dart
Stelle
722
Fork
220
Merge medio
16h 36m
PR unite (30g)
25

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di RevenueCat/purchases-flutter

Tutte le issue di RevenueCat/purchases-flutter

Issue simili

Altre issue su Dart

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.