SkuDetails.cs 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. using System;
  2. using Godot;
  3. using Godot.Collections;
  4. namespace AndroidInAppPurchasesWithCSharp.GodotGooglePlayBilling
  5. {
  6. public partial class SkuDetails
  7. {
  8. public SkuDetails() { }
  9. public SkuDetails(Dictionary skuDetails)
  10. {
  11. foreach (var key in skuDetails.Keys)
  12. {
  13. try
  14. {
  15. switch (key)
  16. {
  17. case "sku":
  18. Sku = (string)skuDetails[key];
  19. break;
  20. case "title":
  21. Title = (string)skuDetails[key];
  22. break;
  23. case "description":
  24. Description = (string)skuDetails[key];
  25. break;
  26. case "price":
  27. Price = (string)skuDetails[key];
  28. break;
  29. case "price_currency_code":
  30. PriceCurrencyCode = (string)skuDetails[key];
  31. break;
  32. case "price_amount_micros":
  33. PriceAmountMicros = Convert.ToInt64(skuDetails[key]);
  34. break;
  35. case "free_trial_period":
  36. FreeTrialPeriod = (string)skuDetails[key];
  37. break;
  38. case "icon_url":
  39. IconUrl = (string)skuDetails[key];
  40. break;
  41. case "introductory_price":
  42. IntroductoryPrice = (string)skuDetails[key];
  43. break;
  44. case "introductory_price_amount_micros":
  45. IntroductoryPriceAmountMicros = Convert.ToInt64(skuDetails[key]);
  46. break;
  47. case "introductory_price_cycles":
  48. IntroductoryPriceCycles = (int)skuDetails[key];
  49. break;
  50. case "introductory_price_period":
  51. IntroductoryPricePeriod = (string)skuDetails[key];
  52. break;
  53. case "original_price":
  54. OriginalPrice = (string)skuDetails[key];
  55. break;
  56. case "original_price_amount_micros":
  57. OriginalPriceAmountMicros = Convert.ToInt64(skuDetails[key]);
  58. break;
  59. case "subscription_period":
  60. SubscriptionPeriod = (string)skuDetails[key];
  61. break;
  62. case "type":
  63. switch(skuDetails[key])
  64. {
  65. case "inapp":
  66. Type = PurchaseType.InApp;
  67. break;
  68. case "subs":
  69. Type = PurchaseType.Subs;
  70. break;
  71. }
  72. break;
  73. }
  74. }
  75. catch (System.Exception ex)
  76. {
  77. GD.Print("Error: ", skuDetails[key], " -> ", ex.ToString());
  78. }
  79. }
  80. }
  81. public string Sku { get; set; }
  82. public string Title { get; set; }
  83. public string Description { get; set; }
  84. public string Price { get; set; }
  85. public string PriceCurrencyCode { get; set; }
  86. public long PriceAmountMicros { get; set; }
  87. public string FreeTrialPeriod { get; set; }
  88. public string IconUrl { get; set; }
  89. public string IntroductoryPrice { get; set; }
  90. public long IntroductoryPriceAmountMicros { get; set; }
  91. public int IntroductoryPriceCycles { get; set; }
  92. public string IntroductoryPricePeriod { get; set; }
  93. public string OriginalPrice { get; set; }
  94. public long OriginalPriceAmountMicros { get; set; }
  95. public string SubscriptionPeriod { get; set; }
  96. public PurchaseType Type { get; set; }
  97. }
  98. }