Skip to content

Commit

Permalink
Add in obfuscated properties
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesmontemagno committed May 5, 2021
1 parent 39cda2a commit 5e0c3e3
Show file tree
Hide file tree
Showing 8 changed files with 951 additions and 6,605 deletions.
4 changes: 3 additions & 1 deletion docs/PurchaseConsumable.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@ Consumables are unique and work a bit different on each platform and the `Consum
/// <param name="productId">Sku or ID of product</param>
/// <param name="itemType">Type of product being requested</param>
/// <param name="verifyPurchase">Verify Purchase implementation</param>
/// <param name="obfuscatedAccountId">Specifies an optional obfuscated string that is uniquely associated with the user's account in your app.</param>
/// <param name="obfuscatedProfileId">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 occures during processing</exception>
Task<InAppBillingPurchase> PurchaseAsync(string productId, ItemType itemType, IInAppBillingVerifyPurchase verifyPurchase = null);
Task<InAppBillingPurchase> PurchaseAsync(string productId, ItemType itemType, IInAppBillingVerifyPurchase verifyPurchase = null, string obfuscatedAccountId = null, string obfuscatedProfileId = null);
```

### Consume Purchase
Expand Down
4 changes: 3 additions & 1 deletion docs/PurchaseSubscription.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@ All purchases go through the `PurchaseAsync` method and you must always `Connect
/// <param name="productId">Sku or ID of product</param>
/// <param name="itemType">Type of product being requested</param>
/// <param name="verifyPurchase">Verify Purchase implementation</param>
/// <param name="obfuscatedAccountId">Specifies an optional obfuscated string that is uniquely associated with the user's account in your app.</param>
/// <param name="obfuscatedProfileId">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 occures during processing</exception>
Task<InAppBillingPurchase> PurchaseAsync(string productId, ItemType itemType, IInAppBillingVerifyPurchase verifyPurchase = null);
Task<InAppBillingPurchase> PurchaseAsync(string productId, ItemType itemType, IInAppBillingVerifyPurchase verifyPurchase = null, string obfuscatedAccountId = null, string obfuscatedProfileId = null);
```

On Android you must call `AcknowledgePurchaseAsync` within 3 days when a purchase is validated. Please read the [Android documentation on Pending Transactions](https://developer.android.com/google/play/billing/integrate#pending) for more information.
Expand Down
7,474 changes: 902 additions & 6,572 deletions src/InAppBillingTests/InAppBillingTests.Android/Resources/Resource.designer.cs

Large diffs are not rendered by default.

24 changes: 16 additions & 8 deletions src/Plugin.InAppBilling/InAppBilling.android.cs
Original file line number Diff line number Diff line change
Expand Up @@ -193,10 +193,11 @@ public override Task<IEnumerable<InAppBillingPurchase>> GetPurchasesAsync(ItemTy
/// </summary>
/// <param name="productId">Sku or ID of product</param>
/// <param name="itemType">Type of product being requested</param>
/// <param name="payload">Developer specific payload (can not be null)</param>
/// <param name="verifyPurchase">Interface to verify purchase</param>
/// <param name="obfuscatedAccountId">Specifies an optional obfuscated string that is uniquely associated with the user's account in your app.</param>
/// <param name="obfuscatedProfileId">Specifies an optional obfuscated string that is uniquely associated with the user's profile in your app.</param>
/// <returns></returns>
public async override Task<InAppBillingPurchase> PurchaseAsync(string productId, ItemType itemType, IInAppBillingVerifyPurchase verifyPurchase = null)
public async override Task<InAppBillingPurchase> PurchaseAsync(string productId, ItemType itemType, IInAppBillingVerifyPurchase verifyPurchase = null, string obfuscatedAccountId = null, string obfuscatedProfileId = null)
{
if (BillingClient == null || !IsConnected)
{
Expand All @@ -213,18 +214,18 @@ public async override Task<InAppBillingPurchase> PurchaseAsync(string productId,
switch (itemType)
{
case ItemType.InAppPurchase:
return await PurchaseAsync(productId, BillingClient.SkuType.Inapp, verifyPurchase);
return await PurchaseAsync(productId, BillingClient.SkuType.Inapp, verifyPurchase, obfuscatedAccountId, obfuscatedProfileId);
case ItemType.Subscription:

var result = BillingClient.IsFeatureSupported(BillingClient.FeatureType.Subscriptions);
ParseBillingResult(result);
return await PurchaseAsync(productId, BillingClient.SkuType.Subs, verifyPurchase);
return await PurchaseAsync(productId, BillingClient.SkuType.Subs, verifyPurchase, obfuscatedAccountId, obfuscatedProfileId);
}

return null;
}

async Task<InAppBillingPurchase> PurchaseAsync(string productSku, string itemType, IInAppBillingVerifyPurchase verifyPurchase)
async Task<InAppBillingPurchase> PurchaseAsync(string productSku, string itemType, IInAppBillingVerifyPurchase verifyPurchase, string obfuscatedAccountId = null, string obfuscatedProfileId = null)
{

var skuDetailsParams = SkuDetailsParams.NewBuilder()
Expand All @@ -240,9 +241,16 @@ async Task<InAppBillingPurchase> PurchaseAsync(string productSku, string itemTyp
if (skuDetails == null)
throw new ArgumentException($"{productSku} does not exist");

var flowParams = BillingFlowParams.NewBuilder()
.SetSkuDetails(skuDetails)
.Build();
var flowParamsBuilder = BillingFlowParams.NewBuilder()
.SetSkuDetails(skuDetails);

if (!string.IsNullOrWhiteSpace(obfuscatedAccountId))
flowParamsBuilder.SetObfuscatedAccountId(obfuscatedAccountId);

if (!string.IsNullOrWhiteSpace(obfuscatedProfileId))
flowParamsBuilder.SetObfuscatedProfileId(obfuscatedProfileId);

var flowParams = flowParamsBuilder.Build();

tcsPurchase = new TaskCompletionSource<(BillingResult billingResult, IList<Android.BillingClient.Api.Purchase> purchases)>();
var responseCode = BillingClient.LaunchBillingFlow(Activity, flowParams);
Expand Down
19 changes: 10 additions & 9 deletions src/Plugin.InAppBilling/InAppBilling.apple.cs
Original file line number Diff line number Diff line change
Expand Up @@ -176,15 +176,16 @@ static SKPaymentTransaction FindOriginalTransaction(SKPaymentTransaction transac



/// <summary>
/// Purchase a specific product or subscription
/// </summary>
/// <param name="productId">Sku or ID of product</param>
/// <param name="itemType">Type of product being requested</param>
/// <param name="payload">Developer specific payload</param>
/// <param name="verifyPurchase">Interface to verify purchase</param>
/// <returns></returns>
public async override Task<InAppBillingPurchase> PurchaseAsync(string productId, ItemType itemType, IInAppBillingVerifyPurchase verifyPurchase = null)
/// <summary>
/// Purchase a specific product or subscription
/// </summary>
/// <param name="productId">Sku or ID of product</param>
/// <param name="itemType">Type of product being requested</param>
/// <param name="verifyPurchase">Interface to verify purchase</param>
/// <param name="obfuscatedAccountId">Specifies an optional obfuscated string that is uniquely associated with the user's account in your app.</param>
/// <param name="obfuscatedProfileId">Specifies an optional obfuscated string that is uniquely associated with the user's profile in your app.</param>
/// <returns></returns>
public async override Task<InAppBillingPurchase> PurchaseAsync(string productId, ItemType itemType, IInAppBillingVerifyPurchase verifyPurchase = null, string obfuscatedAccountId = null, string obfuscatedProfileId = null)
{
var p = await PurchaseAsync(productId);

Expand Down
5 changes: 3 additions & 2 deletions src/Plugin.InAppBilling/InAppBilling.uwp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,12 @@ public async override Task<IEnumerable<InAppBillingPurchase>> GetPurchasesAsync(
/// </summary>
/// <param name="productId">Sku or ID of product</param>
/// <param name="itemType">Type of product being requested</param>
/// <param name="payload">Developer specific payload</param>
/// <param name="verifyPurchase">Verify purchase implementation</param>
/// <param name="obfuscatedAccountId">Specifies an optional obfuscated string that is uniquely associated with the user's account in your app.</param>
/// <param name="obfuscatedProfileId">Specifies an optional obfuscated string that is uniquely associated with the user's profile in your app.</param>
/// <returns></returns>
/// <exception cref="InAppBillingPurchaseException">If an error occurs during processing</exception>
public async override Task<InAppBillingPurchase> PurchaseAsync(string productId, ItemType itemType, IInAppBillingVerifyPurchase verifyPurchase = null)
public async override Task<InAppBillingPurchase> PurchaseAsync(string productId, ItemType itemType, IInAppBillingVerifyPurchase verifyPurchase = null, string obfuscatedAccountId = null, string obfuscatedProfileId = null)
{
// Get purchase result from store or simulator
var purchaseResult = await CurrentAppMock.RequestProductPurchaseAsync(InTestingMode, productId);
Expand Down
21 changes: 11 additions & 10 deletions src/Plugin.InAppBilling/Shared/BaseInAppBilling.shared.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,17 @@ public abstract class BaseInAppBilling : IInAppBilling, IDisposable
/// <returns>The current purchases</returns>
public abstract Task<IEnumerable<InAppBillingPurchase>> GetPurchasesAsync(ItemType itemType);

/// <summary>
/// Purchase a specific product or subscription
/// </summary>
/// <param name="productId">Sku or ID of product</param>
/// <param name="itemType">Type of product being requested</param>
/// <param name="payload">Developer specific payload</param>
/// <param name="verifyPurchase">Verify Purchase implementation</param>
/// <returns>Purchase details</returns>
/// <exception cref="InAppBillingPurchaseException">If an error occures during processing</exception>
public abstract Task<InAppBillingPurchase> PurchaseAsync(string productId, ItemType itemType, IInAppBillingVerifyPurchase verifyPurchase = null);
/// <summary>
/// Purchase a specific product or subscription
/// </summary>
/// <param name="productId">Sku or ID of product</param>
/// <param name="itemType">Type of product being requested</param>
/// <param name="verifyPurchase">Verify Purchase implementation</param>
/// <param name="obfuscatedAccountId">Specifies an optional obfuscated string that is uniquely associated with the user's account in your app.</param>
/// <param name="obfuscatedProfileId">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 occures during processing</exception>
public abstract Task<InAppBillingPurchase> PurchaseAsync(string productId, ItemType itemType, IInAppBillingVerifyPurchase verifyPurchase = null, string obfuscatedAccountId = null, string obfuscatedProfileId = null);

/// <summary>
/// Consume a purchase with a purchase token.
Expand Down
5 changes: 3 additions & 2 deletions src/Plugin.InAppBilling/Shared/IInAppBilling.shared.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,12 @@ public interface IInAppBilling : IDisposable
/// </summary>
/// <param name="productId">Sku or ID of product</param>
/// <param name="itemType">Type of product being requested</param>
/// <param name="payload">Developer specific payload (can not be null)</param>
/// <param name="verifyPurchase">Verify Purchase implementation</param>
/// <param name="obfuscatedAccountId">Specifies an optional obfuscated string that is uniquely associated with the user's account in your app.</param>
/// <param name="obfuscatedProfileId">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 occures during processing</exception>
Task<InAppBillingPurchase> PurchaseAsync(string productId, ItemType itemType, IInAppBillingVerifyPurchase verifyPurchase = null);
Task<InAppBillingPurchase> PurchaseAsync(string productId, ItemType itemType, IInAppBillingVerifyPurchase verifyPurchase = null, string obfuscatedAccountId = null, string obfuscatedProfileId = null);

/// <summary>
/// Consume a purchase with a purchase token.
Expand Down

0 comments on commit 5e0c3e3

Please sign in to comment.