godotengine / godot-google-play-billing

Godot Android plugin for the Google Play Billing library
MIT License
138 stars 38 forks source link

Google requiring Google Play Billing Library version 6 or newer #65

Open flaming-toast opened 1 month ago

flaming-toast commented 1 month ago

Hello!

Got this message just today on Google Play Console, it looks like this plugin will need to be upgraded to a newer version of the Google Play Billing library by August 24th if I'm not mistaken?

image

Veradictus commented 1 month ago

+1 needed please

ArcanaCorvus commented 1 month ago

We got the same message, hopefully it's a fairly easy fix

dalvaren commented 1 month ago

+1 needed

Veradictus commented 1 month ago

We got the same message, hopefully it's a fairly easy fix

I think depending on how much the API has changed, I will probably attempt it today to upgrade it and see if it explodes in my face.

Veradictus commented 1 month ago

I have no way of testing this at the moment since I am still working on my in-app purchases for my game, is anyone available to check:

https://github.com/Kaetram/godot-google-play-billing

BlitBlatGames commented 1 month ago

@Veradictus I successfully built the .aarfile and compiled the app. So, so far so good! I've sent the app to Google for review, will let you know it how it goes once it's approved. Thanks for your the help on this!

BlitBlatGames commented 1 month ago

It's been approved by Google, so that's a good sign, but it doesn't seem to be working 100% yet.

It seems the signal sku_details_query_completed is now product_details_query_completed and item.sku is now item.productId

These aren't problems, but what is a problem is that payment.queryProductDetails(["name0", "name1], "inapp") now only returns details for name0 instead of everything in that array.

I'll keep investigating.

BlitBlatGames commented 1 month ago

https://github.com/Kaetram/godot-google-play-billing/blob/master/godot-google-play-billing/src/main/java/org/godotengine/godot/plugin/googleplaybilling/GodotGooglePlayBilling.java#L133

That section there needs to be updated to not just get the first product only. This gets all the items in one call:


        ArrayList<QueryProductDetailsParams.Product> productList = new ArrayList<QueryProductDetailsParams.Product>();
        for (String productId : productIdList) {
            QueryProductDetailsParams.Product product = QueryProductDetailsParams.Product.newBuilder()
                    .setProductId(productId)
                    .setProductType(type)
                    .build();
            productList.add(product);
        }

        QueryProductDetailsParams params = QueryProductDetailsParams.newBuilder()
            .setProductList(productList)
            .build();

I'm not a Java developer (and I really don't like the language, don't @ me!) so there might be a better way of doing this, but so far it seems to be working.

Veradictus commented 1 month ago

BlitBlatGames

Solid, will try to fix it. I'm starting in-app purchases for my game today so I will update further as needed, and once the game is published on the Play Store and transactions work as intended, I will create a PR into this repo.

777Pixels commented 1 month ago

I think this should fix your last problem... At least on my side, it fixes some issue I got. I have taken some code from the godot master branch.

check for the <<<<<<<<<<<<<<<<<<<<<<<<<

    public static Dictionary convertPurchaseToDictionary(Purchase purchase) {
        Dictionary dictionary = new Dictionary();
        dictionary.put("original_json", purchase.getOriginalJson());
        dictionary.put("order_id", purchase.getOrderId());
        dictionary.put("package_name", purchase.getPackageName());
        dictionary.put("purchase_state", purchase.getPurchaseState());
        dictionary.put("purchase_time", purchase.getPurchaseTime());
        dictionary.put("purchase_token", purchase.getPurchaseToken());
        dictionary.put("quantity", purchase.getQuantity());
        dictionary.put("signature", purchase.getSignature());
        // PBL V4 replaced getSku with getSkus to support multi-sku purchases,
        // use the first entry for "sku" and generate an array for "skus"
        // BUG ArrayList<String> skus = purchase.getSkus();    <<<<<<<<<<<<<<<<<<<<<<
        // BUG dictionary.put("sku", skus.get(0));             <<<<<<<<<<<<<<<<<<<<<<
        // BUG String[] skusArray = skus.toArray(new String[0]); <<<<<<<<<<<<<<<<<<<<<<
        // BUG dictionary.put("skus", skusArray);
        String[] products = purchase.getProducts().toArray(new String[0]);  // NEW <<<<<<<<<<<<<<<<<<<<<<
        dictionary.put("products", products);                   // NEW<<<<<<<<<<<<<<<<<<<<<<
        dictionary.put("is_acknowledged", purchase.isAcknowledged());
        dictionary.put("is_auto_renewing", purchase.isAutoRenewing());
        return dictionary;
    }
Veradictus commented 1 month ago

I think this should fix your last problem... At least on my side, it fixes some issue I got. I have taken some code from the godot master branch.

check for the <<<<<<<<<<<<<<<<<<<<<<<<<

  public static Dictionary convertPurchaseToDictionary(Purchase purchase) {
      Dictionary dictionary = new Dictionary();
      dictionary.put("original_json", purchase.getOriginalJson());
      dictionary.put("order_id", purchase.getOrderId());
      dictionary.put("package_name", purchase.getPackageName());
      dictionary.put("purchase_state", purchase.getPurchaseState());
      dictionary.put("purchase_time", purchase.getPurchaseTime());
      dictionary.put("purchase_token", purchase.getPurchaseToken());
      dictionary.put("quantity", purchase.getQuantity());
      dictionary.put("signature", purchase.getSignature());
      // PBL V4 replaced getSku with getSkus to support multi-sku purchases,
      // use the first entry for "sku" and generate an array for "skus"
      // BUG ArrayList<String> skus = purchase.getSkus();    <<<<<<<<<<<<<<<<<<<<<<
      // BUG dictionary.put("sku", skus.get(0));             <<<<<<<<<<<<<<<<<<<<<<
      // BUG String[] skusArray = skus.toArray(new String[0]); <<<<<<<<<<<<<<<<<<<<<<
      // BUG dictionary.put("skus", skusArray);
      String[] products = purchase.getProducts().toArray(new String[0]);  // NEW <<<<<<<<<<<<<<<<<<<<<<
      dictionary.put("products", products);                   // NEW<<<<<<<<<<<<<<<<<<<<<<
      dictionary.put("is_acknowledged", purchase.isAcknowledged());
      dictionary.put("is_auto_renewing", purchase.isAutoRenewing());
      return dictionary;
  }

Awesome, I haven't had any time to update my code, much appreciated!

777Pixels commented 1 month ago

Just found another issue in another file ( GodotGooglePlayBilling.java ) I'm not a java developper, so my code may not be optimal. But now, I can see my item prices.


@UsedByGodot
    public void queryProductDetails(final String[] list, String type) {
        List<String> productIdList = Arrays.asList(list);

        List<QueryProductDetailsParams.Product> productList = new ArrayList<>();
        for(String productId : productIdList )
        {
            productList.add(  QueryProductDetailsParams.Product.newBuilder()
                                .setProductId(productId)
                                .setProductType(type)
                                .build());
        }
        //QueryProductDetailsParams.Product product = QueryProductDetailsParams.Product.newBuilder()
        //    .setProductId(productIdList.get(0))
        //    .setProductType(type)
        //    .build();

        QueryProductDetailsParams params = QueryProductDetailsParams.newBuilder()
            .setProductList(productList) // Arrays.asList(product))
            .build();

            ...           
201949 commented 4 weeks ago

If anyone is interested, here is the repository of the working plugin that I prepared for using Google Play Billing Library version 6.2.1 on Android for Godot 3.5.2 (https://github.com/201949/godot-google-play-billing-6)

flaming-toast commented 3 weeks ago

@201949 You're amazing, thank you so much for this! 🚀 Would you consider making a pull request so that upstream may benefit from it as well? 😊

@akien-mga Hi Rémi! I'm so sorry for the ping, you must have a lot on your plate.. 😭 But I'm not entirely sure who the maintainer of this repository is, and l wanted to at least let someone know about the current situation with this plugin as the Aug 31st deadline will be coming up soon 🙇🏻‍♀️🙇🏻‍♀️ Thank you so much for your attention 🙏

201949 commented 3 weeks ago

@201949 You're amazing, thank you so much for this! 🚀 Would you consider making a pull request so that upstream may benefit from it as well? 😊

@flaming-toast I attempted to transition to Google Play Billing Library version 7 using the existing official upstream plugin, but I was unsuccessful, just as I was with the transition to version 6. Therefore, to address the need for organizing one-time purchases in my existing applications with the outdated library, I created my own solution, guided by official sources on the Google Play Billing Library. Additionally, I have now implemented support for subscriptions and made it publicly available. Here is the Release 6.2.1 with subs

flaming-toast commented 3 weeks ago

@201949 This is awesome! Thank you so much for updating and even improving on the plugin! Since this official repository seems unmaintained now, I'll try migrating to your plugin, will let you know if I run into any issues 🙇🏻‍♀️ Thank you!

dgsdestinygamestudios commented 3 weeks ago

https://github.com/dgsdestinygamestudios/godot-google-play-billing/tree/main v2 plugin structure, tested on Godot 4.2. Just for android though. If you use, please let me know.

201949 commented 3 weeks ago

https://github.com/dgsdestinygamestudios/godot-google-play-billing/tree/main v2 plugin structure, tested on Godot 4.2. Just for android though. If you use, please let me know.

@dgsdestinygamestudios I'm very happy for you that you managed to build the plugin for the new v2 structure. I hope you will share the source code soon so that we can see your implementation of the methods for working with the Google Play Billing Library. I hope that my solutions have also helped you in your implementation.

dgsdestinygamestudios commented 3 weeks ago

@201949 thank you. Given that Billing library 6 won't be a long-term fix, I figured I should try to go for 7. I've shared java part of the things. If you see anything wrong, feel free to help. Also yes, I've extensively read your code, Remi's code and the documentation to understand what is going on, so thank you.

code-with-max commented 2 weeks ago

I've created an new addon for the Godot 4.2 that integrates with Google Play Billing Library version 7. This module supports all the public functions provided by the library, handles all error codes, and can work with different pricing plans within subscriptions.

You can check it out here: https://github.com/code-with-max/godot-google-play-iapp

I hope this addon helps you with your projects. Feedback and contributions are welcome!

Happy coding!

Krigu commented 2 weeks ago

@code-with-max Do you plan to create a PR and merge it back with the offical plugin?

code-with-max commented 2 weeks ago

@code-with-max Do you plan to create a PR and merge it back with the offical plugin?

I'm not sure I can do this for several reasons:

Shay-M commented 2 weeks ago

@code-with-max Thanks for the update, but when I try to use the new version it gives me an error: Please ensure the app is signed correctly.", "response_code": 5

(the old version works for me)

And according to a Google search it says: code 5: BILLING_RESPONSE_RESULT_DEVELOPER_ERROR: Invalid arguments provided to the API. This error can also indicate that the application was not correctly signed or properly set up for In-app Billing in Google Play, or does not have the necessary permissions in its manifest

I see that it gets the product names but when you click on purchase it gives this error.

code-with-max commented 1 week ago

@Shay-M Write an example of your request.

dgsdestinygamestudios commented 1 week ago

@code-with-max Thanks for the update, but when I try to use the new version it gives me an error: Please ensure the app is signed correctly.", "response_code": 5

(the old version works for me)

And according to a Google search it says: code 5: BILLING_RESPONSE_RESULT_DEVELOPER_ERROR: Invalid arguments provided to the API. This error can also indicate that the application was not correctly signed or properly set up for In-app Billing in Google Play, or does not have the necessary permissions in its manifest

I see that it gets the product names but when you click on purchase it gives this error.

Check your debug and release keystores.

Project > Export > select Android > scroll down until you see keystores > assign

Shay-M commented 1 week ago

Thank you for the quick reply:

@dgsdestinygamestudios In the old version I only had Release and it worked. Now I also added it to Debug and it still doesn't work.

@code-with-max I used the code of the example :

GooglePlayBilling.do_purchase("remove_ads") func do_purchase(id: String, is_personalized: bool = false): billing.purchase([id], is_personalized)

And of course I changed it: const ITEM_ACKNOWLEDGED: Array = [ "remove_ads" ]

image

AndroidIAPP singleton loaded Billing: start connection Billing successfully connected "remove_ads" "remove_ads" { "debug_message": "Please ensure the app is signed correctly.", "response_code": 5 }

dgsdestinygamestudios commented 1 week ago

Thank you for the quick reply:

@dgsdestinygamestudios In the old version I only had Release and it worked. Now I also added it to Debug and it still doesn't work.

@code-with-max I used the code of the example :

GooglePlayBilling.do_purchase("remove_ads") func do_purchase(id: String, is_personalized: bool = false): billing.purchase([id], is_personalized)

And of course I changed it: const ITEM_ACKNOWLEDGED: Array = [ "remove_ads" ]

image

AndroidIAPP singleton loaded Billing: start connection Billing successfully connected "remove_ads" "remove_ads" { "debug_message": "Please ensure the app is signed correctly.", "response_code": 5 }

Then check your AndroidManifest file and unique name. Make sure you enter the unique name of your game. example: com.example.$genname

Shay-M commented 1 week ago

Yes, I have in the settings: image

dgsdestinygamestudios commented 1 week ago

Did you publish an internal testing with this build? Billing library needs latest aab to work.

Yes, I have in the settings: image

code-with-max commented 1 week ago

@dgsdestinygamestudios @Shay-M I make new versions of plug-in achieve with separated "release" and "debug" versions. In fact, the differences between them are minimal, but I want to eliminate all errors.

https://github.com/code-with-max/godot-google-play-iapp/releases/tag/v1.2

Shay-M commented 1 week ago

@dgsdestinygamestudios @code-with-max Ok, I will try and update with the new version + through internal testing

In the previous version, I did the run through godot and a physical connection of my device (this is how it worked)

Shay-M commented 1 week ago

Nice it works :) But It only works for me only from the google store. The question is what can be done that will also work in lectures with the physical connection of the device? while debugging

code-with-max commented 1 week ago

@Shay-M I'm sorry, I don't really understand. Do you want to use this plugin for an application that does not use the Google Store?

Shay-M commented 1 week ago

@code-with-max Ah sorry I didn't explain myself. When I upload the app to the store and run it from there it works. But when I run it from godot (when I connect the device physically so I can check that everything works - debug locally) it still gives the error response_code": 5

201949 commented 1 week ago

As I understand your conversation, you need to register the payment tester in the Google Developer Console. Settings -> License testing. Otherwise, payment testing will have to be carried out in a published application with a real payment method. Or did I misunderstand the conversation? I will add that essentially, in-app payments can only be tested using the release-signed APK file (the one we upload to the Google Play console). https://developer.android.com/google/play/billing/test

code-with-max commented 1 week ago

@201949 @Shay-M Don`t forget put license key in special field on Godot export options

Shay-M commented 1 week ago

Hi, thank you for your help! I found a solution to the problem: "Clear you cache from the google play store account. 😶

https://stackoverflow.com/questions/73025919/google-play-billing-library-5-purchase-flow-fails-but-response-code-indicates-su

I believe that now everything will work