Skip to content

Commit

Permalink
State how payment details modifier data is serialized and used
Browse files Browse the repository at this point in the history
This closes w3c#346, by making it clear that the data is serialized and stored in the PaymentRequest for further usage by show(), and closes w3c#307, by finally stating all the points at which JSON-serialization happens explicitly.
  • Loading branch information
domenic committed Jan 20, 2017
1 parent 49f32c1 commit 27d0eba
Showing 1 changed file with 83 additions and 21 deletions.
104 changes: 83 additions & 21 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,8 @@ <h2>
</li>
</ol>
</li>
<li>Let <var>serializedModifierData</var> be an empty list.
</li>
<li data-link-for="PaymentDetails">Process payment details modifiers:
<ol>
<li>Let <var>modifiers</var> be an empty
Expand Down Expand Up @@ -525,14 +527,27 @@ <h2>
</li>
</ol>
</li>
<li>Let <var>serializedData</var> be the result of
<a>JSON-serializing</a> <var>modifier</var>.<a data-lt=
"PaymentDetailsModifier.data">data</a> into a string, if
the <a data-lt="PaymentDetailsModifier.data">data</a>
member of <var>modifier</var> is present, or null if it
is not. Rethrow any exceptions.
</li>
<li>Add <var>serializedData</var> to
<var>serializedModifierData</var>.
</li>
<li>Remove the <a data-lt="PaymentDetailsModifier.data">
data</a> member of <var>modifier</var>, if it is
present.
</li>
</ol>
</li>
<li>Set <var>details</var>.<a data-lt=
"PaymentDetails.modifiers">modifiers</a> to
<var>modifiers</var>.
</li>
</ol>
</li>
<li>Set <var>details</var>.<a data-lt=
"PaymentDetails.modifiers">modifiers</a> to <var>modifiers</var>.
</li>
</ol>
</li>
<li>If the <a data-lt="PaymentDetails.error">error</a> member of
Expand All @@ -550,6 +565,9 @@ <h2>
</li>
<li>Set <var>request</var>.<a>[[\details]]</a> to <var>details</var>.
</li>
<li>Set <var>request</var>.<a>[[\serializedModifierData]]</a> to
<var>serializedModifierData</var>.
</li>
<li>Set <var>request</var>.<a>[[\serializedMethodData]]</a> to <var>
serializedMethodData</var>.
</li>
Expand Down Expand Up @@ -645,6 +663,12 @@ <h2>
preference of the user when presenting payment methods and
applications.
</p>
<p>
The <a>payment app</a> should be sent the appropriate data from
<var>request</var> in order to guide the user through the payment
process. This includes the various attributes and internal slots
of <var>request</var>.
</p>
<p>
The <var>acceptPromise</var> will later be resolved by the
<a>user accepts the payment request algorithm</a> through
Expand Down Expand Up @@ -833,6 +857,18 @@ <h2>
or null for data (instead of the original object form).
</td>
</tr>
<tr>
<td>
<dfn>[[\serializedModifierData]]</dfn>
</td>
<td>
A list containing the serialized string form of each <a data-lt=
"PaymentDetailsModifier.data">data</a> member for each
corresponding item in the sequence
<a>[[\details]]</a>.<a data-lt="PaymentDetails">modifier</a>, or
null if no such member was present.
</td>
</tr>
<tr>
<td>
<dfn>[[\details]]</dfn>
Expand All @@ -841,7 +877,12 @@ <h2>
The current <a>PaymentDetails</a> for the payment request
initially supplied to the constructor and then updated with calls
to <a data-lt=
"PaymentRequestUpdateEvent.updateWith">updateWith()</a>.
"PaymentRequestUpdateEvent.updateWith">updateWith()</a>. Note
that all <a data-lt="PaymentDetailsModifier.data">data</a>
members of <a>PaymentDetailsModifier</a> instances contained in
the <a data-lt="PaymentDetails.modifiers">modifiers</a> member
will be removed, as they are instead stored in serialized form in
the [[\serializedModifierData]] internal slot.
</td>
</tr>
<tr>
Expand Down Expand Up @@ -1148,9 +1189,9 @@ <h2>
<dfn>data</dfn>
</dt>
<dd>
<code>data</code> is a <a>JSON-serializable object</a> that provides
optional information that might be needed by the supported payment
methods.
<code>data</code> is an object that provides optional information
that might be needed by the supported payment methods. If supplied,
it will be <a>JSON-serialized</a>.
</dd>
</dl>
</section>
Expand Down Expand Up @@ -1941,6 +1982,8 @@ <h2>
<li>Let <var>modifiers</var> be the sequence
<var>details</var>.<a>modifiers</a>.
</li>
<li>Let <var>serializedModifierData</var> be an empty list.
</li>
<li>For each <a>PaymentDetailsModifier</a>
<var>modifier</var> in <var>modifiers</var>:
<ol data-link-for="PaymentDetailsModifier">
Expand All @@ -1950,8 +1993,9 @@ <h2>
"PaymentItem.amount">amount</a>.<a data-lt=
"PaymentCurrencyAmount.value">value</a> is not a
<a>valid decimal monetary value</a>, then set
<var>modifiers</var> to an empty sequence, and jump to
the step labeled <i>copy modifiers</i> below.
<var>modifiers</var> to an empty sequence and
<var>serializedModifierData</var> to an empty list, and
jump to the step labeled <i>copy modifiers</i> below.
</li>
<li>If the <a>additionalDisplayItems</a> member of
<var>modifier</var> is present, then for each
Expand All @@ -1965,17 +2009,41 @@ <h2>
</li>
<li>If <var>amountValue</var> is not a <a>valid
decimal monetary value</a>, then set
<var>modifiers</var> to an empty sequence, and jump
to the step labeled <i>copy modifiers</i> below.
<var>modifiers</var> to an empty sequence and <var>
serializedModifierData</var> to an empty list,
and jump to the step labeled <i>copy
modifiers</i> below.
</li>
</ol>
</li>
<li>Let <var>serializedData</var> be the result of <a>
JSON-serializing</a> <var>modifier</var>.<a data-lt=
"PaymentDetailsModifier.data">data</a> into a string,
if the <a data-lt=
"PaymentDetailsModifier.data">data</a> member of
<var>modifier</var> is present, or null if it is not.
If <a>JSON-serializing</a> throws an exception, then
set <var>modifiers</var> to an empty sequence and
<var>serializedModifierData</var> to an empty list,
and jump to the step labeled <i>copy modifiers</i>
below.
</li>
<li>Add <var>serializedData</var> to
<var>serializedModifierData</var>.
</li>
<li>Remove the <a data-lt=
"PaymentDetailsModifier.data">data</a> member of <var>
modifier</var>, if it is present.
</li>
</ol>
</li>
<li>
<i>Copy modifiers</i>: Copy <var>modifiers</var> to the
<a data-lt="PaymentDetails.modifiers">modifiers</a> field
of <var>target</var>.<a>[[\details]]</a>.
<i>Copy modifiers</i>: Set
<var>target</var>.<a>[[\details]]</a>.<a data-lt=
"PaymentDetails.modifiers">modifiers</a> to
<var>modifiers</var>, and set
<var>target</var>.<a>[[\serializedModifierData]]</a> to
<var>serializedModifierData</var>.
</li>
</ol>
</li>
Expand Down Expand Up @@ -2347,12 +2415,6 @@ <h2>
The terms <dfn>Promise</dfn>, <dfn>internal slot</dfn>,
<dfn><code>TypeError</code></dfn>, <dfn>JSON.stringify</dfn>, and
<dfn>JSON.parse</dfn> are defined by [[!ECMA-262-2015]].
<p>
The term <dfn>JSON-serializable object</dfn> used in this
specification is not well defined; see <a href=
"https://github.com/w3c/browser-payment-api/issues/307">issue
#307</a>.
</p>
<p>
The term <dfn data-lt=
"JSON-serialize|JSON-serialized|JSON-serializing">JSON-serialize</dfn>
Expand Down

0 comments on commit 27d0eba

Please sign in to comment.