Skip to content

ish-1313/InAppBillingPlugin

 
 

Repository files navigation

In-App Billing Plugin for Xamarin and Windows

A simple In-App Purchase plugin for Xamarin and Windows to query item information, purchase items, restore items, and more.

Documentation

Get started by reading through the In-App Billing Plugin documentation.

There are changes in version 4.0 so read below.

NuGet

Dev Feed: https://ci.appveyor.com/nuget/inappbillingplugin

Build Status

Build status

Platform Support

Platform Version
Xamarin.iOS iOS 8+
tvOS - Apple TV All
Xamarin.Android API 14+
Windows 10 UWP 10+

Created By: @JamesMontemagno

Checkout my podcast on IAP

I co-host a weekly development podcast, Merge Conflict, about technology and recently covered IAP and this library: Merge Conflict 28: Demystifying In-App Purchases

Version 4 Major Update - Android

We now use Xamarin.Essentials for getting access to the current activity. So ensure you initialize Xamarin.Essentials in your Android app.

Also if you get a null exception the linker is being aggressive so write the following code in your MainActivity:

var context = Platform.AppContext;
var activity = Platform.CurrentActivity;

Version 4.X updates to the new Android billing client. This means there are few important changes:

  1. You must acknowledge all purchases within 3 days, by calling AcknowledgePurchaseAsync or the Consume API if it a consumable.
  2. You must hanle Pending Transactions from outside of you app. See docs from Google
  3. HandleActivityResult is removed from the API as it is not needed

Pending Transactions:

  • If the result of PurchaseAsync is PurchaseState.PaymentPending, store the order details locally and inform the user that they will have access to the product when the payment completes
  • When the user starts the app (and/or visits a particular page), if the stored PurchaseState is PaymentPending, call GetPurchasesAsync and query the result for a purchase that matches the stored purchase.
  • If the PurchaseState for this purchase is still PaymentPending, show the same no-access message
  • If the PurchaseState is Purchased, call ConsumePurchaseAsync or AcknowledgePurchaseAsync, depending on the product type

I highly recommend reading the entire Google Play Billing System docs.

Version 3+ Linker Settings

For linking if you are setting Link All you may need to add:

Android:

Plugin.InAppBilling;Xamarin.Android.Google.BillingClient;

iOS:

--linkskip=Plugin.InAppBilling

License

The MIT License (MIT), see LICENSE file.

Want To Support This Project?

All I have ever asked is to be active by submitting bugs, features, and sending those pull requests down! Want to go further? Make sure to subscribe to my weekly development podcast Merge Conflict, where I talk all about awesome Xamarin goodies and you can optionally support the show by becoming a supporter on Patreon.

About

Cross-platform In App Billing Plugin for Xamarin

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C# 90.4%
  • PowerShell 7.1%
  • Shell 2.5%