Skip to content

Commit cd1dead

Browse files
authored
Merge pull request #30 from datatrans/PCIP-642-add-wallets-example
PCIP-642: add wallet buttons example
2 parents d88d9e4 + 1370948 commit cd1dead

8 files changed

Lines changed: 167 additions & 2 deletions

File tree

index.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
<a style="color: #fff; margin: 0 10px; text-decoration: none;" href="pciproxy-examples/floating-label.html">Floating Label</a>
1515
<a style="color: #fff; margin: 0 10px; text-decoration: none;" href="pciproxy-examples/iban.html">IBAN</a>
1616
<a style="color: #fff; margin: 0 10px; text-decoration: none;" href="pciproxy-examples/account.html">Account Number</a>
17+
<a style="color: #fff; margin: 0 10px; text-decoration: none;" href="pciproxy-examples/wallets.html">Wallets</a>
18+
<a style="color: #fff; margin: 0 10px; text-decoration: none;" href="pciproxy-examples/show.html">Reveal Card (Show API)</a>
1719
</nav>
1820
<p style="text-align: center;">Please select an example above.</p>
1921
<script>

pciproxy-examples/account.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
<a href="floating-label.html">Floating Label</a>
1515
<a href="iban.html">IBAN</a>
1616
<a style="text-decoration: underline;" href="account.html">Account Number</a>
17+
<a href="wallets.html">Wallets</a>
1718
<a href="show.html">Reveal Card (Show API)</a>
1819
</nav>
1920
<form style="max-width: 400px; margin: 0 auto;">

pciproxy-examples/floating-label.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
<a style="text-decoration: underline;" href="floating-label.html">Floating Label</a>
1515
<a href="iban.html">IBAN</a>
1616
<a href="account.html">Account Number</a>
17+
<a href="wallets.html">Wallets</a>
1718
<a href="show.html">Reveal Card (Show API)</a>
1819
</nav>
1920
<form style="max-width: 400px; margin: 0 auto;">

pciproxy-examples/iban.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
<a href="floating-label.html">Floating Label</a>
1515
<a style="text-decoration: underline;" href="iban.html">IBAN</a>
1616
<a href="account.html">Account Number</a>
17+
<a href="wallets.html">Wallets</a>
1718
<a href="show.html">Reveal Card (Show API)</a>
1819
</nav>
1920
<form style="max-width: 400px; margin: 0 auto;">

pciproxy-examples/index.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
<a href="floating-label.html">Floating Label</a>
1616
<a href="iban.html">IBAN</a>
1717
<a href="account.html">Account Number</a>
18-
<a href="show.html">Reveal card (Show API)</a>
18+
<a href="wallets.html">Wallets</a>
19+
<a href="show.html">Reveal Card (Show API)</a>
1920
</nav>
2021
<form style="max-width: 400px; margin: 0 auto;">
2122
<div style="max-width: 400px">

pciproxy-examples/inline-example.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
<a href="floating-label.html">Floating Label</a>
1717
<a href="iban.html">IBAN</a>
1818
<a href="account.html">Account Number</a>
19+
<a href="wallets.html">Wallets</a>
1920
<a href="show.html">Reveal Card (Show API)</a>
2021
</nav>
2122
<form style="max-width: 390px; margin: 0 auto;">

pciproxy-examples/show.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,14 @@
1414
<a href="floating-label.html">Floating Label</a>
1515
<a href="iban.html">IBAN</a>
1616
<a href="account.html">Account Number</a>
17+
<a href="wallets.html">Wallets</a>
1718
<a style="text-decoration: underline;" href="show.html">Reveal Card (Show API)</a>
1819
</nav>
1920
<div style="max-width: 400px; margin: 0 auto;">
2021
<p>
2122
This example shows how to reveal card data using the PCI Proxy Show API. Using
2223
this feature requires a server-to-server call from a whitelisted IP to obtain a specific <code>transactionId</code>.
23-
See the <a href="https://docs.pci-proxy.com/use/show/web" target="_blank">documentation</a>.
24+
See the <a href="https://docs.pci-proxy.com/docs/show-api" target="_blank">documentation</a>.
2425
</p>
2526

2627
<form style="margin: 20px 0">

pciproxy-examples/wallets.html

Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
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

Comments
 (0)