payment-request.idl (4477B)
1 // GENERATED CONTENT - DO NOT EDIT 2 // Content was automatically extracted by Reffy into webref 3 // (https://github.com/w3c/webref) 4 // Source: Payment Request API (https://w3c.github.io/payment-request/) 5 6 [SecureContext, Exposed=Window] 7 interface PaymentRequest : EventTarget { 8 constructor( 9 sequence<PaymentMethodData> methodData, 10 PaymentDetailsInit details, 11 optional PaymentOptions options = {} 12 ); 13 [NewObject] 14 Promise<PaymentResponse> show(optional Promise<PaymentDetailsUpdate> detailsPromise); 15 [NewObject] 16 Promise<undefined> abort(); 17 [NewObject] 18 Promise<boolean> canMakePayment(); 19 20 readonly attribute DOMString id; 21 readonly attribute ContactAddress? shippingAddress; 22 readonly attribute DOMString? shippingOption; 23 readonly attribute PaymentShippingType? shippingType; 24 25 attribute EventHandler onshippingaddresschange; 26 attribute EventHandler onshippingoptionchange; 27 attribute EventHandler onpaymentmethodchange; 28 }; 29 30 dictionary PaymentMethodData { 31 required DOMString supportedMethods; 32 object data; 33 }; 34 35 dictionary PaymentCurrencyAmount { 36 required DOMString currency; 37 required DOMString value; 38 }; 39 40 dictionary PaymentDetailsBase { 41 sequence<PaymentItem> displayItems; 42 sequence<PaymentShippingOption> shippingOptions; 43 sequence<PaymentDetailsModifier> modifiers; 44 }; 45 46 dictionary PaymentDetailsInit : PaymentDetailsBase { 47 DOMString id; 48 required PaymentItem total; 49 }; 50 51 dictionary PaymentDetailsUpdate : PaymentDetailsBase { 52 DOMString error; 53 PaymentItem total; 54 AddressErrors shippingAddressErrors; 55 PayerErrors payerErrors; 56 object paymentMethodErrors; 57 }; 58 59 dictionary PaymentDetailsModifier { 60 required DOMString supportedMethods; 61 PaymentItem total; 62 sequence<PaymentItem> additionalDisplayItems; 63 object data; 64 }; 65 66 enum PaymentShippingType { 67 "shipping", 68 "delivery", 69 "pickup" 70 }; 71 72 dictionary PaymentOptions { 73 boolean requestPayerName = false; 74 boolean requestBillingAddress = false; 75 boolean requestPayerEmail = false; 76 boolean requestPayerPhone = false; 77 boolean requestShipping = false; 78 PaymentShippingType shippingType = "shipping"; 79 }; 80 81 dictionary PaymentItem { 82 required DOMString label; 83 required PaymentCurrencyAmount amount; 84 boolean pending = false; 85 }; 86 87 dictionary PaymentCompleteDetails { 88 object? data = null; 89 }; 90 91 enum PaymentComplete { 92 "fail", 93 "success", 94 "unknown" 95 }; 96 97 dictionary PaymentShippingOption { 98 required DOMString id; 99 required DOMString label; 100 required PaymentCurrencyAmount amount; 101 boolean selected = false; 102 }; 103 104 [SecureContext, Exposed=Window] 105 interface PaymentResponse : EventTarget { 106 [Default] object toJSON(); 107 108 readonly attribute DOMString requestId; 109 readonly attribute DOMString methodName; 110 readonly attribute object details; 111 readonly attribute ContactAddress? shippingAddress; 112 readonly attribute DOMString? shippingOption; 113 readonly attribute DOMString? payerName; 114 readonly attribute DOMString? payerEmail; 115 readonly attribute DOMString? payerPhone; 116 117 [NewObject] 118 Promise<undefined> complete( 119 optional PaymentComplete result = "unknown", 120 optional PaymentCompleteDetails details = {} 121 ); 122 [NewObject] 123 Promise<undefined> retry(optional PaymentValidationErrors errorFields = {}); 124 125 attribute EventHandler onpayerdetailchange; 126 }; 127 128 dictionary PaymentValidationErrors { 129 PayerErrors payer; 130 AddressErrors shippingAddress; 131 DOMString error; 132 object paymentMethod; 133 }; 134 135 dictionary PayerErrors { 136 DOMString email; 137 DOMString name; 138 DOMString phone; 139 }; 140 141 dictionary AddressErrors { 142 DOMString addressLine; 143 DOMString city; 144 DOMString country; 145 DOMString dependentLocality; 146 DOMString organization; 147 DOMString phone; 148 DOMString postalCode; 149 DOMString recipient; 150 DOMString region; 151 DOMString sortingCode; 152 }; 153 154 [SecureContext, Exposed=Window] 155 interface PaymentMethodChangeEvent : PaymentRequestUpdateEvent { 156 constructor(DOMString type, optional PaymentMethodChangeEventInit eventInitDict = {}); 157 readonly attribute DOMString methodName; 158 readonly attribute object? methodDetails; 159 }; 160 161 dictionary PaymentMethodChangeEventInit : PaymentRequestUpdateEventInit { 162 DOMString methodName = ""; 163 object? methodDetails = null; 164 }; 165 166 [SecureContext, Exposed=Window] 167 interface PaymentRequestUpdateEvent : Event { 168 constructor(DOMString type, optional PaymentRequestUpdateEventInit eventInitDict = {}); 169 undefined updateWith(Promise<PaymentDetailsUpdate> detailsPromise); 170 }; 171 172 dictionary PaymentRequestUpdateEventInit : EventInit {};