echo_payment_request.html (1111B)
1 <!DOCTYPE html> 2 <html> 3 <head> 4 <title>Payment Request Testing</title> 5 <meta content="text/html;charset=utf-8" http-equiv="Content-Type"> 6 <meta content="utf-8" http-equiv="encoding"> 7 </head> 8 <body> 9 <script> 10 window.onmessage = (e) => { 11 const paymentArgs = [[{supportedMethods: 'basic-card'}], {total: {label: 'label', amount: {currency: 'USD', value: '5.00'}}}]; 12 13 if (e.data === 'new PaymentRequest') { 14 try { 15 new PaymentRequest(...paymentArgs); 16 if (window.parent) { 17 window.parent.postMessage("successful", '*'); 18 } 19 } catch(ex) { 20 if (window.parent) { 21 window.parent.postMessage(ex.name, '*'); 22 } 23 } 24 } else if (e.data === 'new PaymentRequest in a new iframe') { 25 var ifrr = document.createElement('iframe'); 26 ifrr.allow = "payment"; 27 ifrr.src = "https://example.com/tests/dom/payments/test/simple_payment_request.html"; 28 document.body.appendChild(ifrr); 29 } else { 30 if (window.parent) { 31 window.parent.postMessage(e.data, '*'); 32 } 33 } 34 } 35 </script> 36 </body> 37 </html>