8000 [Spec] Move some input validation to construction time · w3c/secure-payment-confirmation@79af939 · GitHub
[go: up one dir, main page]

Skip to content
8000

Commit 79af939

Browse files
[Spec] Move some input validation to construction time
Fixes #194 Depends on w3c/payment-request#977
1 parent 12f96d5 commit 79af939

File tree

1 file changed

+41
-9
lines changed

1 file changed

+41
-9
lines changed

spec.bs

Lines changed: 41 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -588,22 +588,29 @@ members:
588588
automatically.
589589
</dl>
590590

591-
### Steps to check if a payment can be made ### {#sctn-steps-to-check-if-a-payment-can-be-made}
591+
### Payment Method additional data type ### {#sctn-payment-method-additional-data-type}
592592

593-
The [=steps to check if a payment can be made=] for this payment method, for an
593+
The `payment method additional data type` for this payment method is {{SecurePaymentConfirmationRequest}}.
594+
595+
NOTE: **TODO**: Link to PaymentRequest spec concept before landing this PR.
596+
597+
### Steps to validate payment method data ### {#sctn-steps-to-validate-payment-method-data}
598+
599+
The `steps to validate payment method data` for this payment method, for an
594600
input {{SecurePaymentConfirmationRequest}} |data|, are:
595601

602+
NOTE: **TODO**: Link to PaymentRequest spec concept before landing this PR.
603+
596604
<wpt>
597605
constructor.https.html
598-
authentication-invalid-icon.https.html
599-
authentication-icon-data-url.https.html
600-
authentication-rejected.https.html
601606
</wpt>
602607

603-
604608
1. If |data|["{{SecurePaymentConfirmationRequest/credentialIds}}"] is empty,
605609
return `false`.
606610

611+
1. If |data|["{{SecurePaymentConfirmationRequest/challenge}}"] is null or
612+
empty, return `false`.
613+
607614
1. If |data|["{{SecurePaymentConfirmationRequest/rpId}}"] is not a
608615
[=valid domain=], return `false`.
609616

@@ -624,12 +631,37 @@ input {{SecurePaymentConfirmationRequest}} |data|, are:
624631

625632
1. If |parsedURL|'s [=url/scheme=] is not "`https`", then return `false`.
626633

627-
1. Set |data|["{{SecurePaymentConfirmationRequest/payeeOrigin}}"] to the
628-
[=serialization of an origin|serialization of=] |parsedURL|'s [=url/origin=].
629-
630634
1. If |data|["{{SecurePaymentConfirmationRequest/instrument}}"]["{{PaymentCredentialInstrument/displayName}}"]
631635
is empty, return `false`.
632636

637+
### Steps to check if a payment can be made ### {#sctn-steps-to-check-if-a-payment-can-be-made}
638+
639+
The [=steps to check if a payment can be made=] for this payment method, for an
640+
input {{SecurePaymentConfirmationRequest}} |data|, are:
641+
642+
<wpt>
643+
constructor.https.html
644+
authentication-invalid-icon.https.html
645+
authentication-icon-data-url.https.html
646+
authentication-rejected.https.html
647+
</wpt>
648+
649+
1. If |data|["{{SecurePaymentConfirmationRequest/payeeOrigin}}"] is present:
650+
651+
1. Let |parsedURL| be the result of running the [=URL parser=] on
652+
|data|["{{SecurePaymentConfirmationRequest/payeeOrigin}}"].
653+
654+
1. Assert that |parsedURL| is not failure.
655+
656+
1. Assert that |parsedURL|'s [=url/scheme=] is "`https`".
657+
658+
NOTE: These pre-conditions were previously checked in the
659+
[[#sctn-steps-to-validate-payment-method-data|steps to validate payment
660+
method data]].
661+
662+
1. Set |data|["{{SecurePaymentConfirmationRequest/payeeOrigin}}"] to the
663+
[=serialization of an origin|serialization of=] |parsedURL|'s [=url/origin=].
664+
633665
1. [=fetch an image resource|Fetch the image resource=] for the icon, passing «["{{ImageResource/src}}" →
634666
|data|["{{SecurePaymentConfirmationRequest/instrument}}"]["{{PaymentCredentialInstrument/icon}}"]
635667
for *image*. If this fails:

0 commit comments

Comments
 (0)
0