- From: MimiaBenna <notifications@github.com>
- Date: Mon, 20 Mar 2023 07:54:15 -0700
- To: w3c/payment-handler <payment-handler@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <w3c/payment-handler/issues/410/1476380287@github.com>
my manifest is: ``` { "default_applications": ["https://testpr.fr/manifest.json"], "supported_origins": ["https://testpr.fr"] } ``` My installer: `function install(){ hideElements(); if ('serviceWorker' in navigator) { navigator.serviceWorker.register('sw.js').then((reg) => { return navigator.serviceWorker.ready; }) }) .catch((error) => { console.log('error is' + error); }); } else { alert('service worker not available on this browser'); } } ` My server Worker: `self.addEventListener('canmakepayment', e => { console.log('canmakepayment', e); e.respondWith(new Promise(function(resolve, reject) { resolve(true); })); }); async function waitForMessage() { return new Promise((resolve, reject) => { self.addEventListener('message', listener = e => { self.removeEventListener('message', listener); if (!e.data || !e.data.methodName ) { reject(); return; } try { switch (e.data.type) { case 'WINDOW_IS_READY': resolve(e.data); break; } }catch (error) { resolver.reject(); payment_request_event = null; } }); }); } self.addEventListener('paymentrequest', evt => { evt.respondWith((async() => { const windowClient = await evt.openWindow('check.html'); windowClient.postMessage( { ...... }); const result = await waitForMessage(); return result; })()); }); // Define a convenient `postMessage()` method const postMessage = (type, contents = {}) => { if (client) client.postMessage({ type, ...contents }); } ` My show function: ``` if(window.PaymentRequest) { const supportedInstruments = [{ supportedMethods: "https://testpr.fr", data: { ... } }]; const details = { .... ], total: { ... } }; const options = {requestPayerName: true, requestShipping: false}; const request =new PaymentRequest(supportedInstruments, details, options); try { const response = await request.show(); console.log(response); window.setTimeout(function() { response.complete('success') .then(function() { alert('payment accepted') console.log('succes') }) .catch(function(err) { ChromeSamples.setStatus(err); }); }, 2000); } catch (err) { console.error("Uh oh, something bad happened", err.message); } } else { // Fallback to traditional checkout alert('PaymentRequest not supported'); } ``` I have error : https://testpr.fr is not supported -- Reply to this email directly or view it on GitHub: https://github.com/w3c/payment-handler/issues/410#issuecomment-1476380287 You are receiving this because you are subscribed to this thread. Message ID: <w3c/payment-handler/issues/410/1476380287@github.com>
Received on Monday, 20 March 2023 14:54:27 UTC