j3k0 / cordova-plugin-purchase

In-App Purchase for Cordova on iOS, Android and Windows
https://purchase.cordova.fovea.cc
1.29k stars 529 forks source link

Handling of unfinished non consumable transactions on iOS #448

Closed j3k0 closed 5 years ago

j3k0 commented 8 years ago

See #447

Non consumable transaction, when not finished, stay stuck in the queue and can't be re-purchased.

heaven commented 7 years ago

Subscriptions seems also stuck there, I am now seeing these errors after I deleted old products:

Store: The purchase queue contains unknown product ERN_Lifetime(6777003) // non consumable
Store: The purchase queue contains unknown product ERN_Subscription(6777003) // subscription
j3k0 commented 7 years ago

The unknown product error is (normally) happening only when there are some items in the queue that are not registered in the plugin (using store.register). Thus, the plugin doesn't know how they should be handled. Can you confirm?

heaven commented 7 years ago

Previously we had 2 products: ERN_Lifetime (non consumable) and ERN_Subscription (subscription) These products were already removed from the store and from our database, new products were added instead, but I have unfinished purchases in the queue for these deleted products.

Now when I am registering new products and calling store.refresh() I am getting errors about these unknown products in the queue.

The title for this issue says about unfinished non consumable transactions, I only wanted to point that subscriptions are also stuck there.

UPD: btw, is there any way I can cancel these unfinished purchases/remove them from the queue manually?

j3k0 commented 7 years ago

There are ways, but just creating a new Test User on iTunes Connect is simpler.

heaven commented 7 years ago

Yeah, but my own itunes account is affected by this :)

thomashilzendegen commented 7 years ago

Hm, I had the same problem recently... After investigating all possible callbacks etc. I just tried to issue a store.refresh() the second time. Then the password was asked again and (magically) the pending "unfinished" transaction did it's normal flow until I could finish it.

Maybe it could be important to wait with the initial store.refresh() until all registered products are raising their registered callback and only then refresh the store.

Update: Nah, keeps asking again... :(

Update 2: It is calling the validate method over and over with every refresh. Is that correct? Should I store the receipt somewhere to prevent "useless" validation of the same receipt again?

j3k0 commented 7 years ago

@thomashilzendegen It's expected. With refresh() you may like to reset all you know about the users' purchase and start fresh. However, you can cache Apple's response (key: a hashed version of the receipt).

To clean the queue of products that aren't valid anymore, you have to hack into InAppPurchase.m, call finishPurchase in transactionUpdated (or something)

thomashilzendegen commented 7 years ago

@j3k0 So in that case I cannot prevent asking for the password during a refresh() (which I need to issue that the products get loaded with their prices etc.)?

Update: Maybe it is only for sandbox users? In this Issue https://github.com/j3k0/cordova-plugin-purchase/issues/217#issuecomment-111492362 he is talking about that on production this won't be the case.

greneham commented 7 years ago

i raised a similar issue to this one which got closed as a duplicate (see https://github.com/j3k0/cordova-plugin-purchase/issues/454)

however my issue was related consumables (not non consumables) would the bug fix for this issue also address my issue too or should they be listed as separate issues? just wanted to check

nnylip commented 7 years ago

Creating a new test user did not solve this problem for me.

aesculus commented 7 years ago

Any update to a fix for this problem? I had a subscription product that somehow must not have had a name (or one of null) but got ordered and now I cannot clear this error for an unknown product of null.

stale[bot] commented 6 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

intercorps commented 5 years ago

Im having the following error: " 6777003 trying to purchase a unknown product " the products are Auto-Renewable Subscription and are already approved in apple console, im not sure what im doing wrong but this is killing me.

Please help, Thanks!

martinkirby commented 4 years ago

it's killing me too... Please help me too! Thank you!

heffthedev commented 3 years ago

Did anyone find a solution to this? For me it's an IOS-thing. I have a deleted product in my purchase queue (sandbox) that throws many errors every time I run my app. I tried several new sandbox users, deleting the app completely, cleaning the build folder in xcode before running the app again but the old purchase queue remains there over all accounts. I have no idea how to get rid of this. Is the hacking solution suggested in https://github.com/j3k0/cordova-plugin-purchase/issues/448#issuecomment-222108884 the only way to remove an old purchase queue, despite it originating from a completely different sandbox account?

Lindsay-Needs-Sleep commented 3 years ago

My theory is that the purchase queue is tied to the device, not so much the sandbox account (which seems wrong but it’s apple...).

You could try factory resetting the device (never tried myself, just a theory)

heffthedev commented 3 years ago

You could try factory resetting the device (never tried myself, just a theory)

Wow, that seems to have worked. Thanks for the suggestion! Definitely far from a practical solution to a (I would have thougt) quite common problem, but you can't bee to picky with apple I guess... ;)

avrahamappel commented 3 years ago

I'm having this issue in production on two apps which were just migrated from [https://github.com/AlexDisler/cordova-plugin-inapppurchase](). Numerous iOS users are unable purchase new content because they're seeing "The purchase queue contains unknown product ..." I can't just tell them to factory reset their phones!

Please advise, thanks.

bhaskar-se commented 2 years ago

Hi @avrahamappel did you solved this issue?

I'm having this issue with this plugin on iOS, in my case it's an auto renewing subscription.

And I'm facing this issue on purchasing second time, after cancelling it from sandbox account or auto expiry after 6 attempts.

It's showing me the status of the product is approved and canPurchase is false. But if I try to re-subscribe from sandbox account then there's no issue with it, it's getting subscribed.

Also, strangely I can not even purchase other products too. It's saying product status is registered but canPurchase is false.

Please help @j3k0 @dpa99c

tempo-riz commented 1 year ago

Same issue with auto-renewing subscriptions, anyone found a solution (other than factory reset) to manually remove items from purchase queue as mentioned here https://github.com/j3k0/cordova-plugin-purchase/issues/448#issuecomment-222108884 ? Please help @j3k0 @dpa99c