godot-sdk-integrations / godot-google-play-billing

Godot Android plugin for the Google Play Billing library
MIT License
147 stars 46 forks source link

Plugin Modernization #69

Open atlasapplications opened 2 months ago

atlasapplications commented 2 months ago

This plugin was initially built with version 3 as the targeted API version. Adjustments were made to get it to work as a version 5 plugin but significant amounts of deprecated methods and workflows were being used. My game needs a functional billing library that's up-to-date, so I built this plugin from the ground up. Google's current API is now version 7.0.0, which is the new target. The Google Play Billing Library has changed quite a bit since the plugin was first created so here are some of the top changes.

There are now three primary methods for starting a purchase that depend on the purchase type.

  1. If it's a non-consumable purchase, (like a level that you unlock or removing ads) use the purchaseNonConsumable method. This only requires a single product ID.
  2. If it's consumable, (like buying virtual currency or a potion) then use purchaseConsumable. A top reason why these should be separated is because this version of the API now supports the ability to purchase consumable items with varying quantities. So this requires an array of product IDs, but of course can also accept just one.
  3. The last one which needed the most refactoring are subscriptions. Use purchaseSubscription which requires not only a productId but also a planId which is the tier of subscription that the user is choosing.

Additional functionality like setting the personalized price flag is now supported.

This plugin modernization also absorbs my other work with adapting the plugin as a version 2 Godot Android Plugin. I've included an updated .gdap file for backwards compatibility purposes but the new way of consuming Android plugins is with an editor addon which I've also built and included.

Of course there are a lot more changes but these are the top differences. Acknowledging purchases and querying for product details is about the same workflow those just needed revisions on what methods need to be called.

This is a work in progress. My initial testing seems to show that things are working properly but I would not treat this as production-level yet because I'm not an expert with Android development. So, I'd be happy to receive feedback.

I'm a C# user, so the next thing I plan on contributing are the bindings to convert the Godot dictionaries to their corresponding Google Play Billing class.