j3k0 / cordova-plugin-purchase

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

Non-Consumable stays in Approved state #1491

Open undergroundcreative opened 1 year ago

undergroundcreative commented 1 year ago

Observed behavior

Hi,

I've recently needed to update this plugin to version 13 (13.8.6) on Android due to Play Billing Library v4 being deprecated.

Consumable IAPs work as expected but I have one non-consumable item, that persistently stays in the approved state, even though it goes through the finish() process.

Every time I close the app and reload it (or refocus it), the .approved() method gets called, which calls my finishPurchase() function

store.when().approved(finishPurchase);

This logs the transaction and then gives the user whatever they've just paid for.

I see that the transaction state is "approved", purchaseState is 0. There's a purchaseToken, signature and receipt as well as purchaseId, purchaseDate, "isPending": false, "isAcknowledged": true

The product's valid property is "true" and "owned" is true.

I see purchaseState 0 is UNSPECIFIED_STATE https://github.com/j3k0/cordova-plugin-purchase/blob/master/api/enums/CdvPurchase.GooglePlay.Bridge.PurchaseState.md

Why is this, and why does this product not get finished?

In my app, once the user buys this IAP, there is a pop up to let them know that ads have been removed. Every time the user focuses the app or opens it, after purchasing the IAP, this pop up appears. Obviously that will get very annoying!

It never used to do this on the previous version of the plugin, with my previous code.

As a temporary workaround, while testing, I've had to add some code in the finishPurchase function to stop the pop up keep appearing but this feels unnecessary.

If I purchase any of the other IAPs, which are all consumable, they work as expected and finish correctly. When I close and reload the app, these transactions aren't logged. Just the unfinished one above.

A couple of days ago, when I was re-coding for version 13, I did do a test transaction on this product using Android's "Test card always declines" option, but I don't think I'd set the error trapping up correctly. Could this have resulted in some kind of "zombie" transaction?

I'm not sure how though because it tries to finish it every time the app loads, but it just never finishes...

Also, the store.when().finished() call never gets called for it, but it does for the consumable products.

Any help very much appreciated!

Thanks,

Sean :)

Expected behavior

All products finish correctly.

System Info

Output of cordova info.

I use Ionic Appflow, so don't know how to use that but I do know the following:

Plugin version 13.8.6 Cordova CLI 12.0.0 Cordova-android 11

From Appflow build:

Linux - 2023.06 Cordova CLI 12.0.0 Ionic CLI 7.1.1 Node.js 16.20.0 / 18.16.0 npm 8.19.4 Yarn 1.22.19 Debian 11.6 Gradle 5.6.4 OpenJDK 1.8.0_332 / 11.0.18 / 17.0.6 Android SDK 27-33

undergroundcreative commented 1 year ago

Update - I've installed it on a different tablet (logged in to the Play Store as the same user) and as soon as I opened it, I got my pop up saying I've removed ads and then it sticks on a blank screen.

The transaction is logged and, again, my code tried to finish it but it doesn't get finished.

I uninstalled the app, changed user in the Play Store app and re-installed and I'm still getting the same behaviour.. same transaction is unfinished.. I'm really stuck here.. Anyone and ideas?

gartorware commented 1 year ago

Same is happening for me, but in my case even "owned" property is false.

proggeramlug commented 1 year ago

I have the exact same problem - need a solution ASAP!

j3k0 commented 11 months ago

Please share debug logs. There's no way to understand the issue without logs. Notice that non-consumables on android have been tested successfully, so I guess it's something about in the way your code is setup. It would be relevant if you could share it as well.

proggeramlug commented 11 months ago

@j3k0 I'll try to pull them for you but given that the app works flawlessly in iOS would not indicate that there is a flow-problem within the app logic, or am I missing something?

metinjakupi commented 9 months ago

bump

@proggeramlug did you fix it?

proggeramlug commented 9 months ago

@metinjakupi No, we ended up working around it. Super annoying.

nebadodev commented 1 month ago

@j3k0 He shared the logs, and we have the same problem. There is no problem with the products consumed. But there is this problem in non-consumables products. Are you planning to fix the problem?

nebadodev commented 1 month ago

The man doesn't help in any way. It causes us to write dozens of ridiculous code to store non-consumed products on the server. Products that are non-consumable for Android do not work properly. There is no problem with consumable products.