- From: Dave Longley <notifications@github.com>
- Date: Wed, 09 Aug 2017 16:17:32 +0000 (UTC)
- To: w3c/payment-handler <payment-handler@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
Received on Wednesday, 9 August 2017 16:17:54 UTC
Also, if we aren't going to simplify (for whatever reason) to just using `requestPermission`, then the return value from `navigator.permissions.query`, I believe, is actually a [PermissionStatus](https://w3c.github.io/permissions/#permissionstatus), which would mean we should be checking its `state` attribute, whereas `requestPermission` returns the `PermissionState` directly: ```js button.addEventListener("click", async() => { const { registration } = await navigator.serviceWorker.register('/sw.js'); if (!registration.paymentManager) { return; // not supported, so bail out. } const permission = await navigator.permissions.query({ name: "paymenthandler" }); switch (permission.state) { case "denied": return; case "prompt": const result = await registration.paymentManager.requestPermission(); if (result !== "granted") { return; } break; } // Excellent, we got it! Let's now set up the user's cards. await addInstruments(registration); }, { once: true }); ``` -- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/w3c/payment-handler/issues/200#issuecomment-321305441
Received on Wednesday, 9 August 2017 16:17:54 UTC