digital_goods.mojom 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. // Copyright 2022 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. // These types are shared between Blink, ARC, and crosapi, so they must conform
  5. // to the requirements of the strictest API and be stable and versioned.
  6. // Next MinVersion: 2
  7. [JavaPackage="org.chromium.payments.mojom"]
  8. module payments.mojom;
  9. import "url/mojom/url.mojom";
  10. import "components/payments/mojom/payment_request_data.mojom";
  11. // Result of Digital Goods operations. The response code is forwarded to the
  12. // renderer, so individual errors don't need to be handled. Any value other than
  13. // |kOK| will result in a JavaScript exception with a description message to aid
  14. // in debugging.
  15. [Extensible, Stable]
  16. enum BillingResponseCode {
  17. // Success.
  18. kOk,
  19. // Unknown error calling a Digital Goods action (a more specific error code
  20. // below is preferred).
  21. kError,
  22. // Item purchased is already owned.
  23. kItemAlreadyOwned,
  24. // Failure to consume an item since it is not owned.
  25. kItemNotOwned,
  26. // Requested item is not available for purchase.
  27. kItemUnavailable,
  28. // The requested client app is not installed.
  29. kClientAppUnavailable,
  30. // Client app failed to handle Digital Goods message format.
  31. kClientAppError,
  32. };
  33. [Extensible, Stable]
  34. enum ItemType {
  35. kUnknown,
  36. kProduct,
  37. kSubscription,
  38. };
  39. // Describes an item from a digital goods service provider.
  40. // See https://wicg.github.io/digital-goods/#itemDetails-dictionary
  41. [Stable]
  42. struct ItemDetails {
  43. string item_id;
  44. string title;
  45. string description;
  46. PaymentCurrencyAmount price;
  47. // Periods are specified as ISO 8601 durations.
  48. // https://en.wikipedia.org/wiki/ISO_8601#Durations
  49. string? subscription_period;
  50. string? free_trial_period;
  51. PaymentCurrencyAmount? introductory_price;
  52. string? introductory_price_period;
  53. // Set to 0 for no introductory cycles.
  54. [MinVersion=1] uint32 introductory_price_cycles;
  55. [MinVersion=1] ItemType type;
  56. [MinVersion=1] array<url.mojom.Url>? icon_urls;
  57. };
  58. // Result of creating a Digital Goods service.
  59. [Extensible, Stable]
  60. enum CreateDigitalGoodsResponseCode {
  61. kOk,
  62. kError,
  63. kUnsupportedPaymentMethod,
  64. kUnsupportedContext,
  65. };
  66. // Describes a specific purchase of an item.
  67. // See https://wicg.github.io/digital-goods/#purchaseDetails-dictionary
  68. [Stable]
  69. struct PurchaseReference {
  70. string item_id;
  71. string purchase_token;
  72. };