5

Google has documentation of what to do IF a subscription's price has changed.

You're supposed to use a billing client and launch PriceChangeConfirmationFlow. However, how do you detect if the price has changed in the first place?

What Android library API would tell me that?

The SkuDetails have the price, but the Purchase details don't. They just refer to the SkuDetails using the "productId". I'm looking at the raw json. If the Purchase object had a price in it, I could compare it to the current price in the SkuDetails, but it doesn't.

david
  • 1,311
  • 12
  • 32
metaphyze
  • 1,412
  • 1
  • 15
  • 13
  • The Google [documentation](https://developer.android.com/google/play/billing/subscriptions#price-change-communicate) says the application can determine if the user has a pending price change by looking at the priceChange field in [the subscription resource](https://developers.google.com/android-publisher/api-ref/rest/v3/purchases.subscriptions) (available through a REST API) If present, this field indicates the subscription has a price change, and the priceChange.state field indicates whether the price change has been accepted or is still outstanding. – david Dec 20 '20 at 12:19
  • I've created an [issue](https://issuetracker.google.com/issues/175741236) on Google Issue Tracker regarding the missing APIs in Google Play Billing library to find out price change. – david Dec 20 '20 at 12:21
  • @DharmendraPratapSingh also pointed me to this [github issue](https://github.com/android/play-billing-samples/issues/180) raising the same question. – david Dec 20 '20 at 12:24

1 Answers1

1

When you query for the user inventory with the billing API, you get Purchase objects which include the purchase time. A bit of a hacky solution is to look at that date and if it's before the time you changed your price, you initiate the flow with launchPriceChangeConfirmationFlow().

Ariel Vardi
  • 797
  • 1
  • 7
  • 18
  • But the user may have already agreed to the price change directly via their Play Store... e.g. as shown here: https://joebirch.co/2019/03/12/handling-pricing-changes-with-the-google-play-billing-library/ ... but I can't see any way of determining in the code whether or not you need to actually launch the relevant workflow... this doesn't really seem to be well thought through by Google, or at least not very well documented. – drmrbrewer Jan 27 '20 at 19:56
  • Aaah, if they agree to the price change then the purchase time will change to the time they agreed to the price change? So if the purchase time is before you changed the price, then they're an existing "legacy" subscriber... so launch the workflow. And if the purchase time is after, then either they're a completely new subscriber, or they're a legacy subscriber who has agreed the change (effectively the same as a new subscriber)? Not really that clear...... – drmrbrewer Jan 27 '20 at 20:02