j3k0 / cordova-plugin-purchase

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

Products loaded with "free" price for Google Play Store #1605

Closed DereviankoAndrew closed 1 month ago

DereviankoAndrew commented 1 month ago

Good morning, @j3k0

Today we got our app submission rejected in Google Play Console, and the reason for it was that the prices for our subscriptions were loaded as "Free" (see screenshot 1), even though they actually have a price in Google Play Console. But, the prices load perfectly 100/100 times while implementing and testing the subscriptions functionality. We have also encountered, that sometimes it is the case for our users in production, that they get the prices as "Free", which happens very rarely.

Screenshot 1, the reason of app submission rejection: IN_APP_EXPERIENCE-6422

The way we load the subscriptions information to display: let sevenProduct = this.store.get(this.subscriptionKeys.android.SEVEN_DAYS_SUBSCRIPTION_KEY, CdvPurchase.Platform.GOOGLE_PLAY); this.sevenDaysSubscription = { title: sevenProduct.title, price: sevenProduct.offers[0].pricingPhases[0].price, } And so the price in this case was "FREE"

Screenshot 2, Internal testing version of the app, everything loads just fine: telegram-cloud-photo-size-2-5449859714310594128-y

I was looking for the issue in the repository, but wasn't able to find the similar one. I understand that plugin just loads the prices from Google, but maybe you have some clue how to prevent this from happening, or maybe you could redirect me to some other existing issue.

Thank you very much for your hard work!

j3k0 commented 1 month ago

It would be helpful if you can access some logs of the production app.

Either there's an offer that has its first phase free (trial period?). Or FREE is a default in your view? (maybe the product wasn't loaded correctly)

Logs are needed to debug this out, you can publish a beta that you instrument and should be able to access logs via logcat.

DereviankoAndrew commented 1 month ago

Hello again @j3k0 ! Thank you very much for your response! I've been trying to debug it for 2 days, and yesterday evening I succeeded!

The issue was that we changed the title of one of our subscriptions in GPC, which lead to Google changing the object that we get from store.get(id, platform) (more specifically BillingClient.queryProductDetailsAsync()). And if previously we always got only one offer and one pricing phase inside of the offer, which has always been our priced base plan, after changing the title, it seems like Google had recached the object, and started to return two types of offers: One, which consisted of two pricing phases: our free trial + our base plan, And one, which consisted of one pricing phase: only our base plan; And because we had always accessed the price with "product.offers[0].pricingPhases[0].price", it was no longer viable for us, because the free trial is now first in the array of pricing phases of our offer with index 0. Therefore, the application started to show "FREE" price.

One more interesting thing, is that the "FREE" price has been the case for a lot of users in the production, not only for the Google testers, who rejected the app. But I never was able to reproduce the problem on my android device for testing (which I described in the issue above). Turns out, that apparently Google caches the prices per google account, so the accounts that I've always been using for testing got the same object, that was viable for "product.offers[0].pricingPhases[0].price" approach, but our users got the updated version of this object. Therefore, I had to create a new google account and run the logcat on it to actually see the changed object.

Hope my suffering for last 2 days will help someone!

j3k0 commented 1 month ago

Thank you. I turned this into a wiki entry linked from Android Troubleshooting: https://github.com/j3k0/cordova-plugin-purchase/wiki/Handling-Dynamic-Pricing-Structures-in-Google-Play-Subscriptions

DereviankoAndrew commented 1 month ago

Thank you very much again for your hard work!