1 /* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
4 * You can obtain one at http://mozilla.org/MPL/2.0/.
6 * The origin of this WebIDL file is
7 * https://w3c.github.io/payment-request/#paymentrequest-interface
8 * https://w3c.github.io/payment-request/#idl-index
10 * Copyright © 2018 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
11 * liability, trademark and document use rules apply.
14 dictionary PaymentMethodData {
15 required DOMString supportedMethods;
19 dictionary PaymentCurrencyAmount {
20 required DOMString currency;
21 required DOMString value;
24 dictionary PaymentItem {
25 required DOMString label;
26 required PaymentCurrencyAmount amount;
27 boolean pending = false;
30 dictionary PaymentShippingOption {
31 required DOMString id;
32 required DOMString label;
33 required PaymentCurrencyAmount amount;
34 boolean selected = false;
37 dictionary PaymentDetailsModifier {
38 required DOMString supportedMethods;
40 sequence<PaymentItem> additionalDisplayItems;
44 dictionary PaymentDetailsBase {
45 sequence<PaymentItem> displayItems;
46 sequence<PaymentShippingOption> shippingOptions;
47 sequence<PaymentDetailsModifier> modifiers;
50 dictionary PaymentDetailsInit : PaymentDetailsBase {
52 required PaymentItem total;
55 [GenerateInitFromJSON, GenerateToJSON]
56 dictionary AddressErrors {
57 DOMString addressLine;
60 DOMString dependentLocality;
61 DOMString organization;
67 DOMString sortingCode;
70 dictionary PaymentValidationErrors {
72 AddressErrors shippingAddress;
77 [GenerateInitFromJSON, GenerateToJSON]
78 dictionary PayerErrors {
84 dictionary PaymentDetailsUpdate : PaymentDetailsBase {
86 AddressErrors shippingAddressErrors;
87 PayerErrors payerErrors;
88 object paymentMethodErrors;
92 enum PaymentShippingType {
98 dictionary PaymentOptions {
99 boolean requestPayerName = false;
100 boolean requestPayerEmail = false;
101 boolean requestPayerPhone = false;
102 boolean requestShipping = false;
103 boolean requestBillingAddress = false;
104 PaymentShippingType shippingType = "shipping";
108 Func="mozilla::dom::PaymentRequest::PrefEnabled",
110 interface PaymentRequest : EventTarget {
112 constructor(sequence<PaymentMethodData> methodData,
113 PaymentDetailsInit details,
114 optional PaymentOptions options = {});
117 Promise<PaymentResponse> show(optional Promise<PaymentDetailsUpdate> detailsPromise);
119 Promise<void> abort();
121 Promise<boolean> canMakePayment();
123 readonly attribute DOMString id;
124 readonly attribute PaymentAddress? shippingAddress;
125 readonly attribute DOMString? shippingOption;
126 readonly attribute PaymentShippingType? shippingType;
128 attribute EventHandler onmerchantvalidation;
129 attribute EventHandler onshippingaddresschange;
130 attribute EventHandler onshippingoptionchange;
131 attribute EventHandler onpaymentmethodchange;