jamesmontemagno / InAppBillingPlugin

Cross-platform In App Billing Plugin for .NET
MIT License
651 stars 152 forks source link

iOS done but now Google PlayStore Connectivity Issues #334

Closed blmiles closed 3 years ago

blmiles commented 3 years ago

Hello.

Glad to say after much fiddling, the iOS app is in the App Store with all approved, incl. IAPs. Yet to be released. IAPs all work and I'll post my findings on all once I get PlayStore working too. Hint: you cannot use InAppBilling as-is but it certainly helps the effort.

New issue:

FYI, this is a Xamarin Forms solution with an iOS, Android and Shared project. I am trying to use the Beta 4.0.1 version of this InAppBilling plugin.

I have followed the examples and looked at the test code in the repo and cannot get the InAppBilling plugin to connect to the PlayStore.

In the Main activity on OnCreate() one of these two lines I believe are needed: CrossCurrentActivity.Current.Init(this, bundle); OR Plugin.CurrentActivity.CrossCurrentActivity.Current.Activity = this;

I've tried both.

This always returns false on trying to connect to the PlayStore: var connected = await billing.ConnectAsync(true);

In previous versions of this plugin, the connection call was different: var connected = await billing.ConnectAsync(ItemType.Subscription);

When this line is reached in checking for a purchase: var purchases = await billing.GetPurchasesAsync(ItemType.Subscription);

I get this error: {Plugin.InAppBilling.InAppBillingPurchaseException: Unable to process purchase. at Plugin.InAppBilling.InAppBillingImplementation.ParseBillingResult (Android.BillingClient.Api.BillingResult result) [0x0005d] in D:\a\1\s\src\Plugin.InAppBilling\InAppBilling.android.cs:331 at Plugin.InAppBilling.InAppBillingImplementation.GetPurchasesAsync (Plugin.InAppBilling.ItemType itemType) [0x00035] in D:\a\1\s\src\Plugin.InAppBilling\InAppBilling.android.cs:186 at mycompany.Services.BillingService.CheckOrRestoreSubscription () [0x000d4] in D:\Projects\Solutions\mycompany\mycompany.Shared\Services\BillingService.cs:98 }

OR this line in making a purchase: var purchase = await billing.PurchaseAsync(productId, ItemType.Subscription, verify);

I get this error: {Plugin.InAppBilling.InAppBillingPurchaseException: You are not connected to the Google Play App store. at Plugin.InAppBilling.InAppBillingImplementation.PurchaseAsync (System.String productId, Plugin.InAppBilling.ItemType itemType, Plugin.InAppBilling.IInAppBillingVerifyPurchase verifyPurchase) [0x0002b] in D:\a\1\s\src\Plugin.InAppBilling\InAppBilling.android.cs:203 at mycompany.Services.BillingService.Subscribe (System.String productId) [0x000f3] in D:\Projects\Solutions\mycompany\mycompany.Shared\Services\BillingService.cs:42 }

Just so you know, the app .apk is uploaded into the PlayStore and the Subscription items added and activated.

OBVIOUSLY I'm missing something.

Can someone please provide insight into why this might not be connecting to the PlayStore? Is there some other parameter or setting needed to allow a connection?

blmiles commented 3 years ago

Solved. Just for those who are unaware.

In iOS, when a purchase is made, one gets to login with their Apple ID to complete the purchase. In Android, one needs to be logged into the PlayStore BEFORE a purchase can be made.

Once I got the test account logged in on the test device, this connection worked: var connected = await billing.ConnectAsync(true);

Now there seems to be a different issue... the PlayStore returns msg "[productSKU] does not exist". But that subscription item is clearly in the PlayStore and activated.

Does anyone know why this cannot be found? And yes, I've double checked and triple checked that the right SKU was being passed in in this: var purchase = await billing.PurchaseAsync(productId, ItemType.Subscription, verify);

Is there any other obscure setting in the PlayStore that would cause this item to not be found? Anyone know?

Thanks

blmiles commented 3 years ago

Unlike the App Store, one can only access IAPs in the PlayStore from a RELEASE build of the app on a hard device... There are ways to mess with the app signing etc but I don't want to go there.