Skip to content

Commit

Permalink
add introductory price android
Browse files Browse the repository at this point in the history
  • Loading branch information
Philippe Creytens committed Mar 5, 2018
1 parent 52833c0 commit 0caadb6
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 4 deletions.
19 changes: 19 additions & 0 deletions src/Plugin.InAppBilling.Abstractions/InAppBillingProduct.cs
Expand Up @@ -41,6 +41,25 @@ public class InAppBillingProduct
/// </summary>
public Int64 MicrosPrice { get; set; }

/// <summary>
/// Gets or sets the localized introductory price.
/// </summary>
/// <value>The localized introductory price.</value>
public string LocalizedIntroductoryPrice { get; set; }

/// <summary>
/// Introductory price of the product in micor-units
/// </summary>
/// <value>The introductory price.</value>
public Int64 MicrosIntroductoryPrice { get; set; }

/// <summary>
/// Gets a value indicating whether this <see cref="T:Plugin.InAppBilling.Abstractions.InAppBillingProduct"/>
/// has introductory price. This is an optional value in the answer from the server, requires a boolean to check if this exists
/// </summary>
/// <value><c>true</c> if has introductory price; otherwise, <c>false</c>.</value>
public bool HasIntroductoryPrice => !string.IsNullOrEmpty(LocalizedIntroductoryPrice);

}

}
22 changes: 18 additions & 4 deletions src/Plugin.InAppBilling.Android/InAppBillingImplementation.cs
Expand Up @@ -105,7 +105,9 @@ public async override Task<IEnumerable<InAppBillingProduct>> GetProductInfoAsync
CurrencyCode = product.CurrencyCode,
LocalizedPrice = product.Price,
ProductId = product.ProductId,
MicrosPrice = product.MicrosPrice
MicrosPrice = product.MicrosPrice,
LocalizedIntroductoryPrice = product.IntroductoryPrice,
MicrosIntroductoryPrice = product.IntroductoryPriceAmountMicros
});
}

Expand Down Expand Up @@ -711,9 +713,21 @@ public Product()
[JsonProperty(PropertyName = "price_amount_micros")]
public Int64 MicrosPrice { get; set; }

public override string ToString()
{
return string.Format("[Product: Title={0}, Price={1}, Type={2}, Description={3}, ProductId={4}]", Title, Price, Type, Description, ProductId);
[JsonProperty(PropertyName = "introductoryPrice")]
public string IntroductoryPrice { get; set; }

// 0 is default if this property is not set
[JsonProperty(PropertyName = "introductoryPriceAmountMicros")]
public Int64 IntroductoryPriceAmountMicros { get; set; }

[JsonProperty(PropertyName = "introductoryPricePeriod")]
public string IntroductoryPricePeriod { get; set; }

[JsonProperty(PropertyName = "introductoryPriceCycles")]
public int IntroductoryPriceCycles { get; set; }

public override string ToString() {
return string.Format("[Product: Title={0}, Price={1}, Type={2}, Description={3}, ProductId={4}, CurrencyCode={5}, MicrosPrice={6}, IntroductoryPrice={7}, IntroductoryPriceAmountMicros={8}, IntroductoryPricePeriod={9}, IntroductoryPriceCycles={10}]", Title, Price, Type, Description, ProductId, CurrencyCode, MicrosPrice, IntroductoryPrice, IntroductoryPriceAmountMicros, IntroductoryPricePeriod, IntroductoryPriceCycles);
}
}

Expand Down

0 comments on commit 0caadb6

Please sign in to comment.