// Copyright 2022 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// These types are shared between Blink, ARC, and crosapi, so they must conform
// to the requirements of the strictest API and be stable and versioned.
// Next MinVersion: 2
[JavaPackage="org.chromium.payments.mojom"]
module payments.mojom;
import "url/mojom/url.mojom";
import "components/payments/mojom/payment_request_data.mojom";
// Result of Digital Goods operations. The response code is forwarded to the
// renderer, so individual errors don't need to be handled. Any value other than
// |kOK| will result in a JavaScript exception with a description message to aid
// in debugging.
[Extensible, Stable]
enum BillingResponseCode {
// Success.
kOk,
// Unknown error calling a Digital Goods action (a more specific error code
// below is preferred).
[Default] kError,
// Item purchased is already owned.
kItemAlreadyOwned,
// Failure to consume an item since it is not owned.
kItemNotOwned,
// Requested item is not available for purchase.
kItemUnavailable,
// The requested client app is not installed.
kClientAppUnavailable,
// Client app failed to handle Digital Goods message format.
kClientAppError,
};
[Extensible, Stable]
enum ItemType {
[Default] kUnknown,
kProduct,
kSubscription,
};
// Describes an item from a digital goods service provider.
// See https://wicg.github.io/digital-goods/#itemDetails-dictionary
[Stable]
struct ItemDetails {
string item_id;
string title;
string description;
PaymentCurrencyAmount price;
// Periods are specified as ISO 8601 durations.
// https://en.wikipedia.org/wiki/ISO_8601#Durations
string? subscription_period;
string? free_trial_period;
PaymentCurrencyAmount? introductory_price;
string? introductory_price_period;
// Set to 0 for no introductory cycles.
[MinVersion=1] uint32 introductory_price_cycles;
[MinVersion=1] ItemType type;
[MinVersion=1] array<url.mojom.Url>? icon_urls;
};
// Result of creating a Digital Goods service.
[Extensible, Stable]
enum CreateDigitalGoodsResponseCode {
kOk,
[Default] kError,
kUnsupportedPaymentMethod,
kUnsupportedContext,
};
// Describes a specific purchase of an item.
// See https://wicg.github.io/digital-goods/#purchaseDetails-dictionary
[Stable]
struct PurchaseReference {
string item_id;
string purchase_token;
};