Skip to content
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

Store.order() returns undefined if a receipt or transaction has been updated while the purchase dialog is opened, thus never calling cancel or error #1548

Open
DavidTalevski opened this issue Mar 18, 2024 · 1 comment
Assignees
Labels

Comments

@DavidTalevski
Copy link

Observed behavior

When the purchase dialog is opened, and some of the receipts get updated they trigger the order promise to resolve and return undefined, thus making it impossible to listen for cancel or error events during the current ordering of a product. The easiest way to reproduce this is to order a product, when the purchase dialog appears minimize the app, upon returning to the app some of the receipts might have gotten updated and then they trigger the order to resolve. The order is resolved and the purchase dialog is left open and then it is impossible for us to listen to cancel or error events for the currently opened dialog. In the previous versions this could've been remedied with the store.when().cancelled event but now that everything is tied to store.order() this makes it impossible to handle.

These are the logs when the app is resumed and the purchase dialog is still opened:

[CdvPurchase] DEBUG: Calling callback: type=approved() name=transactionStateMonitors_callOnChange reason=adapterListener_receiptsUpdated_approved
[CdvPurchase] DEBUG: Calling callback: type=approved() name=#fb6c4b9c7fe59d61a15b3c3e14723044 reason=adapterListener_receiptsUpdated_approved

After the order falsely finishes, in logcat when the close dialog is closed this is the output:

onPurchasesUpdated() -> Cancelled: USER_CANCELED: User pressed back or canceled a dialog
callError({code:6777006, msg:"USER_CANCELED")

This error is no longer listened to because the order has finished and the js code never gets notified that this dialog has closed.

Expected behavior

When ordering a product and some of the receipt get updated, this should not affect the current order that is taking place. The promise should not resolve with "undefined" if a different receipt has been updated, it should only resolve when the order is completed or it has failed.

@j3k0
Copy link
Owner

j3k0 commented Sep 13, 2024

This is a bug that will happen mostly in dev. A user has to try to update a subscription he owns, keep the purchase window open long enough that the subscription renews at that exact moment. In dev, with 3 minutes renewal it might happen. In prod with monthly renewal it's extremely unlikely.

That's a minor bug nevertheless, I'll dig into it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants