|
| 1 | +<!DOCTYPE html> |
| 2 | +<html lang="en"> |
| 3 | +<head> |
| 4 | + <meta charset="utf-8"> |
| 5 | + <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"> |
| 6 | + <title>PCI Proxy Web Tokenization</title> |
| 7 | + <script src="https://pay.sandbox.datatrans.com/upp/payment/js/secure-fields-2.0.0.min.js"></script> |
| 8 | + <link rel="stylesheet" type="text/css" href="../assets/css/stylesheet.css"> |
| 9 | +</head> |
| 10 | +<body style="margin: 0;"> |
| 11 | + <nav style="text-align: center; background: #213d62; padding: 10px; margin-bottom: 40px;"> |
| 12 | + <a href="index.html">Basic</a> |
| 13 | + <a href="inline-example.html">Inline</a> |
| 14 | + <a href="floating-label.html">Floating Label</a> |
| 15 | + <a href="iban.html">IBAN</a> |
| 16 | + <a href="account.html">Account Number</a> |
| 17 | + <a style="text-decoration: underline;" href="wallets.html">Wallets</a> |
| 18 | + <a href="show.html">Reveal Card (Show API)</a> |
| 19 | + </nav> |
| 20 | + <div style="width: 600px; margin: 0 auto;"> |
| 21 | + <p> |
| 22 | + This example shows how to collect tokens using our hosted tokenization buttons. |
| 23 | + We take care of the onboarding process at the wallet provider and offer you an easy and simple way to collect card details stored in the wallets of the cardholder. |
| 24 | + See the <a href="https://docs.pci-proxy.com/docs/hosted-tokenisation-button" target="_blank">documentation</a>. |
| 25 | + </p> |
| 26 | + |
| 27 | + <strong>Execute the following code in your terminal:</strong> |
| 28 | + <pre style="user-select: all">curl 'https://api.sandbox.datatrans.com/v1/transactions/secureFields/tokenize' \ |
| 29 | + --header 'Content-Type: application/json' \ |
| 30 | + --header 'Authorization: Basic MTEwMDAyNTgzNTozY29mTjNNeFhhQkg3VWw4' \ |
| 31 | + --data '{ |
| 32 | + "applePay": { |
| 33 | + "merchantName": "Sample merchant", |
| 34 | + "currency": "CHF", |
| 35 | + "country": "CH" |
| 36 | + }, |
| 37 | + "googlePay": { |
| 38 | + "currency": "CHF" |
| 39 | + } |
| 40 | + }'</pre> |
| 41 | + <strong>Provide the resulting transactionId:</strong> |
| 42 | + <form style="margin: 20px 0"> |
| 43 | + <div> |
| 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> |
| 46 | + </div> |
| 47 | + </form> |
| 48 | + <div id="results-container" class="hidden"> |
| 49 | + <div style="display: flex; flex-flow: row wrap; justify-content: space-between; margin: 20px 0"> |
| 50 | + <div class="button-container"><span class="hint"><strong>Google Pay</strong> works in all browsers</span><div id="googlepay-container"></div></div> |
| 51 | + <div class="button-container"><span class="hint"><strong>Apple Pay</strong> requires Safari 17</span><div id="applepay-container"></div></div> |
| 52 | + </div> |
| 53 | + <pre id="events"></pre> |
| 54 | + </div> |
| 55 | + </div> |
| 56 | + <footer> |
| 57 | + <a href="https://github.com/datatrans/secure-fields-sample/blob/master/pciproxy-examples/wallets.html">View this page on GitHub</a> |
| 58 | + </footer> |
| 59 | + <script> |
| 60 | + var secureFields; |
| 61 | + |
| 62 | + var eventContainer = document.getElementById('events'); |
| 63 | + |
| 64 | + function initWalletButtons(transactionId) { |
| 65 | + if (secureFields) { |
| 66 | + secureFields.destroy(); |
| 67 | + } else { |
| 68 | + document.getElementById('results-container').classList.remove('hidden'); |
| 69 | + } |
| 70 | + |
| 71 | + secureFields = new SecureFields(); |
| 72 | + |
| 73 | + secureFields.init(transactionId, { |
| 74 | + googlePay: "googlepay-container" |
| 75 | + }); |
| 76 | + |
| 77 | + secureFields.init(transactionId, { |
| 78 | + applePay: "applepay-container" |
| 79 | + }); |
| 80 | + |
| 81 | + secureFields.on('error', function (data) { |
| 82 | + try { |
| 83 | + data = JSON.stringify(data) |
| 84 | + } catch {} |
| 85 | + if (data) { |
| 86 | + eventContainer.innerText += 'Error: ' + data + '\n'; |
| 87 | + } |
| 88 | + }); |
| 89 | + |
| 90 | + secureFields.on('success', function (data) { |
| 91 | + try { |
| 92 | + data = JSON.stringify(data) |
| 93 | + } catch {} |
| 94 | + if (data) { |
| 95 | + eventContainer.innerText += 'Success: ' + data + '\n'; |
| 96 | + } |
| 97 | + }); |
| 98 | + |
| 99 | + secureFields.on('ready', function () { |
| 100 | + eventContainer.innerText += 'Ready: Secure Fields initialized\n'; |
| 101 | + }); |
| 102 | + } |
| 103 | + </script> |
| 104 | + <style> |
| 105 | + /* The following styles are NOT required */ |
| 106 | + html, body { |
| 107 | + font-family: Arial, Helvetica, sans-serif; |
| 108 | + } |
| 109 | + |
| 110 | + button { |
| 111 | + border: none; |
| 112 | + background-color: #06bd6e; |
| 113 | + color: white; |
| 114 | + padding: 7px 12px; |
| 115 | + font-size: 1rem; |
| 116 | + cursor: pointer; |
| 117 | + } |
| 118 | + |
| 119 | + input { |
| 120 | + display: inline-block; |
| 121 | + padding: 7px 12px; |
| 122 | + line-height: 1.3; |
| 123 | + cursor: text; |
| 124 | + border-style: solid; |
| 125 | + border-width: 1px; |
| 126 | + border-color: #e3e3e3; |
| 127 | + border-radius: 0; |
| 128 | + } |
| 129 | + |
| 130 | + pre { |
| 131 | + font-size: 85%; |
| 132 | + background-color: #f2f2f2; |
| 133 | + padding: 10px; |
| 134 | + } |
| 135 | + |
| 136 | + .button-container { |
| 137 | + background-color: #f2f2f2; |
| 138 | + flex-basis: 47.5%; |
| 139 | + padding: 5px; |
| 140 | + } |
| 141 | + |
| 142 | + .button-container div { |
| 143 | + margin-top: 5px; |
| 144 | + height: 45px; |
| 145 | + width: 100%; |
| 146 | + } |
| 147 | + |
| 148 | + .hint { |
| 149 | + color: #999; |
| 150 | + font-size: 85%; |
| 151 | + } |
| 152 | + |
| 153 | + .hidden { |
| 154 | + display: none; |
| 155 | + } |
| 156 | + </style> |
| 157 | +</body> |
0 commit comments