InAppBillingPlugin
Cross-platform In App Billing Plugin for .NET
Project maintained by jamesmontemagno
Hosted on GitHub Pages — Theme by mattgraham
Testing and Troubleshooting
Integrating and testing In-App Purchases is not an easy task and should go through a lot of testing. I have attempted to simplify the integration part, but the app store side is a bit trickier. Here are my tips and tricks on each platform:
iOS Testing & Troubleshooting
Ensure Contracts are Signed
You will not be able to test any StoreKit functionality until you have an iOS Paid Applications contract – StoreKit calls in your code will fail until Apple has processed your Contracts, Tax, and Banking information.
How to test purchase from TestFlight
- Don’t try to sign-in Settings > iTunes & App Stores
- Log out of iTunes & App Stores (make sure you’re not logged into any account)
- Just open the app you’re trying to test
- Your app will prompt you to sign in
- Enter your credentials for your sandbox test account
- While you could e.g. read your items, you need a real device to test purchasing. NO apis work on Simulators.
Android Testing
- You MUST use a physical device. Emulators do not work.
- Ensure you have app in Alpha/Beta with the NuGet installed. This will add “com.android.vending.BILLING” permission for you
- Create an IAB product, make sure it is published and active
- Add a test account to the app, ensure it is the main account on device, and that account is opted-in as tester
- Validated your version code and number in your development environment match what is in the Play store.
- You MUST sign the APK even in debug mode. In XS this is in the properties. In VS you must manually add this to your project:
<AndroidKeyStore>True</AndroidKeyStore>
<AndroidSigningKeyStore>KeystoreLocation</AndroidSigningKeyStore>
<AndroidSigningStorePass>PASS</AndroidSigningStorePass>
<AndroidSigningKeyAlias>ALIAS</AndroidSigningKeyAlias>
<AndroidSigningKeyPass>PASS</AndroidSigningKeyPass>
Android Troubleshooting
- If you see “You need to sign into your google account”. This most likely means that you don’t have an items published and active for IAB
- If you see “This version of the application is not configured for billing through Google Play”: This means the versions number don’t match or you don’t have the app configured to sign correctly with your keystore.
- If you see “The publisher cannot purchase this item”: This means you are trying to buy it on your developer account, and that isn’t allowed, you need a different account.
Windows Testing & Troubleshooting
- Read Microsoft’s In-app purchases and trials documentation, and see Windows and the Microsoft Store.
- To test against the real Store, your add-ons and app must be published (they can be hidden), your project must be associated with the app in Partner Center, and you must install the app from the Store once to get a license. After that you can debug locally.
PurchaseError.DeveloperError with 0x803F6107 means the Store doesn’t know your app, so the association or license above is missing.
PurchaseError.DeveloperError with 0x80070578 or a missing window message means you need to set InAppBillingImplementation.WindowHandleProvider.
Turning on Testing Mode
Windows.Services.Store has no simulator, so the plugin includes an in-memory one. Nothing is persisted between runs and no money is involved. Add your catalog and turn on InTestingMode:
#if WINDOWS
var simulator = InAppBillingImplementation.Simulator;
simulator.AddProduct("gold", ItemType.InAppPurchase, "Gold", 4.99m);
simulator.AddProduct("potion", ItemType.InAppPurchaseConsumable);
simulator.AddProduct("coins", ItemType.InAppPurchaseConsumable, storeManagedQuantity: 100);
simulator.AddProduct("monthly", ItemType.Subscription, hasTrial: true);
// Optionally force a failure for the next purchase
simulator.NextPurchaseStatus = WindowsStorePurchaseStatus.NetworkError;
#endif
CrossInAppBilling.Current.InTestingMode = true;
Testing mode doesn’t show any Store UI and doesn’t need a packaged app. Make sure it is off in release builds.
<= Back to Table of Contents