chromium/third_party/blink/public/mojom/digital_goods/digital_goods.mojom

// Copyright 2020 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

module payments.mojom;

import "components/digital_goods/mojom/digital_goods.mojom";

// https://github.com/WICG/digital-goods/blob/main/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);

  // Queries the associated backend for information on all items that are
  // currently owned by the user. May include unconfirmed purchases.
  ListPurchases()
      => (BillingResponseCode code,
          array<PurchaseReference> purchase_reference_list);

  // Queries the associated backend for information on the latest purchase for
  // each item type ever purchased by the user. May include expired or consumed
  // purchases.
  ListPurchaseHistory()
      => (BillingResponseCode code,
          array<PurchaseReference> purchase_reference_list);

  // Informs the associated backend that the purchase identified by
  // |purchase_token| was used up.
  Consume(string purchase_token) => (BillingResponseCode code);
};

// 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);
};