blob: 81b2e883576caca3265b59ff74ab0c87054f92d7 [file] [log] [blame]
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// This file is versioned solely for the convenience of sharing struct and enum
// definitions with with an external repository. Do not add any
// browser <-> renderer specific definitions or any browser <-> external
// repository specific definitions in this file.
// Specifically interfaces defined here must not be versioned.
// Next MinVersion: 1
module payments.mojom;
import "components/payments/mojom/payment_request_data.mojom";
import "mojo/public/mojom/base/time.mojom";
// https://github.com/WICG/digital-goods/blob/master/explainer.md
// Allow the renderer to talk to an associated digital goods backend.
interface DigitalGoods {
// Queries the associated backend for information about one or more items.
GetDetails(array<string> item_ids)
=> (BillingResponseCode code, array<ItemDetails> item_details_list);
// Informs the associated backend that the purchase identified by
// |purchase_token| was successfully acknowledged. If |make_available_again|
// is true, indicates that the purchase is repeatable (e.g. a consumable
// item). If it is false, indicates that the purchase is one-off (e.g. a
// permanent upgrade).
Acknowledge(string purchase_token, bool make_available_again)
=> (BillingResponseCode code);
// Queries the associated backend for information on all items that are
// currently owned by the user.
ListPurchases()
=> (BillingResponseCode code,
array<PurchaseDetails> purchase_details_list);
};
// Allow the renderer to request a |DigitalGoods| instance. DigitalGoods
// instances must be created via this factory to allow the backend to validate
// the current context.
interface DigitalGoodsFactory {
// Creates a DigitalGoods instance. The |digital_goods| is non-null iff
// |code| == kOk.
CreateDigitalGoods(string payment_method)
=> (CreateDigitalGoodsResponseCode code,
pending_remote<DigitalGoods>? digital_goods);
};
[Extensible]
enum BillingResponseCode {
kOk,
kError,
kItemAlreadyOwned,
kItemNotOwned,
kItemUnavailable,
kClientAppUnavailable,
kClientAppError,
};
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;
};
[Extensible]
enum CreateDigitalGoodsResponseCode {
kOk,
kError,
kUnsupportedPaymentMethod,
kUnsupportedContext,
};
struct PurchaseDetails {
string item_id;
string purchase_token;
bool acknowledged;
PurchaseState purchase_state;
// Microseconds since the Unix epoch.
mojo_base.mojom.TimeDelta purchase_time;
bool will_auto_renew;
};
[Extensible]
enum PurchaseState {
kUnknown,
kPurchased,
kPending,
};