-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Subscriptions: Add Failed State to PurchaseState #7296
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Subscriptions: Add Failed State to PurchaseState #7296
Conversation
| logcat { "Subs: Cannot switch plan - $errorMessage" } | ||
| subscriptionSwitchWideEvent.onSwitchFailed(errorMessage) | ||
| _currentPurchaseState.emit(CurrentPurchase.Failure(errorMessage)) | ||
| _currentPurchaseState.emit(CurrentPurchase.Failure("No account found for switch")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Missing switch failure event tracking for validation errors
The refactoring removed calls to subscriptionSwitchWideEvent.onSwitchFailed() for the currentPurchaseToken == null and account == null validation errors in switchSubscriptionPlan. These errors occur before the billing flow launches, so no PurchaseState.Failure will be emitted, and the wide event tracking system won't be notified of these switch failures. The logging was also removed, making debugging harder.
Please tell me if this was useful or not with a 👍 or 👎.
| } | ||
|
|
||
| is PurchaseState.Failure -> { | ||
| subscriptionPurchaseWideEvent.onPurchaseFailed(it.errorType) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Purchase failure uses wrong event method, missing step tracking
The PurchaseState.Failure handler calls subscriptionPurchaseWideEvent.onPurchaseFailed() but the previous code in PlayBillingManager called onBillingFlowPurchaseFailure(). These methods have different behavior: onBillingFlowPurchaseFailure records a flowStep with success = false before finishing the flow, while onPurchaseFailed only finishes the flow. This causes the billing flow purchase step tracking to be lost for purchase failures.
Please tell me if this was useful or not with a 👍 or 👎.

Task/Issue URL: https://app.asana.com/1/137249556945/project/1201807753394693/task/1212077422444869?focus=true
Description
implement Failed state callback when receiving a PurchaseState update
Steps to test this PR
Purchase Wide Event
subscription-purchasewide event on cancellationsubscription-purchasewide event on failuresubscription-purchasewide event on successSwitch Wide Event
subscription-switchwide event on cancellationsubscription-switchwide event on failuresubscription-switchwide event on successNo UI changes
Note
Introduce
PurchaseState.Failureand emit it across billing and manager flows, updating wide events, switch-plan/purchase logic, and tests accordingly.PlayBillingManager):PurchaseState.Failure(errorType)and emit it for init errors, invalid product details, empty/invalid tokens, and purchase update failures.Canceledonly on user cancellation; all other errors now emitFailure.SubscriptionsManager):PurchaseState.Failure: triggersubscription-purchaseandsubscription-switchfailure events and emitCurrentPurchase.Failure.Canceled: trigger cancellation events and emitCurrentPurchase.Canceled.CurrentPurchase.Failure("...")without extra logging callbacks.Failureemissions for billing init/update errors and purchase update failures; keepCanceledfor user-cancel cases.Written by Cursor Bugbot for commit ad98924. This will update automatically on new commits. Configure here.