Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add isSecurePaymentConfirmationAvailable API to spec #233

Merged
merged 7 commits into from
Jun 20, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 41 additions & 8 deletions spec.bs
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,16 @@ The sample code for authenticating the user follows. Note that the example code
presumes access to await/async, for easier to read promise handling.

<pre class="example" id="authentication-example" highlight="js">
if (!window.PaymentRequest) { /* PaymentRequest not available; merchant should fallback to traditional flows */ }
/* isSecurePaymentConfirmationAvailable indicates whether the browser */
/* supports SPC. It does not indicate whether the user has a credential */
/* ready to go on this device. */
const spcAvailable =
PaymentRequest &&
PaymentRequest.isSecurePaymentConfirmationAvailable &&
await PaymentRequest.isSecurePaymentConfirmationAvailable();
if (!spcAvailable) {
/* Browser does not support SPC; merchant should fallback to traditional flows. */
}

const request = new PaymentRequest([{
supportedMethods: "secure-payment-confirmation",
Expand Down Expand Up @@ -398,14 +407,7 @@ const request = new PaymentRequest([{
},
});

/* canMakePayment indicates whether the browser supports SPC. */
/* canMakePayment does not indicate whether the user has a credential */
/* ready to go on this device. */

try {
const canMakePayment = await request.canMakePayment();
if (!canMakePayment) { /* Browser does not support SPC. Handle error. */ }

const response = await request.show();
await response.complete('success');

Expand Down Expand Up @@ -622,6 +624,37 @@ members:
The [=payment method additional data type=] for this payment method is
{{SecurePaymentConfirmationRequest}}.

### Checking if Secure Payment Confirmation is available ### {#sctn-secure-payment-confirmation-available-api}

A static API is added to {{PaymentRequest}} in order to provide developers a
simplified method of checking whether Secure Payment Confirmation is available.

<xmp class="idl">
partial interface PaymentRequest {
static Promise<boolean> isSecurePaymentConfirmationAvailable();
};
</xmp>
<dl dfn-type="attribute" dfn-for="PaymentRequest">
: {{PaymentRequest/isSecurePaymentConfirmationAvailable()}}
:: Upon invocation, a promise is returned that resolves with a value of
`true` if the Secure Payment Confirmation feature is available, or
`false` otherwise.
</dl>

This allows a developer to perform the following check when deciding whether to
initiate a SPC flow:

<pre class="example" id="available-example" highlight="js">
const spcAvailable =
PaymentRequest &&
PaymentRequest.isSecurePaymentConfirmationAvailable &&
await PaymentRequest.isSecurePaymentConfirmationAvailable();
</pre>
nickburris marked this conversation as resolved.
Show resolved Hide resolved

NOTE: The use of the static {{PaymentRequest/isSecurePaymentConfirmationAvailable}} method is recommended for
SPC feature detection, instead of calling {{PaymentRequest/canMakePayment}} on an already-constructed
PaymentRequest object.

### Steps to validate payment method data ### {#sctn-steps-to-validate-payment-method-data}

The [=steps to validate payment method data=] for this payment method, for an
Expand Down