akshaaatt / Google-IAP

Android Library for easing Google Play Billing to your apps with support for Subscriptions, Non-Consumable and Consumable Purchases with a beautiful sample app.
https://play.google.com/store/apps/details?id=com.redalck.gameone
GNU General Public License v3.0
237 stars 56 forks source link

onProductPurchased not called immediately (for consumable SKUs) #45

Open sagarvasnani opened 3 years ago

sagarvasnani commented 3 years ago

Hey there. The event onProductPurchased() is not being triggered (immediately) on completion of a consumable SKU. It's only called when I reopen the app.

iapConnector = new IapConnector(this, Collections.emptyList(), consumableSKUs, subscriptionSKUs, key, true);

iapConnector.addPurchaseListener(new PurchaseServiceListener() {
    @Override
    public void onProductPurchased(@NotNull DataWrappers.PurchaseInfo purchaseInfo) {
        thankUser();
    }

    @Override
    public void onProductRestored(@NotNull DataWrappers.PurchaseInfo purchaseInfo) {
    }

    @Override
    public void onPricesUpdated(@NotNull Map<String, String> map) {
        updatePrices(map);
    }
});
JVeverGiveUp commented 3 years ago

@sagarvasnani Have you found solution for this issue? I also get many bad rating because of this. User purchased and they want premium features immediately. If the app delay, they think that we scam.

akshaaatt commented 3 years ago

I have tested and have not faced this problem. Make sure that you are using a proper thread to control the UI in onProductPurchased if you want to send a toast or anything to the user on successful completion. Knowledge of Android basics is a prerequisite while using this library!

sagarvasnani commented 3 years ago

Hey, thanks for the reply. There's not a lot of difference between your (Java) sample and my activity. This issue has less to do with the threads or UI changes that show up after purchase. The onProductPurchased event is just not called -- I've tried with a debugger, and I have tried with Logs. Interestingly, everything works perfectly fine for subscriptions.

If I reinitialize the purchase of the consumable, Google Play returns with the error "You already own this item". For some background, I am not a beginner. I've been an Android dev for over 5 years now. So I've tried a bunch of things to confirm that this is not an implementation issue.

Thanks for your help!

akshaaatt commented 3 years ago

@sagarvasnani Thank you for bringing this up! I will have to thoroughly check regarding this and that can take a while since I am caught up with a lot of stuff right now. We will resolve this soon though.

jmimohsin commented 2 years ago

I am using com.github.akshaaatt:Google-IAP:1.1.7 and facing same problem with consumable product. New version not working with Java project.

jmimohsin commented 2 years ago

@akshaaatt Please check it as it's happening.... https://play.google.com/store/apps/details?id=daily.maza.earn.money

Send gift to user and you will get it.

jmimohsin commented 2 years ago

Can you please update about it or I need to use another SDK? This issue is open from 1 year and it is not a normal bug.

chris-houston commented 2 years ago

I am also having this same issue using the latest version. It seems onProductPurchased is not getting called right when the purchase is successful. Is there any update? I'll have to switch to another SDK if this isn't working and I'd love to keep using this

jdleung commented 1 year ago

I got the same problem, onProductPurchased is not getting called after purchase completed.

And I got error "You already own this item" when click to purchase again.

jmimohsin commented 1 year ago

Admin, plz take care about this problem asap. It's not a minor bug.

jdleung commented 1 year ago

The following is from Google Play Billing document Consumable products, just don't know if this is the case. On my side, it did occasionally succeeded.

Note: Because consumption requests can occasionally fail, you must check your secure backend server to ensure that each purchase token hasn't been used so your app doesn't grant entitlement multiple times for the same purchase. Alternatively, your app can wait until you receive a successful consumption response from Google Play before granting entitlement. If you choose to withhold purchases from the user until Google Play sends a successful consumption response, you must be very careful not to lose track of the purchases for which you have sent a consumption request.

akshaaatt commented 1 year ago

Can you please update to the latest and confirm whether this issue has been resolved or not?

jdleung commented 1 year ago

Can you please update to the latest and confirm whether this issue has been resolved or not?

No, the problem still exists in the latest release.

My app structure: Activity1 --> Activity2 IAP is initialized in Activity2, when onProductPurchased is not called, go back to Activity1 and start Activity2 again, onProductPurchased is called.

When the purchase completed and onProductPurchased is not called, IAP throws an error. By now, I added an error listener to show a popup view indicate the problem on consumable purchase, user can choose reload to purchase again, and then receive an error You already own this item (onProductPurchased is called).

jmimohsin commented 1 year ago

@akshaaatt any update on this issue as I am going to update my apps. It would be helpful.

DennyWeinberg commented 1 year ago

Same issue here! I upgraded to 1.2.4 because I want to use billing v5, but onProductPurchased isn't called anymore! Then, when I purchase again, "you already own the item" is raised. 1.2.2 worked jus tfine

csbenz commented 7 months ago

Same problem here, as described by others. Been getting many bad reviews because of it. I'll move away from this library as it doesn't work correctly.