jamesmontemagno / InAppBillingPlugin

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

Handling IAP Promotional Offers in the App Store #335

Closed blmiles closed 3 years ago

blmiles commented 3 years ago

Hello,

As expected, handling IAP Promotional Offers in the App Store is problematic.

To enable a "Trial Period" in the App, one needs to add a Promotional Offer to any IAP, as you know. I have two approved IAPs in the App Store and a Promotional Offer on each, app is approved for release too.

Purchasing an IAP, I pass in the IAP productId, the purchase completes with no issues. However, when I pass in the IAP-Promotional-Offer productId, I get an unknown error in the InAppBilling plugin.

Bug Information

Version Number of Plugin: Beta 4.0.1 Device Tested On: iPad Mini 5th Gen Simulator Tested On: Version of VS: 16.8.2 Version of Xamarin: Xamarin Forms - 4.8.0.1560 Versions of other things you are using:

Steps to reproduce the Behavior

Add a Promotional Offer to an IAP in the APP Store and try to use that Promotional Offer productID and NOT the IAP productID

Expected Behavior

Complete the purchase of the IAP Promotional Offer, get a "purchase" object returned with all the correct trial-period information properly set in the PurchaseToken.

Actual Behavior

This is the error I get in VS: {Plugin.InAppBilling.InAppBillingPurchaseException: An unknown error occurred 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.apple.cs:168 at mycompany.Services.BillingService.Subscribe (System.String productId) [0x000f3] in D:\Projects\Solutions\mycompany\mycompany.Shared\Services\BillingService.cs:41 }

Code snippet

var purchase = await billing.PurchaseAsync(productId, ItemType.Subscription, verify);

Screenshotst

Can someone please offer advice on this? Do we "purchase" IAP Promotional Offers in the same way as IAPs? Am I missing a step?

Thanks

blmiles commented 3 years ago

OK, so it looks like using Promotional Offers on an IAP to achieve a trial period is NOT the way to do things.

I added an Introductory Offer on each of the IAPs with a two-week free period. Testing shows the info in the PurchaseToken "IsTrialPeriod" = true. Also, the app-store popup on the device shows it's a trial period and the date on which the first charge applies.

For my purposes, that'll suffice.

Hope this helps someone albeit not directly plugin related but trying to catch all the loose ends dealing with this and the variations in the app stores is quite the challenge.

Thank you

blmiles commented 3 years ago

OK, so it looks like using Promotional Offers on an IAP to achieve a trial period is NOT the way to do things.

I added an Introductory Offer on each of the IAPs with a two-week free period. Testing shows the info in the PurchaseToken "IsTrialPeriod" = true. Also, the app-store popup on the device shows it's a trial period and the date on which the first charge applies.