From c3a3ff7d2491b921efa4e22820255650e180cc8b Mon Sep 17 00:00:00 2001
From: Ade Bateman Dependencies
PaymentRequest interface
- [Constructor(sequence<DOMString> supportedMethods, PaymentDetails details, optional PaymentOptions options, optional object data)]
+ [Constructor(sequence<PaymentMethodData> methodData, PaymentDetails details, optional PaymentOptions options)]
interface PaymentRequest : EventTarget {
Promise<PaymentResponse> show();
void abort();
@@ -255,7 +255,7 @@
PaymentRequest interface
user interaction:
- var payment = new PaymentRequest(supportedMethods, details, options, data); + var payment = new PaymentRequest(methodData, details, options); payment.addEventListener("shippingaddresschange", function (changeEvent) { // Process shipping address change }); @@ -273,9 +273,9 @@PaymentRequest interface
PaymentRequest constructor
- The
PaymentRequest
is constructed using the suppliedsupportedMethods
- list, the paymentdetails
, the paymentoptions
, and any payment - method specificdata
. + ThePaymentRequest
is constructed using the suppliedmethodData
+ list including any payment method specificdata
, the paymentdetails
, + and the paymentoptions
.It is proposed that a conformance criteria for implementations of this API be @@ -286,10 +286,21 @@PaymentRequest constructor
payment app.-The
+supportedMethods
sequence contains the payment method identifiers - for the payment methods that the merchant web site accepts.The
methodData
sequence containsPaymentMethodData
dictionaries + containing the payment method identifiers for the payment methods that the web site accepts + and any associated payment method specific data.- ["visa", "bitcoin", "bobpay.com"] + [ + { + supportedMethods: ["visa","bitcoin"] + }, + { + supportedMethods: ["bobpay.com"], + data: { + "merchantIdentifier": "XXXX", + "bobPaySpecificField": true + } + ]The
details
object contains information about the transaction that the @@ -324,24 +335,10 @@PaymentRequest constructor
"requestShipping": true } - --
data
is a JSON-serializable object that provides optional information that might - be needed by the supported payment methods.- { - "bobpay.com": { - "merchantIdentifier": "XXXX", - "bobPaySpecificField": true - }, - "bitcoin": { - "address": "XXXX" - } - } -- There is an open issue about whether@@ -375,9 +372,13 @@supportedMethods
,details
, anddata
+ There is an open issue about whethermethodData
,details
, anddata
should be combined into a single object.PaymentRequest constructor
- - If the length of the
+supportedMethods
sequence is zero, then throw + If the length of themethodData
sequence is zero, then throw aTypeError
.- + For each
PaymentMethodData
dictionary, if the length of the +supportedMethods
sequence is zero, then throw aTypeError
. +- If the global object of the script calling the constructor is not considered a secure context, then throw a
SecurityError
. @@ -402,21 +403,14 @@PaymentRequest constructor
than zero, then throw aTypeError
.- - If
-data
is not a JSON-serializable object, then throw aTypeError
. -- - If the name of any top level field of
-data
does not match one of the payment method identifiers - insupportedMethods
, then throw aTypeError
. -- - If the value of any top level field is not a JSON-serializable object, then - throw a
TypeError
. + For eachPaymentMethodData
inmethodData
, if thedata
field + is supplied but is not a JSON-serializable object, then throw aTypeError
.- Let request be a new
PaymentRequest
.- - Store
supportedMethods
into request@[[\supportedMethods]]. + StoremethodData
into request@[[\methodData]].- The
supportedMethods
supplied to thePaymentRequest
constructor + ThemethodData
supplied to thePaymentRequest
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. @@ -424,7 +418,6 @@PaymentRequest constructor
- Store
details
into request@[[\details]].- Store
-options
into request@[[\options]].- Store
data
into request@[[\data]].- Set the value request@[[\state]] to created.
- Set the value of the
shippingAddress
attribute on request to null. @@ -472,11 +465,16 @@show()
Return acceptPromise and asynchronously perform the remaining steps.- - Let acceptedMethods be the sequence of payment method identifiers request@[[\supportedMethods]] - with all identifiers removed that the user agent does not accept. + Let supportedMethods be the union of all the
+supportedMethods
sequences from each +PaymentMethodData
in the request@[[\methodData]] sequence. +- + Let acceptedMethods be supportedMethods with all identifiers removed that the + user agent does not accept.
- - If the length of acceptedMethods is zero, then reject acceptPromise with a
NotSupportedError
. + If the length of acceptedMethods is zero, then reject acceptPromise with a +NotSupportedError
.- Show a user interface to allow the user to interact with the payment request process. The acceptPromise will @@ -544,8 +542,8 @@
Internal Slots
Internal Slot Description (non-normative) - [[\supportedMethods]] -The +supportMethods
supplied to the constructor.[[\methodData]] +The methodData
supplied to the constructor.- [[\details]] @@ -558,13 +556,6 @@Internal Slots
[[\options]] The PaymentOptions
supplied to the constructor.- [[\data]] -- The payment method specific -data
supplied to the constructor used - by a Payment App to influence the app's behavior. -[[\state]] The current state of the payment request. @@ -588,6 +579,29 @@Internal Slots
++ +PaymentMethodData dictionary
++ dictionary PaymentMethodData { + required sequence<DOMString> supportedMethods; + object data; + }; +++ 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:+
+- +
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 + might be needed by the supported payment methods.CurrencyAmount