This repository was archived by the owner on Jul 21, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +48
-0
lines changed Expand file tree Collapse file tree 2 files changed +48
-0
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ layout: page
3+ favicon: gray
4+ background: gray
5+ ---
6+
7+ < div id ="content ">
8+ < h1 > web-payment</ h1 >
9+ < p > < button onclick ="handleClick(); "> Initiate payment</ button > </ p >
10+ </ div >
11+
12+ < div id ="footer "> This page requires web payment API.</ div >
13+
14+ < script src ="index.js "> </ script >
Original file line number Diff line number Diff line change 1+ /**
2+ * Builds PaymentRequest for credit cards, but does not show any UI yet.
3+ * @return {PaymentRequest } The PaymentRequest object.
4+ */
5+ function initPaymentRequest ( ) {
6+ return new PaymentRequest (
7+ [ {
8+ supportedMethods : [ 'basic-card' ] ,
9+ } ] ,
10+ {
11+ total : {
12+ label : 'Total' ,
13+ amount : {
14+ currency : 'USD' ,
15+ value : '1.00' ,
16+ } ,
17+ } ,
18+ } ) ;
19+ }
20+
21+ let request = initPaymentRequest ( ) ;
22+
23+ /** Invokes PaymentRequest for credit cards. */
24+ function handleClick ( ) {
25+ request . show ( )
26+ . then ( function ( instrumentResponse ) {
27+ return instrumentResponse . complete ( 'success' ) ;
28+ } )
29+ . catch ( function ( err ) {
30+ console . log ( err ) ;
31+ } ) ;
32+
33+ request = initPaymentRequest ( ) ;
34+ }
You can’t perform that action at this time.
0 commit comments