diff --git a/docs/CheckAndRestorePurchases.md b/docs/CheckAndRestorePurchases.md index 52f55a3..2a964d4 100644 --- a/docs/CheckAndRestorePurchases.md +++ b/docs/CheckAndRestorePurchases.md @@ -12,7 +12,10 @@ Task> GetPurchasesAsync(ItemType itemType); When you make a call to restore a purchase it will prompt for the user to sign in if they haven't yet, so take that into consideration. -Note, that on iOS this will only return your non-consumables, consumables are not tracked at all and your app should handle these situations +Note, that on iOS this will only return your non-consumables, consumables that have already been `finished` are not tracked at all and your app should handle these situations. + +On iOS, we auto finish all transactions when you get purchases. If you have any consumables you should pass in a `List` with ids that you do not want finished. + Example: ```csharp @@ -30,12 +33,15 @@ public async Task WasItemPurchased(string productId) } //check purchases - var purchases = await billing.GetPurchasesAsync(ItemType.InAppPurchase); + var idsToNotFinish = new List(new [] {"myconsumable"}); + + var purchases = await billing.GetPurchasesAsync(ItemType.InAppPurchase, idsToNotFinish); //check for null just incase if(purchases?.Any(p => p.ProductId == productId) ?? false) { //Purchase restored + // if on Android may be good to return true; } else @@ -64,7 +70,7 @@ public async Task WasItemPurchased(string productId) ## Subscriptions -On `Android` only valid on-going subscriptions will be returned. `iOS` returns all receipts for all instances of the subscripitions. Read the iOS documentation to learn more on strategies. +On `Android` only valid on-going subscriptions will be returned (with the original purchase date). `iOS` returns all receipts for all instances of the subscripitions. Read the iOS documentation to learn more on strategies. Learn more about `IInAppBillingVerifyPurchase` in the [Securing Purchases](SecuringPurchases.md) documentation. diff --git a/docs/GetProductDetails.md b/docs/GetProductDetails.md index 0b22aab..23d06f5 100644 --- a/docs/GetProductDetails.md +++ b/docs/GetProductDetails.md @@ -11,14 +11,11 @@ After creating the in-app purchase items in the respective app store you can the /// List of products Task> GetProductInfoAsync(ItemType itemType, params string[] productIds); ``` -Note that you have to specify an `ItemType` for each call. This means you have to query your `InAppPurchase` and `Subscriptio`n items in multiple calls to the API. Additionally, the `productIds` must be specified in the app, there is no way to query the In-App Billing service to just say "give me everything". +Note that you have to specify an `ItemType` for each call. This means you have to query your `InAppPurchase` and `Subscription` items in multiple calls to the API. Additionally, the `productIds` must be specified in the app, there is no way to query the In-App Billing service to just say "give me everything". - You will receive back a list of your products that you specified the `productIds` for with the following information: + You will receive back a list of your products that you specified the `productIds` for with common information including: ```csharp -/// -/// Product being offered -/// public class InAppBillingProduct { /// @@ -31,6 +28,7 @@ public class InAppBillingProduct /// public string Description { get; set; } + /// /// Product ID or sku /// @@ -52,9 +50,24 @@ public class InAppBillingProduct /// This value represents the localized, rounded price for a particular currency. /// public Int64 MicrosPrice { get; set; } + + /// + /// Extra information for apple platforms + /// + public InAppBillingProductAppleExtras AppleExtras { get; set; } = null; + /// + /// Extra information for Android platforms + /// + public InAppBillingProductAndroidExtras AndroidExtras { get; set; } = null; + /// + /// Extra information for Windows platforms + /// + public InAppBillingProductWindowsExtras WindowsExtras { get; set; } = null; + } - ``` +``` +This information should be enough for most users, however there are all sorts of special things that each platforms return. That is why there are `AppleExtras`, `AndroidExtras`, and `WindowsExtras`. Each of these return special properties for things like discounts, sales, introductory offers, and subscription group information. Example: ```csharp diff --git a/docs/PurchaseConsumable.md b/docs/PurchaseConsumable.md index 7f89008..df6c10a 100644 --- a/docs/PurchaseConsumable.md +++ b/docs/PurchaseConsumable.md @@ -10,10 +10,12 @@ Each app store calls them something slightly different: All purchases go through the `PurchaseAsync` method and you must always `ConnectAsync` before making calls and `DisconnectAsync` after making calls. Consumables are unique and work a bit different on each platform and the `ConsumePurchaseAsync` may need to be called after making the purchase: -* Apple: As soon as you purchase they are consumed +* Apple: You must consume the purchase (this finishes the transaction), starting in 5.x and 6.x will not auto do this. * Android: You must consume before purchasing again * Microsoft: You must consume before purchasing again +The reason for forcing you to consume is that some platforms will not receive the consumable purchase based when getting them. For this reason, we have introduced `ItemType.InAppPurchaseConsumable` specificaly for iOS. If you pass in `ItemType.InAppPurchase` then it will auto consume the purchase. This is what used to happen in 4.0. + ### Purchase Item ```csharp /// @@ -44,7 +46,7 @@ Task ConsumePurchaseAsync(string productId, string purchas Example: ```csharp -public async Task PurchaseItem(string productId, string payload) +public async Task PurchaseItem(string productId) { var billing = CrossInAppBilling.Current; try @@ -57,7 +59,7 @@ public async Task PurchaseItem(string productId, string payload) } //check purchases - var purchase = await billing.PurchaseAsync(productId, ItemType.InAppPurchase); + var purchase = await billing.PurchaseAsync(productId, ItemType.InAppPurchaseConsumable); //possibility that a null came through. if(purchase == null) @@ -66,16 +68,13 @@ public async Task PurchaseItem(string productId, string payload) } else if(purchase.State == PurchaseState.Purchased) { - //purchased, we can now consume the item or do it later - - //If we are on iOS we are done, else try to consume the purchase - //Device.RuntimePlatform comes from Xamarin.Forms, you can also use a conditional flag or the DeviceInfo plugin - if(Device.RuntimePlatform == Device.iOS) - return true; + // purchased, we can now consume the item or do it later + // here you may want to call your backend or process something in your app. + - var consumedItem = await CrossInAppBilling.Current.ConsumePurchaseAsync(purchase.ProductId, purchase.PurchaseToken); + var wasConsumed = await CrossInAppBilling.Current.ConsumePurchaseAsync(purchase.ProductId, purchase.PurchaseToken); - if(consumedItem != null) + if(wasConsumed) { //Consumed!! } diff --git a/docs/PurchaseNonConsumable.md b/docs/PurchaseNonConsumable.md index a3a1f5f..7323e82 100644 --- a/docs/PurchaseNonConsumable.md +++ b/docs/PurchaseNonConsumable.md @@ -25,7 +25,7 @@ On Android you must call `AcknowledgePurchaseAsync` within 3 days when a purchas Example: ```csharp -public async Task PurchaseItem(string productId, string payload) +public async Task PurchaseItem(string productId) { var billing = CrossInAppBilling.Current; try diff --git a/docs/PurchaseSubscription.md b/docs/PurchaseSubscription.md index 375e71d..e2bde04 100644 --- a/docs/PurchaseSubscription.md +++ b/docs/PurchaseSubscription.md @@ -49,7 +49,7 @@ public async Task PurchaseItem(string productId, string payload) } else { - //purchased! + //purchased! if(Device.RuntimePlatform == Device.Android) { // Must call AcknowledgePurchaseAsync else the purchase will be refunded diff --git a/src/Plugin.InAppBilling/Shared/InAppBillingProduct.shared.cs b/src/Plugin.InAppBilling/Shared/InAppBillingProduct.shared.cs index 2e767c8..cf8c483 100644 --- a/src/Plugin.InAppBilling/Shared/InAppBillingProduct.shared.cs +++ b/src/Plugin.InAppBilling/Shared/InAppBillingProduct.shared.cs @@ -179,11 +179,11 @@ public class InAppBillingProduct /// public InAppBillingProductAppleExtras AppleExtras { get; set; } = null; /// - /// Extra infor for Android platforms + /// Extra information for Android platforms /// public InAppBillingProductAndroidExtras AndroidExtras { get; set; } = null; /// - /// Extra infor for Windows platforms + /// Extra information for Windows platforms /// public InAppBillingProductWindowsExtras WindowsExtras { get; set; } = null;