Skip to content

Commit

Permalink
Add cancellation tokens to the interface (break everything)
Browse files Browse the repository at this point in the history
  • Loading branch information
aritchie committed May 8, 2024
1 parent 9779278 commit 2f6241a
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions src/Plugin.InAppBilling/Shared/IInAppBilling.shared.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;

namespace Plugin.InAppBilling
Expand Down Expand Up @@ -37,50 +38,50 @@ public interface IInAppBilling : IDisposable
/// </summary>
/// <param name="transactionIdentifier"></param>
/// <returns>if all were acknowledged/finalized</returns>
Task<IEnumerable<(string Id, bool Success)>> FinalizePurchaseAsync(params string[] transactionIdentifier);
Task<IEnumerable<(string Id, bool Success)>> FinalizePurchaseAsync(string[] transactionIdentifier, CancellationToken cancellationToken = default);

/// <summary>
/// Manually acknowledge/finalize a product id
/// </summary>
/// <param name="productIds"></param>
/// <returns>if all were acknowledged/finalized</returns>
Task<IEnumerable<(string Id, bool Success)>> FinalizePurchaseOfProductAsync(params string[] productIds);
Task<IEnumerable<(string Id, bool Success)>> FinalizePurchaseOfProductAsync(string[] productIds, CancellationToken cancellationToken = default);


/// <summary>
/// Connect to billing service
/// </summary>
/// <returns>If Success</returns>
Task<bool> ConnectAsync(bool enablePendingPurchases = true);
Task<bool> ConnectAsync(bool enablePendingPurchases = true, CancellationToken cancellationToken = default);

/// <summary>
/// Disconnect from the billing service
/// </summary>
/// <returns>Task to disconnect</returns>
Task DisconnectAsync();
Task DisconnectAsync(CancellationToken cancellationToken = default);

/// <summary>
/// Get product information of a specific product
/// </summary>
/// <param name="itemType">Type of product offering</param>
/// <param name="productIds">Sku or Id of the product(s)</param>
/// <returns>List of products</returns>
Task<IEnumerable<InAppBillingProduct>> GetProductInfoAsync(ItemType itemType, params string[] productIds);
Task<IEnumerable<InAppBillingProduct>> GetProductInfoAsync(ItemType itemType, string[] productIds, CancellationToken cancellationToken = default);

/// <summary>
/// Get all current purchases for a specific product type. If you use verification and it fails for some purchase, it's not contained in the result.
/// </summary>
/// <param name="itemType">Type of product</param>
/// <returns>The current purchases</returns>
Task<IEnumerable<InAppBillingPurchase>> GetPurchasesAsync(ItemType itemType);
Task<IEnumerable<InAppBillingPurchase>> GetPurchasesAsync(ItemType itemType, CancellationToken cancellationToken = default);


/// <summary>
/// Android only: Returns the most recent purchase made by the user for each SKU, even if that purchase is expired, canceled, or consumed.
/// </summary>
/// <param name="itemType">Type of product</param>
/// <returns>The current purchases</returns>
Task<IEnumerable<InAppBillingPurchase>> GetPurchasesHistoryAsync(ItemType itemType);
Task<IEnumerable<InAppBillingPurchase>> GetPurchasesHistoryAsync(ItemType itemType, CancellationToken cancellationToken = default);

/// <summary>
/// Purchase a specific product or subscription
Expand All @@ -91,7 +92,7 @@ public interface IInAppBilling : IDisposable
/// <param name="obfuscatedProfileId">Android: Specifies an optional obfuscated string that is uniquely associated with the user's profile in your app.</param>
/// <returns>Purchase details</returns>
/// <exception cref="InAppBillingPurchaseException">If an error occurs during processing</exception>
Task<InAppBillingPurchase> PurchaseAsync(string productId, ItemType itemType, string obfuscatedAccountId = null, string obfuscatedProfileId = null, string subOfferToken = null);
Task<InAppBillingPurchase> PurchaseAsync(string productId, ItemType itemType, string obfuscatedAccountId = null, string obfuscatedProfileId = null, string subOfferToken = null, CancellationToken cancellationToken = default);

/// <summary>
/// (Android specific) Upgrade/Downgrade a previously purchased subscription
Expand All @@ -101,7 +102,7 @@ public interface IInAppBilling : IDisposable
/// <param name="prorationMode">Proration mode (1 - ImmediateWithTimeProration, 2 - ImmediateAndChargeProratedPrice, 3 - ImmediateWithoutProration, 4 - Deferred)</param>
/// <returns>Purchase details</returns>
/// <exception cref="InAppBillingPurchaseException">If an error occurs during processing</exception>
Task<InAppBillingPurchase> UpgradePurchasedSubscriptionAsync(string newProductId, string purchaseTokenOfOriginalSubscription, SubscriptionProrationMode prorationMode = SubscriptionProrationMode.ImmediateWithTimeProration);
Task<InAppBillingPurchase> UpgradePurchasedSubscriptionAsync(string newProductId, string purchaseTokenOfOriginalSubscription, SubscriptionProrationMode prorationMode = SubscriptionProrationMode.ImmediateWithTimeProration, CancellationToken cancellationToken = default);

/// <summary>
/// Consume a purchase with a purchase token.
Expand All @@ -110,7 +111,7 @@ public interface IInAppBilling : IDisposable
/// <param name="transactionIdentifier">Original Purchase Token</param>
/// <returns>If consumed successful</returns>
/// <exception cref="InAppBillingPurchaseException">If an error occurs during processing</exception>
Task<bool> ConsumePurchaseAsync(string productId, string transactionIdentifier);
Task<bool> ConsumePurchaseAsync(string productId, string transactionIdentifier, CancellationToken cancellationToken = default);

/// <summary>
/// Get receipt data on iOS
Expand Down

0 comments on commit 2f6241a

Please sign in to comment.