jamesmontemagno / InAppBillingPlugin

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

v7 Android subscription with free trial fail #559

Closed Nick1611 closed 1 year ago

Nick1611 commented 1 year ago

Bug Information

Version Number of Plugin: 7.0.5 Device Tested On: Simulator Tested On: API 31 Version of VS: 2022 Version of Xamarin: 17.5.0.173 Versions of other things you are using:

I posted this issue under another thread (https://github.com/jamesmontemagno/InAppBillingPlugin/pull/532#issue-1696554673) a couple of weeks ago. That seems to be ignored so I open a new one. Sorry if it caused any confusion.

My xamarin.android project target API 33. I am testing migration from version 5 to 7.0.5. I found issues with subscription items (monthly & yearly) with free trial for users who never had any subscription.

Test case 1: User who had subscription, free trial is not eligible. Product LocalizedPrice & MicrosPrice can be retrieved correctly. Product subscription works.

Test case 2: User who never had any subscription, free trial is available. The product.AndroidExtras…PricingPhase contains 2 records:

BillingPeriod “P1W”, PriceAmountMicros “0” BillingPeriod “P1M” (or “P1Y” for yearly subscription), PriceAmountMicros “99”

Issue 1: In change “Return info of first sub into default info for simplicity”, “var firstSub = subs?.FirstOrDefault()?.PricingPhases?.FirstOrDefault()” returns the first pricing phase would get the free trial phase of 0. It is better to return the first pricing phase where PriceAmountMicros != 0.

Issue 2 (critical): When execute “CrossInAppBilling.Current.PurchaseAsync(productId, ItemType.Subscription)”, Google prompt error on device “This version of the application is not configured for billing through Google Play. Check the help center for more information”.

It ended up with InAppBillingPurchaseException:

PurchaseError: “Plugin.InAppBilling.PurchaseError.DeveloperError”, message: "Unable to process purchase."

It seems that more information is required to be passed into Google Play for subscription with eligible free trial.

Thanks,

Nick

jamesmontemagno commented 1 year ago

Thanks nick, i will make the change for PriceAmountMicros != 0 this makes sense.

I am not sure about the second issue.... seems like something isn't configured on the backend?

You may need to pass in the offercode on purchase?