|
42 | 42 | <form style="margin: 20px 0"> |
43 | 43 | <div> |
44 | 44 | <input type="text" placeholder="Transaction ID" name="transactionId" autocomplete="off" style="width: 250px"/> |
45 | | - <button type="button" onClick="initWalletButtons(document.querySelector('input[name=transactionId]').value)">Render buttons</button> |
| 45 | + <button type="button" onClick="initWalletButtons()">Render buttons</button> |
46 | 46 | </div> |
47 | 47 | </form> |
48 | 48 | <div id="results-container" class="hidden"> |
49 | 49 | <div style="display: flex; flex-flow: row wrap; justify-content: space-between; margin: 20px 0"> |
50 | 50 | <div class="button-container"><span class="hint"><strong>Google Pay</strong> works in all browsers</span><div id="googlepay-container"></div></div> |
51 | 51 | <div class="button-container"><span class="hint"><strong>Apple Pay</strong> requires Safari 17</span><div id="applepay-container"></div></div> |
52 | 52 | </div> |
53 | | - <pre id="events"></pre> |
54 | 53 | </div> |
| 54 | + <pre id="events"></pre> |
55 | 55 | </div> |
56 | 56 | <footer> |
57 | 57 | <a href="https://github.com/datatrans/secure-fields-sample/blob/master/pciproxy-examples/wallets.html">View this page on GitHub</a> |
58 | 58 | </footer> |
59 | 59 | <script> |
| 60 | + var eventContainer = document.getElementById('events'); |
| 61 | + var transactionIdInput = document.querySelector('input[name=transactionId]'); |
| 62 | + |
60 | 63 | var secureFields; |
61 | 64 |
|
62 | | - var eventContainer = document.getElementById('events'); |
| 65 | + function initWalletButtons() { |
| 66 | + var transactionId = transactionIdInput.value; |
63 | 67 |
|
64 | | - function initWalletButtons(transactionId) { |
65 | 68 | if (secureFields) { |
66 | 69 | secureFields.destroy(); |
67 | 70 | } else { |
|
71 | 74 | secureFields = new SecureFields(); |
72 | 75 |
|
73 | 76 | secureFields.init(transactionId, { |
74 | | - googlePay: "googlepay-container" |
75 | | - }); |
76 | | - |
77 | | - secureFields.init(transactionId, { |
78 | | - applePay: "applepay-container" |
| 77 | + googlePay: 'googlepay-container', |
| 78 | + applePay: 'applepay-container' |
79 | 79 | }); |
80 | 80 |
|
81 | 81 | secureFields.on('error', function (data) { |
|
94 | 94 | if (data) { |
95 | 95 | eventContainer.innerText += 'Success: ' + data + '\n'; |
96 | 96 | } |
| 97 | + |
| 98 | + document.getElementById('results-container').classList.add('hidden'); |
| 99 | + transactionIdInput.value = ''; |
| 100 | + secureFields.destroy(); |
97 | 101 | }); |
98 | 102 |
|
99 | 103 | secureFields.on('ready', function () { |
|
0 commit comments