BillingResult.cs 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. using Godot;
  2. using Godot.Collections;
  3. namespace AndroidInAppPurchasesWithCSharp.GodotGooglePlayBilling
  4. {
  5. // https://developer.android.com/reference/com/android/billingclient/api/BillingClient.BillingResponseCode
  6. public enum BillingResponseCode
  7. {
  8. // The request has reached the maximum timeout before Google Play responds.
  9. ServiceTimeout = -3,
  10. // Requested feature is not supported by Play Store on the current device.
  11. FeatureNotSupported = -2,
  12. // Play Store service is not connected now - potentially transient state.
  13. ServiceDisconnected = -1,
  14. // Success
  15. Ok = 0,
  16. // User pressed back or canceled a dialog
  17. UserCanceled = 1,
  18. // Network connection is down
  19. ServiceUnavailable = 2,
  20. // Billing API version is not supported for the type requested
  21. BillingUnavailable = 3,
  22. // Requested product is not available for purchase
  23. ItemUnavailable = 4,
  24. // Invalid arguments provided to the API.
  25. DeveloperError = 5,
  26. // Fatal error during the API action
  27. Error = 6,
  28. // Failure to purchase since item is already owned
  29. ItemAlreadyOwned = 7,
  30. // Failure to consume since item is not owned
  31. ItemNotOwned = 8,
  32. }
  33. public partial class BillingResult
  34. {
  35. public BillingResult() { }
  36. public BillingResult(Dictionary billingResult)
  37. {
  38. try
  39. {
  40. Status = (int)billingResult["status"];
  41. ResponseCode = (billingResult.Contains("response_code") ? (BillingResponseCode?)billingResult["response_code"] : null);
  42. DebugMessage = (billingResult.Contains("debug_message") ? (string)billingResult["debug_message"] : null);
  43. }
  44. catch (System.Exception ex)
  45. {
  46. GD.Print("BillingResult: ", ex.ToString());
  47. }
  48. }
  49. public int Status { get; set; }
  50. public BillingResponseCode? ResponseCode { get; set; }
  51. public string DebugMessage { get; set; }
  52. }
  53. }