Re: [w3c/payment-request] User activation et webauthn (Issue #1002)

Hi Stephen
I hope you're doing well, the idea is that we want to create something like SPC for browsers that do not support it, but support Payment Request API, we procede in 3 parts :
first the user register if he's not already registred, we call the credentials.create() function for this
second we execute show method with our payment method and ask him to confirm the order
and at last the user should confirm his order by giving a fingerprint, here we call : credentials.get()

the problem we have is that we have one button to do all the work, let's say a "pay" button, when we click on it we will 
ask the user to register, so if the user takes a lot of time the show method will not execute and we will have : uncaught (in promise) DOMException: Failed to execute 'show' on 'PaymentRequest': PaymentRequest.show() requires either transient user activation or delegated payment request capability

is there any event that i can listen to to trigger the show method after the credentials.create() ?
or is there any way we can execute credentials.create() and the show() within the same event ?

`
// when we click on the pay button
async function pay() {
  const cred = await navigator.credentials.create({ publicKey });
  // we fetch the data in a post request in a remote server, and then we will get them back from the server(we are not using a localstorage)
         const supportedInstruments = [{
                  supportedMethods: ".....",
                  ......
         }];
          
          const details = {
           id: 'order-123',
           displayItems: [
             {
               label: "Sub-total",
               amount: { currency: "EUR", value: "55.00" },
             },
           ],
           total: {
             label: "Total",
             amount: { currency: "EUR", value: "65.00" },
           }
          };
          
          const options = {requestPayerName: false, requestShipping: false};
          const request =new PaymentRequest(supportedInstruments, details, options);   
          const response = await request.show(); // error from here 
}
`


-- 
Reply to this email directly or view it on GitHub:
https://github.com/w3c/payment-request/issues/1002#issuecomment-1497097144
You are receiving this because you are subscribed to this thread.

Message ID: <w3c/payment-request/issues/1002/1497097144@github.com>

Received on Wednesday, 5 April 2023 08:15:05 UTC