Skip to content

Commit

Permalink
Validate PMIs, ignore duplicates
Browse files Browse the repository at this point in the history
* Validate supportedMethods (closes #464)
* Defines behavior for duplicate PMIs in contructor and updateWith() (closes #309)
  • Loading branch information
marcoscaceres committed Aug 18, 2017
1 parent 76bd629 commit 6de125d
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -566,8 +566,33 @@ <h2>
then <a>throw</a> a <a>TypeError</a>, optionally informing the
developer that at least one <a>payment method</a> is required.
</li>
<li>Let <var>seenPMIs</var> be an emtpy list.
</li>
<li>For each <var>paymentMethod</var> of <var>methodData</var>:
<ol>
<li>Run the steps to <a data-cite=
"payment-method-id#dfn-validate-a-payment-method-identifier">
validate a payment method identifier</a> with
<var>paymentMethod</var>.<a data-lt=
"PaymentMethodData.supportedMethods">supportedMethods</a>.
If it returns false, then throw a <a>RangeError</a>
exception and terminate this algorithm. Optionally, inform
the developer that the payment method identifier is
invalid.
</li>
<li>If <a>seenPMIs</a> contains
<var>paymentMethod</var>.<a data-lt=
"PaymentMethodData.supportedMethods">supportedMethods</a>,
continue to the next <var>paymentMethod</var> of
<var>methodData</var> (if any). Optionally, inform the
developer that <var>paymentMethod</var>.<a data-lt=
"PaymentMethodData.supportedMethods">supportedMethods</a> was
already seen and <var>paymentMethod</var> will be ignored.
</li>
<li>Append <var>paymentMethod</var>.<a data-lt=
"PaymentMethodData.supportedMethods">supportedMethods</a> to
<var>seenPMI</var>.
</li>
<li>If the <a data-lt="PaymentMethodData.data">data</a>
member of <var>paymentMethod</var> is missing, let
<var>serializedData</var> be null. Otherwise, let
Expand Down Expand Up @@ -2547,9 +2572,21 @@ <h2>
<li>Let <var>serializedModifierData</var> be an empty
list.
</li>
<li>Let <var>seenPMIs</var> be an empty list.
</li>
<li>For each <a>PaymentDetailsModifier</a>
<var>modifier</var> in <var>modifiers</var>:
<ol data-link-for="PaymentDetailsModifier">
<li>Run the steps to <a data-cite=
"payment-method-id#dfn-validate-a-payment-method-identifier">
validate a payment method identifier</a> with
<var>modifier</var>.<a data-lt=
"PaymentDetailsModifier.supportedMethods">supportedMethods</a>.
If it returns false, then <a>abort the update</a>
with a <a>RangeError</a> exception. Optional,
inform the developer that the payment method
identifier is invalid.
</li>
<li>If the <a>total</a> member of
<var>modifier</var> is present, then:
<ol>
Expand Down Expand Up @@ -2588,6 +2625,20 @@ <h2>
exception, then <a>abort the update</a> with that
exception.
</li>
<li>If <a>seenPMIs</a> contains
<var>modifier</var>.<a data-lt=
"PaymentDetailsModifier.supportedMethods">supportedMethods</a>,
continue to the next <var>modifier</var> of
<var>modifiers</var> (if any). Optionally, inform
the developer that
<var>modifier</var>.<a data-lt="PaymentDetailsModifier.supportedMethods">supportedMethods</a>
was already seen and <var>modifier</var> will be
ignored.
</li>
<li>Append <var>modifier</var>.<a data-lt=
"PaymentDetailsModifier.supportedMethods">supportedMethods</a>
to <var>seenPMI</var>.
</li>
<li>Add <var>serializedData</var> to
<var>serializedModifierData</var>.
</li>
Expand Down

0 comments on commit 6de125d

Please sign in to comment.