From 4ca93c93bb3455c6256034f576fcb71f180388ed Mon Sep 17 00:00:00 2001 From: Marcos Caceres Date: Fri, 11 Nov 2016 17:34:52 +1100 Subject: [PATCH] chore: fix xrefs and dfns --- index.html | 669 +++++++++++++++++++++++++++-------------------------- 1 file changed, 335 insertions(+), 334 deletions(-) diff --git a/index.html b/index.html index 0b27c0fc..402d7e6d 100644 --- a/index.html +++ b/index.html @@ -165,47 +165,48 @@

PaymentRequest interface

- The shippingAddress, shippingOption, - and shippingType attributes - are populated during processing if the requestShipping flag is set. + The shippingAddress, + shippingOption, + and shippingType attributes + are populated during processing if the requestShipping flag is set.

- The [SecureContext] extended attribute means that the PaymentRequest + The [SecureContext] extended attribute means that the PaymentRequest is only exposed within a secure context and won't be accessible elsewhere.

-

The following example shows how to construct a PaymentRequest and begin the +

The following example shows how to construct a PaymentRequest and begin the user interaction:

-
-        var payment = new PaymentRequest(methodData, details, options);
-        payment.addEventListener("shippingaddresschange", function (changeEvent) {
-            // Process shipping address change
-        });
-
-        payment.show().then(function(paymentResponse) {
-          // Process paymentResponse
-          // paymentResponse.methodName contains the selected payment method
-          // paymentResponse.details contains a payment method specific response
-          paymentResponse.complete("success");
-        }).catch(function(err) {
-          console.error("Uh oh, something bad happened", err.message);
-        });
-      
+
+    var payment = new PaymentRequest(methodData, details, options);
+    payment.addEventListener("shippingaddresschange", function (changeEvent) {
+        // Process shipping address change
+    });
+
+    payment.show().then(function(paymentResponse) {
+      // Process paymentResponse
+      // paymentResponse.methodName contains the selected payment method
+      // paymentResponse.details contains a payment method specific response
+      paymentResponse.complete("success");
+    }).catch(function(err) {
+      console.error("Uh oh, something bad happened", err.message);
+    });
+  
-

PaymentRequest constructor

+

Constructor

- The PaymentRequest is constructed using the supplied methodData + The PaymentRequest is constructed using the supplied methodData list including any payment method specific data, the payment details, and the payment options.

-

The methodData sequence contains PaymentMethodData dictionaries +

The methodData sequence contains PaymentMethodData dictionaries containing the payment method identifiers for the payment methods that the web site accepts and any associated payment method specific data.

-
+          
             [
               {
                 supportedMethods: ["visa","bitcoin"]
@@ -222,7 +223,7 @@ 

PaymentRequest constructor

The details object contains information about the transaction that the user is being asked to complete such as the line items in an order.

-
+          
             {
               displayItems: [
                 {
@@ -245,7 +246,7 @@ 

PaymentRequest constructor

The options object contains information about what options the web page wishes to use from the payment request system.

-
+          
             {
               requestShipping: true
             }
@@ -253,73 +254,73 @@ 

PaymentRequest constructor

- The PaymentRequest constructor MUST act as follows: + The PaymentRequest constructor MUST act as follows:

  1. If the length of the methodData sequence is zero, then throw - a TypeError. + a TypeError.
  2. - For each PaymentMethodData dictionary, if the length of the - supportedMethods sequence is zero, then throw a TypeError. + For each PaymentMethodData dictionary, if the length of the + supportedMethods sequence is zero, then throw a TypeError.
  3. If the browsing context of the script calling the constructor is a nested browsing context whose origin is different from the top-level browsing context's origin and the nested browsing context is not allowed to make payment requests, then throw - a SecurityError. + a SecurityError.
  4. If details does not contain a value for total, then throw a - TypeError. + TypeError.
  5. If details.total.amount.value is not a valid decimal monetary value, then throw a - TypeError. + TypeError.
  6. If the first character of details.total.amount.value is U+002D HYPHEN-MINUS, then throw a - TypeError. total MUST be a non-negative amount. + TypeError. total MUST be a non-negative amount.
  7. - If the details.displayItems sequence contains any PaymentItem + If the details.displayItems sequence contains any PaymentItem objects with an amount that is not a valid decimal monetary value, then throw a - TypeError. + TypeError.
  8. - If the details.shippingOptions sequence contains any PaymentShippingOption + If the details.shippingOptions sequence contains any PaymentShippingOption objects with an amount that is not a valid decimal monetary value, then throw a - TypeError. + TypeError.
  9. If details contains a value for error, then throw a - TypeError. + TypeError.
  10. - For each PaymentMethodData in methodData, if the data field - is supplied but is not a JSON-serializable object, then throw a TypeError. + For each PaymentMethodData in methodData, if the data field + is supplied but is not a JSON-serializable object, then throw a TypeError.
  11. - For each PaymentDetailsModifier in details.modifiers, if the total field - is supplied and is not a valid decimal monetary value, then throw a TypeError. + For each PaymentDetailsModifier in details.modifiers, if the total field + is supplied and is not a valid decimal monetary value, then throw a TypeError.
  12. - For each PaymentDetailsModifier in details.modifiers, if the total field + For each PaymentDetailsModifier in details.modifiers, if the total field is supplied and the first character of total.amount.value is U+002D HYPHEN-MINUS, then throw a - TypeError. total MUST be a non-negative amount. + TypeError. total MUST be a non-negative amount.
  13. - For each PaymentDetailsModifier in details.modifiers, if the - additionalDisplayItems sequence contains any PaymentItem + For each PaymentDetailsModifier in details.modifiers, if the + additionalDisplayItems sequence contains any PaymentItem objects with an amount that is not a valid decimal monetary value, then throw a - TypeError. + TypeError.
  14. -
  15. Let request be a new PaymentRequest.
  16. +
  17. Let request be a new PaymentRequest.
  18. Store methodData into request@[[\methodData]].

    - The methodData supplied to the PaymentRequest constructor + The methodData supplied to the PaymentRequest constructor SHOULD be in the order of preference of the caller. Implementations MAY show payment methods in this order if possible but SHOULD prioritize the preference of the user when presenting payment methods. @@ -329,19 +330,19 @@

    PaymentRequest constructor

  19. Store options into request@[[\options]].
  20. Set the value request@[[\state]] to created.
  21. - Set the value of the shippingAddress attribute on request to null. + Set the value of the shippingAddress attribute on request to null.
  22. - Set the value of the shippingOption attribute on request to null. + Set the value of the shippingOption attribute on request to null.
  23. - Set the value of the shippingType attribute on request to null. + Set the value of the shippingType attribute on request to null.
  24. If options.requestShipping is set to true, then set the value of the - shippingType attribute on request to options.shippingType. - If options.shippingType is not a valid PaymentShippingType value - then set the shippingType attribute on request to "shipping". + shippingType attribute on request to options.shippingType. + If options.shippingType is not a valid PaymentShippingType value + then set the shippingType attribute on request to "shipping".
    This behavior allows a page to detect if it supplied an unsupported shipping type. This will be important if new shipping types are added to a future version of this specification but a page is @@ -350,15 +351,15 @@

    PaymentRequest constructor

  25. If the details.shippingOptions sequence contains multiple - PaymentShippingOption objects that have the same id, - then set the shippingOptions field of request@[[\details]] + PaymentShippingOption objects that have the same id, + then set the shippingOptions field of request@[[\details]] to an empty sequence.
  26. If request@[[\details]] contains a shippingOptions sequence and - if any PaymentShippingOption in the sequence + if any PaymentShippingOption in the sequence has the selected field set to true, then set - shippingOption to the id of the last ShippingOption + shippingOption to the id of the last PaymentShippingOption in the sequence with selected set to true.
  27. Set the value request@[[\updating]] to false.
  28. @@ -366,23 +367,23 @@

    PaymentRequest constructor

-
-

show()

+
+

show() method

- The show method is called when the page wants to begin user interaction for the + The show method is called when the page wants to begin user interaction for the payment request. The show method returns a Promise that will be resolved when the user accepts the payment request. Some kind of user interface will be presented to the user to facilitate the payment request after the show method returns.

- The show method MUST act as follows: + The show method MUST act as follows:

  1. - Let request be the PaymentRequest object on which the method is called. + Let request be the PaymentRequest object on which the method is called.
  2. If the value of request@[[\state]] is not created then - throw an InvalidStateError.
  3. + throw an InvalidStateError.
  4. Set the value of request@[[\state]] to interactive.
  5. @@ -397,7 +398,7 @@

    show()

  6. Let supportedMethods be the union of all the supportedMethods sequences from each - PaymentMethodData in the request@[[\methodData]] sequence. + PaymentMethodData in the request@[[\methodData]] sequence.
  7. Let acceptedMethods be supportedMethods with all identifiers removed that the @@ -405,7 +406,7 @@

    show()

  8. If the length of acceptedMethods is zero, then reject acceptPromise with a - NotSupportedError. + NotSupportedError.
  9. Show a user interface to allow the user to interact with the payment request process. The acceptPromise will @@ -414,13 +415,13 @@

    show()

-
-

abort()

+
+

abort() method

- The abort method may be called if the web page wishes to tell the + The abort method may be called if the web page wishes to tell the user agent to abort the payment request and to tear down any user interface that - might be shown. abort can only be called after the show method + might be shown. abort can only be called after the show method has been called and before the request@[[\acceptPromise]] has been resolved. For example, a web page might choose to do this if the goods they are selling are only available for a limited amount of time. If the user does not accept the payment request @@ -433,20 +434,20 @@

abort()

reject the returned Promise.

-

The abort method MUST act as follows:

+

The abort method MUST act as follows:

  1. - Let request be the PaymentRequest object on which the method is called. + Let request be the PaymentRequest object on which the method is called.
  2. If the value of request@[[\state]] is not interactive then - throw an InvalidStateError.
  3. + throw an InvalidStateError.
  4. Let promise be a new Promise.
  5. Return promise and asynchronously perform the remaining steps.
  6. Try to abort the current user interaction and close down any remaining user interface.
  7. If it is not possible to abort the current user interaction, then reject promise - with InvalidStateError and abort this algorithm.
  8. + with InvalidStateError and abort this algorithm.
  9. Set the value of the internal slot request@[[\state]] to closed.
  10. -
  11. Reject the promise request@[[\acceptPromise]] with an AbortError.
  12. +
  13. Reject the promise request@[[\acceptPromise]] with an AbortError.
  14. Resolve promise with undefined.
@@ -458,35 +459,35 @@

State transitions

src="images/state-transitions.svg" width="518" height="125">
-
-

shippingAddress

+
+

shippingAddress attribute

- shippingAddress is populated when the user provides a shipping + shippingAddress is populated when the user provides a shipping address. It is null by default. When a user provides a shipping address, the shipping address changed algorithm runs.

- onshippingaddresschange is an EventHandler for an + onshippingaddresschange is an EventHandler for an Event named shippingaddresschange.

-
-

shippingOption

+
+

shippingOption attribute

- shippingOption is populated when the user chooses a shipping + shippingOption is populated when the user chooses a shipping option. It is null by default. When a user chooses a shipping option, the shipping option changed algorithm runs.

- onshippingoptionchange is an EventHandler for an + onshippingoptionchange is an EventHandler for an Event named shippingoptionchange.

Internal Slots

-

Instances of PaymentRequest are created with the internal slots in +

Instances of PaymentRequest are created with the internal slots in the following table:

@@ -497,13 +498,13 @@

Internal Slots

- + @@ -512,14 +513,14 @@

Internal Slots

@@ -528,31 +529,31 @@

Internal Slots

-
-

PaymentMethodData dictionary

-
-        dictionary PaymentMethodData {
-          required sequence<DOMString> supportedMethods;
-          object data;
-        };
-      
+
+

PaymentMethodData dictionary

+
+    dictionary PaymentMethodData {
+      required sequence<DOMString> supportedMethods;
+      object data;
+    };
+  

- A PaymentMethodData dictionary is used to indicate a set of supported payment + A PaymentMethodData dictionary is used to indicate a set of supported payment methods and any associated payment method specific data for those methods.

-

The following fields are part of the PaymentMethodData dictionary:

+

The following fields are part of the PaymentMethodData dictionary:

-
supportedMethods
-
supportedMethods is a required sequence of strings containing payment method identifiers for +
supportedMethods
+
supportedMethods is a required sequence of strings containing payment method identifiers for payment methods that the merchant web site accepts.
-
data
-
data is a JSON-serializable object that provides optional information that +
data
+
data is a JSON-serializable object that provides optional information that might be needed by the supported payment methods.
-
-

PaymentCurrencyAmount

+
+

PaymentCurrencyAmount dictionary

         dictionary PaymentCurrencyAmount {
           required DOMString currency;
@@ -561,26 +562,26 @@ 

PaymentCurrencyAmount

};

- A PaymentCurrencyAmount dictionary is used to supply monetary amounts. + A PaymentCurrencyAmount dictionary is used to supply monetary amounts.

The following fields are required:

-
currencySystem
+
currencySystem
- currencySystem is a URL that indicates the currency system that the - currency identifier belongs to. By default, the value is + A URL that indicates the currency system that the + currency identifier belongs to. By default, the value is urn:iso:std:iso:4217 indicating that currency is defined by [[ISO4217]] (for example, USD for US Dollars).
-
currency
+
currency
- currency is a string containing a currency identifier. The + A string containing a currency identifier. The value of currency can be any string that is valid within the currency system indicated by currencySystem.
-
value
+
value
A valid decimal monetary value containing a monetary amount. A string is a valid decimal monetary value if it consists of the following components in the given order: @@ -599,7 +600,7 @@

PaymentCurrencyAmount

The following example shows how to represent US$55.00.

-
+      
 {
   "currency": "USD",
   "value" : "55.00"
@@ -607,85 +608,85 @@ 

PaymentCurrencyAmount

-
-

PaymentDetails dictionary

-
-dictionary PaymentDetails {
-  PaymentItem total;
-  sequence<PaymentItem> displayItems;
-  sequence<PaymentShippingOption> shippingOptions;
-  sequence<PaymentDetailsModifier> modifiers;
-  DOMString error;
-};
-      
+
+

PaymentDetails dictionary

+
+  dictionary PaymentDetails {
+    PaymentItem total;
+    sequence<PaymentItem> displayItems;
+    sequence<PaymentShippingOption> shippingOptions;
+    sequence<PaymentDetailsModifier> modifiers;
+    DOMString error;
+  };
+  

- The PaymentDetails dictionary is passed to the PaymentRequest + The PaymentDetails dictionary is passed to the PaymentRequest constructor and provides information about the requested transaction. The PaymentDetails - dictionary is also used to update the payment request using updateWith. + dictionary is also used to update the payment request using updateWith.

The following fields are part of the PaymentDetails dictionary:

-
total
+
total
- This PaymentItem contains the total amount of the payment request. + This PaymentItem contains the total amount of the payment request.

total MUST be a non-negative value. This means that the total.amount.value field MUST NOT begin with a U+002D HYPHEN-MINUS character.

-
displayItems
+
displayItems
- This sequence of PaymentItem dictionaries contains line items + This sequence of PaymentItem dictionaries contains line items for the payment request that the user agent MAY display. For example, it might include details of products or breakdown of tax and shipping. It is optional to provide this information.

The user agent MAY validate that the total amount is the sum of these items, but it is the responsibility of the calling code to ensure that.

-
shippingOptions
+
shippingOptions
A sequence containing the different shipping options for the user to choose from.

If the sequence is empty, then this indicates that the merchant - cannot ship to the current shippingAddress.

+ cannot ship to the current shippingAddress.

If an item in the sequence has the selected field set to true, - then this is the shipping option that will be used by default and shippingOption + then this is the shipping option that will be used by default and shippingOption will be set to the id of this option without running the shipping option changed algorithm. Authors SHOULD NOT set selected to true on more than one item. If more than one item in the sequence has selected set to true, then user agents MUST select the last one in the sequence.

-

The shippingOptions field is only used if the PaymentRequest was - constructed with PaymentOptions requestShipping +

The shippingOptions field is only used if the PaymentRequest was + constructed with PaymentOptions requestShipping set to true.

If the sequence has an item with the selected field set to true, then authors are responsible for ensuring that the total field includes - the cost of the shipping option. This is because no shippingoptionchange event + the cost of the shipping option. This is because no shippingoptionchange event will be fired for this option unless the user selects an alternative option first.

-
modifiers
+
modifiers
- This sequence of PaymentDetailsModifier dictionaries contains modifiers + This sequence of PaymentDetailsModifier dictionaries contains modifiers for particular payment method identifiers. For example, it allows you to adjust the total amount based on payment method.
error
- When the payment request is updated using updateWith, the PaymentDetails + When the payment request is updated using updateWith, the PaymentDetails can contain a message in the error field that will be displayed to the user. For example, this might commonly be used to explain why goods cannot be shipped to the chosen shipping address.

- The error field cannot be passed to the PaymentRequest constructor. - Doing so will cause a TypeError to be thrown. + The error field cannot be passed to the PaymentRequest constructor. + Doing so will cause a TypeError to be thrown.

-
-

PaymentDetailsModifier dictionary

+
+

PaymentDetailsModifier dictionary

     dictionary PaymentDetailsModifier {
       required sequence<DOMString> supportedMethods;
@@ -696,28 +697,28 @@ 

PaymentDetailsModifier dictionary

- The PaymentDetailsModifier dictionary provides details that modify the - PaymentDetails based on payment method identifier. It contains the + The PaymentDetailsModifier dictionary provides details that modify the + PaymentDetails based on payment method identifier. It contains the following fields:

-
supportedMethods
+
supportedMethods
- The supportedMethods field contains a sequence of payment method identifiers. - The remaining fields in the PaymentDetailsModifier apply only if the user selects + The supportedMethods field contains a sequence of payment method identifiers. + The remaining fields in the PaymentDetailsModifier apply only if the user selects a payment method included in this sequence.
-
total
+
total
- This PaymentItem value overrides the total field in the - PaymentDetails dictionary for the payment method identifiers + This PaymentItem value overrides the total field in the + PaymentDetails dictionary for the payment method identifiers in the supportedMethods field.
-
additionalDisplayItems
+
additionalDisplayItems
- This sequence of PaymentItem dictionaries provides additional display - items that are appended to the displayItems field in the PaymentDetails + This sequence of PaymentItem dictionaries provides additional display + items that are appended to the displayItems field in the PaymentDetails dictionary for the payment method identifiers in the supportedMethods field. This field is commonly used to add a discount or surcharge line item indicating the reason for the different total amount for the selected payment method @@ -733,8 +734,8 @@

PaymentDetailsModifier dictionary

-
-

PaymentOptions dictionary

+
+

PaymentOptions dictionary

         enum PaymentShippingType {
           "shipping",
@@ -752,39 +753,39 @@ 

PaymentOptions dictionary

- The PaymentOptions dictionary is passed to the PaymentRequest + The PaymentOptions dictionary is passed to the PaymentRequest constructor and provides information about the options desired for the payment request.

- The following fields MAY be passed to the PaymentRequest constructor: + The following fields MAY be passed to the PaymentRequest constructor:

-
requestPayerName
+
requestPayerName
This boolean value indicates whether the user agent should collect and return the payer's name as part of the payment request. For example, this would be set to true to allow a merchant to make a booking in the payer's name.
-
requestPayerEmail
+
requestPayerEmail
This boolean value indicates whether the user agent should collect and return the payer's email address as part of the payment request. For example, this would be set to true to allow a merchant to email a receipt.
-
requestPayerPhone
+
requestPayerPhone
This boolean value indicates whether the user agent should collect and return the payer's phone number as part of the payment request. For example, this would be set to true to allow a merchant to phone a customer with a billing enquiry.
-
requestShipping
+
requestShipping
This boolean value indicates whether the user agent should collect and return a shipping address as part of the payment request. For example, this would be set to true when physical goods need to be shipped by the merchant to the user. This would be set to false for an online-only electronic purchase transaction.
-
shippingType
+
shippingType
Some transactions require an address for delivery but the term "shipping" isn't appropriate. For example, "pizza delivery" not "pizza shipping" and "laundry pickup" not "laundry shipping". @@ -807,31 +808,31 @@

PaymentOptions dictionary

-
-

PaymentItem dictionary

-
-        dictionary PaymentItem {
-          required DOMString label;
-          required PaymentCurrencyAmount amount;
-          boolean pending = false;
-        };
-      
+
+

PaymentItem dictionary

+
+    dictionary PaymentItem {
+      required DOMString label;
+      required PaymentCurrencyAmount amount;
+      boolean pending = false;
+    };
+  

- A sequence of one or more PaymentItem dictionaries is included in the PaymentDetails + A sequence of one or more PaymentItem dictionaries is included in the PaymentDetails dictionary to indicate what the payment request is for and the value asked for.

The following fields are required:

-
label
+
label
This is a human-readable description of the item. The user agent may display this to the user.
-
amount
+
amount
- A PaymentCurrencyAmount containing the monetary amount for the item. + A PaymentCurrencyAmount containing the monetary amount for the item.
-
pending
+
pending
When set to true this flag means that the amount field is not final. This is commonly used to show items such as shipping or tax amounts that depend upon @@ -841,78 +842,78 @@

PaymentItem dictionary

-
-

PaymentAddress interface

-
-        [SecureContext]
-        interface PaymentAddress {
-          serializer = { attribute };
-          readonly attribute DOMString country;
-          readonly attribute FrozenArray<DOMString> addressLine;
-          readonly attribute DOMString region;
-          readonly attribute DOMString city;
-          readonly attribute DOMString dependentLocality;
-          readonly attribute DOMString postalCode;
-          readonly attribute DOMString sortingCode;
-          readonly attribute DOMString languageCode;
-          readonly attribute DOMString organization;
-          readonly attribute DOMString recipient;
-          readonly attribute DOMString phone;
-        };
-      
+
+

PaymentAddress interface

+
+    [SecureContext]
+    interface PaymentAddress {
+      serializer = { attribute };
+      readonly attribute DOMString country;
+      readonly attribute FrozenArray<DOMString> addressLine;
+      readonly attribute DOMString region;
+      readonly attribute DOMString city;
+      readonly attribute DOMString dependentLocality;
+      readonly attribute DOMString postalCode;
+      readonly attribute DOMString sortingCode;
+      readonly attribute DOMString languageCode;
+      readonly attribute DOMString organization;
+      readonly attribute DOMString recipient;
+      readonly attribute DOMString phone;
+    };
+  
-
country
+
country
This is the [[CLDR]] (Common Locale Data Repository) region code. For example, US, GB, CN, or JP.
-
addressLine
+
addressLine
This is the most specific part of the address. It can include, for example, a street name, a house number, apartment number, a rural delivery route, descriptive instructions, or a post office box number.
-
region
+
region
This is the top level administrative subdivision of the country. For example, this can be a state, a province, an oblast, or a prefecture.
-
city
+
city
This is the city/town portion of the address.
-
dependentLocality
+
dependentLocality
This is the dependent locality or sublocality within a city. For example, used for neighborhoods, boroughs, districts, or UK dependent localities.
-
postalCode
+
postalCode
This is the postal code or ZIP code, also known as PIN code in India.
-
sortingCode
+
sortingCode
This is the sorting code as used in, for example, France.
-
languageCode
+
languageCode
This is the BCP-47 language code for the address. It's used to determine the field separators and the order of fields when formatting the address for display.
-
organization
+
organization
This is the organization, firm, company, or institution at this address.
-
recipient
+
recipient
This is the name of the recipient or contact person. This field may, under certain circumstances, contain multiline information. For example, it might contain "care of" information.
-
phone
+
phone
This is the phone number of the recipient or contact person.

- If the requestShipping flag was set to true in the PaymentOptions + If the requestShipping flag was set to true in the PaymentOptions passed to the PaymentRequest constructor, then the user agent will populate the - shippingAddress field of the PaymentRequest and ultimately the - PaymentResponse object with the user's selected shipping address after + shippingAddress field of the PaymentRequest and ultimately the + PaymentResponse object with the user's selected shipping address after the user has accepted the payment.

-
-

PaymentShippingOption dictionary

-
-        dictionary PaymentShippingOption {
-          required DOMString id;
-          required DOMString label;
-          required PaymentCurrencyAmount amount;
-          boolean selected = false;
-        };
-      
+
+

PaymentShippingOption dictionary

+
+    dictionary PaymentShippingOption {
+      required DOMString id;
+      required DOMString label;
+      required PaymentCurrencyAmount amount;
+      boolean selected = false;
+    };
+  

The PaymentShippingOption dictionary has fields describing a shipping option. A web page can - provide the user with one or more shipping options by calling the updateWith + provide the user with one or more shipping options by calling the updateWith method in response to a change event.

@@ -921,13 +922,13 @@

PaymentShippingOption dictionary

id
This is a string identifier used to reference this PaymentShippingOption. It MUST be - unique for a given PaymentRequest.
+ unique for a given PaymentRequest.
label
This is a human-readable description of the item. The user agent SHOULD use this string to display the shipping option to the user.
amount
- A PaymentCurrencyAmount containing the monetary amount for the item. + A PaymentCurrencyAmount containing the monetary amount for the item.
selected
This is set to true to indicate that this is the default selected PaymentShippingOption @@ -935,89 +936,89 @@

PaymentShippingOption dictionary

-
-

PaymentResponse interface

-
-        enum PaymentComplete { "success", "fail", "" };
+
+

PaymentResponse interface

+
+    enum PaymentComplete { "success", "fail", "" };
 
-        [SecureContext]
-        interface PaymentResponse {
-          serializer = { attribute };
+    [SecureContext]
+    interface PaymentResponse {
+      serializer = { attribute };
 
-          readonly attribute DOMString methodName;
-          readonly attribute object details;
-          readonly attribute PaymentAddress? shippingAddress;
-          readonly attribute DOMString?      shippingOption;
-          readonly attribute DOMString? payerName;
-          readonly attribute DOMString? payerEmail;
-          readonly attribute DOMString? payerPhone;
+      readonly attribute DOMString methodName;
+      readonly attribute object details;
+      readonly attribute PaymentAddress? shippingAddress;
+      readonly attribute DOMString?      shippingOption;
+      readonly attribute DOMString? payerName;
+      readonly attribute DOMString? payerEmail;
+      readonly attribute DOMString? payerPhone;
 
-          Promise<void> complete(optional PaymentComplete result = "");
-        };
-      
+ Promise<void> complete(optional PaymentComplete result = ""); + }; +

- A PaymentResponse is returned when a user has selected a payment method and + A PaymentResponse is returned when a user has selected a payment method and approved a payment request. It contains the following fields:

-
methodName
+
methodName
The payment method identifier for the payment method that the user selected to fulfil the transaction.
-
details
+
details
A JSON-serializable object that provides a payment method specific message used by the merchant to process the transaction and determine successful fund transfer. This data is returned by the payment method specific code that satisfies the payment request.
-
shippingAddress
+
shippingAddress
- If the requestShipping flag was set to true in the PaymentOptions - passed to the PaymentRequest constructor, then shippingAddress will + If the requestShipping flag was set to true in the PaymentOptions + passed to the PaymentRequest constructor, then shippingAddress will be the full and final shipping address chosen by the user.
-
shippingOption
+
shippingOption
- If the requestShipping flag was set to true in the PaymentOptions - passed to the PaymentRequest constructor, then shippingOption will + If the requestShipping flag was set to true in the PaymentOptions + passed to the PaymentRequest constructor, then shippingOption will be the id attribute of the selected shipping option.
-
payerName
+
payerName
- If the requestPayerName flag was set to true in the PaymentOptions - passed to the PaymentRequest constructor, then payerName will + If the requestPayerName flag was set to true in the PaymentOptions + passed to the PaymentRequest constructor, then payerName will be the name provided by the user.
-
payerEmail
+
payerEmail
- If the requestPayerEmail flag was set to true in the PaymentOptions - passed to the PaymentRequest constructor, then payerEmail will + If the requestPayerEmail flag was set to true in the PaymentOptions + passed to the PaymentRequest constructor, then payerEmail will be the email address chosen by the user.
-
payerPhone
+
payerPhone
- If the requestPayerPhone flag was set to true in the PaymentOptions - passed to the PaymentRequest constructor, then payerPhone will + If the requestPayerPhone flag was set to true in the PaymentOptions + passed to the PaymentRequest constructor, then payerPhone will be the phone number chosen by the user.
-
-

complete()

-

The complete method is called after the user has accepted the payment +

+

complete() method

+

The complete method is called after the user has accepted the payment request and the [[\acceptPromise]] has been resolved. Calling the complete method tells the user agent that the user interaction is over (and SHOULD cause any remaining user interface to be closed).

-

The complete method takes a string argument from the PaymentComplete +

The complete method takes a string argument from the PaymentComplete enum (result). These values are used to influence the user experience provided by the user agent when the user interface is dismissed. The value of result has the following meaning:

-
-
"success"
+
+
"success"
Indicates the payment was successfully processed. The user agent MAY display UI indicating success.
-
"fail"
+
"fail"
Indicates that processing of the payment failed. The user agent MAY display UI indicating failure.
""
@@ -1027,21 +1028,21 @@

complete()

-

After the payment request has been accepted and the PaymentResponse returned to - the page but before the page calls complete the payment request user interface remains in a pending +

After the payment request has been accepted and the PaymentResponse returned to + the page but before the page calls complete the payment request user interface remains in a pending state. At this point the user interface ought not offer a cancel command because acceptance of the - payment request has been returned. However, if something goes wrong and the page never calls complete + payment request has been returned. However, if something goes wrong and the page never calls complete then the user interface is blocked.

-

For this reason, implementations may choose to impose a timeout for the page to call complete. - If the timeout expires then the implementation will behave as if complete was called with no +

For this reason, implementations may choose to impose a timeout for the page to call complete. + If the timeout expires then the implementation will behave as if complete was called with no arguments.

-

The complete method MUST act as follows:

+

The complete method MUST act as follows:

  1. Let promise be a new Promise.
  2. - If the value of the internal slot [[\completeCalled]] is true, then throw an InvalidStateError. + If the value of the internal slot [[\completeCalled]] is true, then throw an InvalidStateError.
  3. Set the value of the internal slot [[\completeCalled]] to true.
  4. Return promise and asynchronously perform the remaining steps.
  5. @@ -1054,14 +1055,14 @@

    complete()

    Internal Slots

    -

    Instances of PaymentResponse are created with the internal slots in +

    Instances of PaymentResponse are created with the internal slots in the following table:

Internal SlotDescription (non-normative)
[[\details]] - The current PaymentDetails for the payment request initially - supplied to the constructor and then updated with calls to updateWith. + The current PaymentDetails for the payment request initially + supplied to the constructor and then updated with calls to updateWith.
[[\options]]The PaymentOptions supplied to the constructor.The PaymentOptions supplied to the constructor.
[[\state]]
[[\updating]] - true is there is a pending updateWith call to update + true is there is a pending updateWith call to update the payment request and false otherwise.
[[\acceptPromise]] - The pending Promise created during show that will be + The pending Promise created during show that will be resolved if the user accepts the payment request.
@@ -1079,13 +1080,13 @@

PaymentRequest and iframes

The HTMLIFrameElement is extended with an allowpaymentrequest - content attribute. allowpaymentrequest is a boolean attribute. + content attribute. allowpaymentrequest is a boolean attribute. When specified, it indicates that scripts in the iframe element's browsing context are allowed to make payment requests (if it's not blocked for other reasons, e.g., there is another ancestor iframe without this attribute set).

-
-

HTMLIFrameElement extension

+
+

HTMLIFrameElement extension

The iframe DOM interface is extended as follows:

       partial interface HTMLIFrameElement {
@@ -1096,7 +1097,7 @@ 

HTMLIFrameElement extension

allowPaymentRequest
The allowPaymentRequest IDL attribute MUST reflect the - allowpaymentrequest content attribute. + allowpaymentrequest content attribute.
@@ -1123,44 +1124,44 @@

Summary

Internal SlotDescription (non-normative)
[[\completeCalled]] - true if the complete method has been called and false + true if the complete method has been called and false otherwise.
-
-

PaymentRequestUpdateEvent

-
-[Constructor(DOMString type, optional PaymentRequestUpdateEventInit eventInitDict),SecureContext]
-interface PaymentRequestUpdateEvent : Event {
-  void updateWith(Promise<PaymentDetails> d);
-};
-
-dictionary PaymentRequestUpdateEventInit : EventInit {
-};
-        
-

The PaymentRequestUpdateEvent enables the web page to update +

+

PaymentRequestUpdateEvent interface

+
+      [Constructor(DOMString type, optional PaymentRequestUpdateEventInit eventInitDict),SecureContext]
+      interface PaymentRequestUpdateEvent : Event {
+        void updateWith(Promise<PaymentDetails> d);
+      };
+
+      dictionary PaymentRequestUpdateEventInit : EventInit {
+      };
+    
+

The PaymentRequestUpdateEvent enables the web page to update the details of the payment request in response to a user interaction.

-

If the web page wishes to update the payment request then it should call updateWith - and provide a promise that will resolve with a PaymentDetails +

If the web page wishes to update the payment request then it should call updateWith + and provide a promise that will resolve with a PaymentDetails dictionary containing changed values that the user agent SHOULD present to the user.

The PaymentRequestUpdateEvent constructor MUST set the internal slot [[\waitForUpdate]] to false.

-

updateWith()

-

The updateWith method MUST act as follows:

+

updateWith() method

+

The updateWith method MUST act as follows:

  1. - Let target be the PaymentRequest object that is the target of + Let target be the PaymentRequest object that is the target of the event.
  2. -
  3. If the dispatch flag is unset, then throw an InvalidStateError.
  4. +
  5. If the dispatch flag is unset, then throw an InvalidStateError.
  6. - If [[\waitForUpdate]] is true, then throw an InvalidStateError. + If [[\waitForUpdate]] is true, then throw an InvalidStateError.
  7. If target@[[\state]] is not interactive, then throw an - InvalidStateError. + InvalidStateError.
  8. If target@[[\updating]] is true, then throw - an InvalidStateError. + an InvalidStateError.
  9. Set the stop propagation flag and stop immediate propagation flag.
  10. Set [[\waitForUpdate]] to true.
  11. @@ -1188,7 +1189,7 @@

    updateWith()

    1. Abort the current user interaction and close down any remaining user interface.
    2. Set the value of the internal slot target@[[\state]] to closed.
    3. -
    4. Reject the promise target@[[\acceptPromise]] with an AbortError.
    5. +
    6. Reject the promise target@[[\acceptPromise]] with an AbortError.
    7. Abort this algorithm.
    @@ -1202,7 +1203,7 @@

    updateWith()

  12. If d is resolved with details and details is a - PaymentDetails dictionary, then: + PaymentDetails dictionary, then:
    1. If details contains a total value and total.amount.value @@ -1213,7 +1214,7 @@

      updateWith()

    2. If details contains a displayItems value and every - PaymentItem in the displayItems has an + PaymentItem in the displayItems has an amount.value containing a valid decimal monetary value, then copy details.displayItems to the displayItems field of target@[[\details]]. @@ -1222,11 +1223,11 @@

      updateWith()

      If details contains a modifiers value, then:
      1. Let modifiers be the sequence details.modifiers.
      2. -
      3. For each PaymentDetailsModifier in modifiers, if the +
      4. For each PaymentDetailsModifier in modifiers, if the total field is supplied and is not a valid decimal monetary value, then set modifiers to an empty sequence.
      5. -
      6. For each PaymentDetailsModifier in modifiers, if the - additionalDisplayItems sequence contains any PaymentItem +
      7. For each PaymentDetailsModifier in modifiers, if the + additionalDisplayItems sequence contains any PaymentItem objects with an amount that is not a valid decimal monetary value, then set modifiers to an empty sequence.
      8. Copy modifiers to the modifiers field of target@[[\details]].
      9. @@ -1238,10 +1239,10 @@

        updateWith()

      10. Let shippingOptions be the sequence details.shippingOptions.
      11. If the shippingOptions sequence contains multiple - PaymentShippingOption objects that have the same id, + PaymentShippingOption objects that have the same id, then set shippingOptions to the empty sequence.
      12. - If the shippingOptions sequence contains a PaymentShippingOption + If the shippingOptions sequence contains a PaymentShippingOption that has an amount.value that is not a valid decimal monetary value, then set shippingOptions to the empty sequence.
      13. @@ -1251,13 +1252,13 @@

        updateWith()

      14. Let newOption be null.
      15. If target@[[\details]] contains a shippingOptions sequence - and if any ShippingOption in the sequence + and if any PaymentShippingOption in the sequence has the selected field set to true, then set - newOption to the id of the last ShippingOption + newOption to the id of the last PaymentShippingOption in the sequence with selected set to true.
      16. - Set the value of shippingOption on target to + Set the value of shippingOption on target to newOption.
      @@ -1283,7 +1284,7 @@

      updateWith()

      Algorithms

      -

      When the internal slot [[\state]] of a PaymentRequest object is set to +

      When the internal slot [[\state]] of a PaymentRequest object is set to interactive, the user agent will trigger the following algorithms based on user interaction.

      @@ -1294,11 +1295,11 @@

      Shipping address changed algorithm

      address. It MUST run the following steps:

        -
      1. Let request be the PaymentRequest object that the user is +
      2. Let request be the PaymentRequest object that the user is interacting with.
      3. -
      4. Let name be shippingaddresschange.
      5. +
      6. Let name be shippingaddresschange.
      7. - Set the shippingAddress attribute on request to the + Set the shippingAddress attribute on request to the shipping address provided by the user.
      8. @@ -1314,12 +1315,12 @@

        Shipping option changed algorithm

        option. It MUST run the following steps:

          -
        1. Let request be the PaymentRequest object that the user is +
        2. Let request be the PaymentRequest object that the user is interacting with.
        3. -
        4. Let name be shippingoptionchange.
        5. +
        6. Let name be shippingoptionchange.
        7. - Set the shippingOption attribute on request to the - id string of the PaymentShippingOption provided by the user. + Set the shippingOption attribute on request to the + id string of the PaymentShippingOption provided by the user.
        8. Run the PaymentRequest updated algorithm with request and name. @@ -1331,7 +1332,7 @@

          Shipping option changed algorithm

          PaymentRequest updated algorithm

          The PaymentRequest updated algorithm is run by other algorithms above to fire - an event to indicate that a user has made a change to a PaymentRequest + an event to indicate that a user has made a change to a PaymentRequest called request with an event name of name.

          It MUST run the following steps:

            @@ -1345,7 +1346,7 @@

            PaymentRequest updated algorithm

            then terminate this algorithm and take no further action. The user agent user interface should ensure that this never occurs. -
          1. Let event be a new PaymentRequestUpdateEvent.
          2. +
          3. Let event be a new PaymentRequestUpdateEvent.
          4. Queue a task to fire an event named name of type event at request. @@ -1362,7 +1363,7 @@

            User accepts the payment request algorithm

            1. - Let request be the PaymentRequest object that the user is + Let request be the PaymentRequest object that the user is interacting with.
            2. @@ -1383,7 +1384,7 @@

              User accepts the payment request algorithm

              never occur.
            3. - Let response be a new PaymentResponse. + Let response be a new PaymentResponse.
            4. Set the methodName attribute value of response to the payment method identifier @@ -1397,21 +1398,21 @@

              User accepts the payment request algorithm

            5. If the requestShipping value of request@[[\options]] is true, then copy the shippingAddress attribute of - request to the shippingAddress attribute of response. + request to the shippingAddress attribute of response.
            6. If the requestShipping value of request@[[\options]] is true, then copy the shippingOption attribute of - request to the shippingOption attribute of response. + request to the shippingOption attribute of response.
            7. If the requestPayerName value of request@[[\options]] - is true, then set the payerName attribute of + is true, then set the payerName attribute of response to the payer's name provided by the user.
            8. If the requestPayerEmail value of request@[[\options]] - is true, then set the payerEmail attribute of + is true, then set the payerEmail attribute of response to the payer's email address selected by the user.
            9. @@ -1441,7 +1442,7 @@

              Security Considerations

              Encryption of data fields

              - The PaymentRequest API does not directly support encryption of data fields. + The PaymentRequest API does not directly support encryption of data fields. Individual payment methods may choose to include support for encrypted data but it is not mandatory that all payment methods support this.

              @@ -1501,15 +1502,15 @@

              Dependencies

              DOM4
              - The Event type and the terms fire an event, dispatch flag, + The Event type and the terms fire an event, dispatch flag, stop propagation flag, and stop immediate propagation flag are defined by [[!DOM4]].

              DOMException and the following DOMException types from [[!DOM4]] are used:

              - - - - + + + +
              TypeMessage (optional)
              AbortErrorThe payment request was aborted
              InvalidStateErrorThe object is in an invalid state
              NotSupportedErrorThe payment method was not supported
              SecurityErrorThe operation is only supported in a secure context
              AbortErrorThe payment request was aborted
              InvalidStateErrorThe object is in an invalid state
              NotSupportedErrorThe payment method was not supported
              SecurityErrorThe operation is only supported in a secure context
              WebIDL