anjlab / android-inapp-billing-v3

A lightweight implementation of Android In-app Billing Version 3
Other
2.19k stars 535 forks source link

Mirgated to v4 #497

Closed Equin closed 2 years ago

Equin commented 2 years ago

its fork of #492 but with some changes:

PS: was doing this changes to make my project work, hope someone can finish my work or point me in right direction=) @serggl @showdpro

Cand3h commented 2 years ago

Hoping for a merge as we're running out of time.

Equin commented 2 years ago

@serggl Thanks for review =) i will try to find some time and fix the code. and i think on most answers can answer @showdpro as mostly it was his code.

lumirodri commented 2 years ago

Hey @Equin Sorry, but how can I include your fork on my android app?

Equin commented 2 years ago

@serggl pushed new changes acording your comments. @showdpro can you answer on few qustion in comments ?

showdpro commented 2 years ago

its fork of #492 but with some changes:

* added async functions with callbacks

* removed serviceConnection as looks like v4 billing already doing same.

* added simple retry connection logic

* saving developer paylod locally as google removed such functionality. (will not be sent to playmarket)

* some minor fixes

* tried to follow original code style

* subscriptions works pretty fine, but i did not changed code for purchases because i dont have ability to test purchases.

PS: was doing this changes to make my project work, hope someone can finish my work or point me in right direction=) @serggl @showdpro

@Equin Thanks for the improvement made on the #492 fork, I think @serggl should be able to merge this #497 after all reviews have been made. I will check through comments and answer some questions mentioned. November 1st is near.

showdpro commented 2 years ago

@serggl pushed new changes acording your comments. @showdpro can you answer on few qustion in comments ?

@Equin Ok

showdpro commented 2 years ago

@Equin Please check through the isPurchased and isSubscribed methods in relations to the BillingCache methods, I think it sometimes returns null (meaning it might not be in cache despite that the user(s) had actually purchased the item), I think the best alternatives are:

  1. To use the Playstore cache that the new version 4 give us i.e queryPurchasesAsync, its only active subscriptions and non-consumed one-time purchases are returned. This method uses a cache of Google Play Store app without initiating a network request. refer here And if we will consider this alt, we might need to check if the user has Google Play store app installed in his/her phone.

  2. Developers can obtained the purchase details from the onActivityForResult callback, save it to their server and check if the current user(s) have already purchase the item before giving values (This is recommended by google). Alt 1 above is applicable if developer dont want/need server side validations.

  3. We can improve on BillingCache in this library and include this version so that it handles Alternatives 1 and 2 above.

Based on the current usage of this updated library, I can say that for the past three months: a) Its working fine with one-time purchases and subscriptions b) isPurchased sometimes return null, this can be resolved with any of the three alternatives mentioned above. c) Consume method has not been working (meaning if your users have to purchase a productId multiple times)

oceanox commented 2 years ago

@showdpro, @Equin not include in readme?? bp.connect(this); //Connection required based on google Version 4 for inapp lib

Its ok? I am checking and I see that it does not mention in the forked in the readme.

I wanted to ask, I understand that this thread is the one that is being followed now to see if it is possible to update the library, right? for following the correct thread, and I still understand very well how threads work on github.

showdpro commented 2 years ago

@showdpro, @Equin not include in readme?? bp.connect(this); //Connection required based on google Version 4 for inapp lib

Its ok? I am checking and I see that it does not mention in the forked in the readme.

I wanted to ask, I understand that this thread is the one that is being followed now to see if it is possible to update the library, right? for following the correct thread, and I still understand very well how threads work on github.

@oceanox , It was included in readme of #492 , I just noticed now that its not included in the readme of @Equin updates. Maybe i will reopen the #492 for easy reference, however, we will continue to follow this #497 thread to avoid double conversations on same reasons. Additionally, I am not sure if bp.connect(this) is used in this current update #497 as this has been modified to bp.init(this) if eventually merged.

ysnsyhn commented 2 years ago

Hey, are you planning to release an official update before November. Or can you pls release a little documentation how to update it. If not for both please let us know that we can find other solutions for our apps. Thanks in advance

Equin commented 2 years ago

@showdpro, @Equin not include in readme?? bp.connect(this); //Connection required based on google Version 4 for inapp lib

Its ok? I am checking and I see that it does not mention in the forked in the readme.

I wanted to ask, I understand that this thread is the one that is being followed now to see if it is possible to update the library, right? for following the correct thread, and I still understand very well how threads work on github.

I am not changed readme because i did code working same like in old version, depending which constructor or method you are using to initialize BillingProcessor it will connect automatically or you should do it manually

edmundoto commented 2 years ago

Hey guys looks like you're super busy on updating this library so forgive me if you've gotten this question 100 times but whats an estimated date for the updated version? I'm stuck until I can get billing updated so an estimate for when I can submit to Google play would be really helpful, appreciate everything you're doing!

ismailnurudeen commented 2 years ago

I'm considering switching to the official Google Play Billing Library but then again I'm feeling too lazy to make this switch across my multiple apps on playstore.

So where are we with this PR? Worth waiting for?

PS: Nov 1st is 3 days away and app updates on playstore takes a couple days (these days).

moisoni97 commented 2 years ago

This was a great library that I have used in my apps but unfortunately, it wasn't updated by the original author @serggl (who knows what he's doing) and the new version just doesn't meet the code quality I expect. Sure, it works, but I want it to be perfect. At some point, I was interested to update this library myself but then I realized it would be much simpler to make a library from scratch and I ended up creating my own billing library. For obvious reasons, I won't post a direct link to my library here but if you are interested to migrate your app ASAP, check my profile. It's not a promo, the library is free and I don't get anything if you use it or not. I have created it in the first place for myself.

serggl commented 2 years ago

Is this the proper place for consuming purchases? In my understanding it should be called within consumePurchase method with is a part of library's public API. Right now consumePurchase does not actually consuming.

According to the google billing library : This method also enables your app to make the one-time product available for purchase again. In our case here we are using it for both the OTP and Subs. The medthod can also be used for acknowledging and consuming purchases.

@showdpro Historically this library separates consume/purchase processes, so let us keep it. There are a lot of breaking changes here besides that

edmundoto commented 2 years ago

Says a lot about how google does things that we have to build libraries to simplify the convoluted android official libraries, in my 10 years developing android this has been a constant theme

serggl commented 2 years ago

@Equin I was finally able to fix my test setup and tried the update. Purchase/Subscribe features worked perfectly, however Consume did not work at all. Here's the fixed one, please add it to the PR:

public void consumePurchaseAsync(final String productId, final IPurchasesResponseListener listener)
    {
        if (!isConnected())
        {
            reportPurchasesError(listener);
        }

        try
        {
            TransactionDetails transaction = getPurchaseTransactionDetails(productId, cachedProducts);
            if (transaction != null && !TextUtils.isEmpty(transaction.purchaseInfo.purchaseData.purchaseToken))
            {
                ConsumeParams consumeParams =
                        ConsumeParams.newBuilder()
                                     .setPurchaseToken(transaction.purchaseInfo.purchaseData.purchaseToken)
                                     .build();

                billingService.consumeAsync(consumeParams, new ConsumeResponseListener()
                {
                    @Override
                    public void onConsumeResponse(@NonNull BillingResult billingResult, @NonNull String purchaseToken)
                    {
                        if (billingResult.getResponseCode() == BillingClient.BillingResponseCode.OK)
                        {
                            cachedProducts.remove(productId);
                            Log.d(LOG_TAG, "Successfully consumed " + productId + " purchase.");

                            reportPurchasesSuccess(listener);
                        } else {
                            Log.d(LOG_TAG, "Failure consume " + productId + " purchase.");
                            reportBillingError(Constants.BILLING_ERROR_CONSUME_FAILED, new Exception(billingResult.getDebugMessage()));
                            reportPurchasesError(listener);
                        }
                    }
                });
            }
        }
        catch (Exception e)
        {
            Log.e(LOG_TAG, "Error in consumePurchase", e);
            reportBillingError(Constants.BILLING_ERROR_CONSUME_FAILED, e);
            reportPurchasesError(listener);
        }
    }

Waiting for the last updates from you while I will try/fix the maven central deploy

Again, great job guys @Equin @showdpro

Equin commented 2 years ago

@serggl thanks for reviewing and help, i pushed new changes

Equin commented 2 years ago

This was a great library that I have used in my apps but unfortunately, it wasn't updated by the original author @serggl (who knows what he's doing) and the new version just doesn't meet the code quality I expect. Sure, it works, but I want it to be perfect. At some point, I was interested to update this library myself but then I realized it would be much simpler to make a library from scratch and I ended up creating my own billing library. For obvious reasons, I won't post a direct link to my library here but if you are interested to migrate your app ASAP, check my profile. It's not a promo, the library is free and I don't get anything if you use it or not. I have created it in the first place for myself.

Hi, i saw your lib when i needed to update my project with v4 billing library, your lib not bad but its not support subscription upgrade and subscription cancel (it support, but as i can see it just opening google play page), and thats not what i need. So i decided to change current librarry for myself and help to upgrade it. Maybe someday someone can make it more cleaner so it will meet your code quality.

oceanox commented 2 years ago

@serggl is now ready the library to use? I am seeing the Readme that the version number of the implement is still the same, they will not change it to differentiate the library, we continue using the same then? These instructions are still valid to implement the new library then? Thanks! dependencies { implementation 'com.anjlab.android.iab.v3:library:1.0.44' }

serggl commented 2 years ago

I will do some basic cleanup in the project, update README and push it to maven central later today. New version to use will be 2.0.0

oceanox commented 2 years ago

I will do some basic cleanup in the project, update README and push it to maven central later today. New version to use will be 2.0.0

ok, then I'll wait XD. A crazy weekend awaits us to update our apps :)

@serggl I understand that everything remains the same and that we would only have to update the library number in our projects? Because the use from what I see is still the same, it has not changed. certain?

showdpro commented 2 years ago

@Equin I was finally able to fix my test setup and tried the update. Purchase/Subscribe features worked perfectly, however Consume did not work at all. Here's the fixed one, please add it to the PR:

public void consumePurchaseAsync(final String productId, final IPurchasesResponseListener listener)
  {
      if (!isConnected())
      {
          reportPurchasesError(listener);
      }

      try
      {
          TransactionDetails transaction = getPurchaseTransactionDetails(productId, cachedProducts);
          if (transaction != null && !TextUtils.isEmpty(transaction.purchaseInfo.purchaseData.purchaseToken))
          {
              ConsumeParams consumeParams =
                      ConsumeParams.newBuilder()
                                   .setPurchaseToken(transaction.purchaseInfo.purchaseData.purchaseToken)
                                   .build();

              billingService.consumeAsync(consumeParams, new ConsumeResponseListener()
              {
                  @Override
                  public void onConsumeResponse(@NonNull BillingResult billingResult, @NonNull String purchaseToken)
                  {
                      if (billingResult.getResponseCode() == BillingClient.BillingResponseCode.OK)
                      {
                          cachedProducts.remove(productId);
                          Log.d(LOG_TAG, "Successfully consumed " + productId + " purchase.");

                          reportPurchasesSuccess(listener);
                      } else {
                          Log.d(LOG_TAG, "Failure consume " + productId + " purchase.");
                          reportBillingError(Constants.BILLING_ERROR_CONSUME_FAILED, new Exception(billingResult.getDebugMessage()));
                          reportPurchasesError(listener);
                      }
                  }
              });
          }
      }
      catch (Exception e)
      {
          Log.e(LOG_TAG, "Error in consumePurchase", e);
          reportBillingError(Constants.BILLING_ERROR_CONSUME_FAILED, e);
          reportPurchasesError(listener);
      }
  }

Waiting for the last updates from you while I will try/fix the maven central deploy

Again, great job guys @Equin @showdpro

@serggl Great job too, for ensuring the library got all it takes to serve the users as they expected. @Equin You are wonderful, great one for contributing. it takes a lot of time having to go through all the codes before updating. And that's greatly done. Thanks to all other contributors to the thread. Great one!

I'm also waiting for the maven update myself.

serggl commented 2 years ago

v2.0.0 was just pushed to maven central. README updated accordingly Migration plan / breaking changes were listed here.

Good luck for everyone still planning to upgrade!

moisoni97 commented 2 years ago

This was a great library that I have used in my apps but unfortunately, it wasn't updated by the original author @serggl (who knows what he's doing) and the new version just doesn't meet the code quality I expect. Sure, it works, but I want it to be perfect. At some point, I was interested to update this library myself but then I realized it would be much simpler to make a library from scratch and I ended up creating my own billing library. For obvious reasons, I won't post a direct link to my library here but if you are interested to migrate your app ASAP, check my profile. It's not a promo, the library is free and I don't get anything if you use it or not. I have created it in the first place for myself.

Hi, i saw your lib when i needed to update my project with v4 billing library, your lib not bad but its not support subscription upgrade and subscription cancel (it support, but as i can see it just opening google play page), and thats not what i need. So i decided to change current librarry for myself and help to upgrade it. Maybe someday someone can make it more cleaner so it will meet your code quality.

Don't get me wrong, if @serggl finally approved the pull request after all these months and changes, it means that now is all right and up to his standards which is good (he is a very skilled individual). I didn't follow the project in particular but I was speaking about the first pull request attempt which was in my opinion a big mess, not following the base code style, and was made in a more "barbaric way" just to work. That's why I said about code quality and the fact that it took a few months to finish really prove my point.

ismailnurudeen commented 2 years ago

Great Job @showdpro @Equin @serggl 👏🏾 👏🏾 👏🏾

oceanox commented 2 years ago

Thank you very much, great job! @showdpro @Equin @serggl

qijaz221 commented 2 years ago

Great job getting this out before the deadline @Equin @showdpro @serggl 👍 Last month was kind of thrill watching this thread.

@oceanox There are some breaking changes, they are pretty simple and here's the migration guide: https://github.com/anjlab/android-inapp-billing-v3/blob/master/UPGRADING.md

RozeKurhy commented 2 years ago

Thank you very much!!!!!!!!!!! @showdpro @Equin @serggl

doganmur commented 2 years ago

Thank you very much, great job! @showdpro @Equin @serggl

ysnsyhn commented 2 years ago

Thanks a lot .@showdpro @Equin @serggl

Where is the "Give a cup of coffee" Button :)