Google-IAP icon indicating copy to clipboard operation
Google-IAP copied to clipboard

onProductPurchased not called immediately (for consumable SKUs)

Open sagarvasnani opened this issue 4 years ago • 16 comments

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);
	}
});

sagarvasnani avatar Jul 04 '21 23:07 sagarvasnani

@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.

JVeverGiveUp avatar Jul 06 '21 23:07 JVeverGiveUp

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!

akshaaatt avatar Jul 07 '21 11:07 akshaaatt

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!

sagarvasnani avatar Jul 07 '21 13:07 sagarvasnani

@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.

akshaaatt avatar Jul 07 '21 13:07 akshaaatt

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 avatar Jun 13 '22 06:06 jmimohsin

@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 avatar Jun 13 '22 06:06 jmimohsin

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.

jmimohsin avatar Jun 14 '22 07:06 jmimohsin

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

chris-houston avatar Jun 21 '22 21:06 chris-houston

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.

jdleung avatar May 15 '23 02:05 jdleung

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

jmimohsin avatar May 15 '23 10:05 jmimohsin

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.

jdleung avatar May 17 '23 01:05 jdleung

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

akshaaatt avatar Jun 04 '23 07:06 akshaaatt

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).

jdleung avatar Jun 05 '23 01:06 jdleung

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

jmimohsin avatar Jun 14 '23 07:06 jmimohsin

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

DennyWeinberg avatar Jul 03 '23 08:07 DennyWeinberg

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.

csbenz avatar Dec 05 '23 08:12 csbenz