-
Notifications
You must be signed in to change notification settings - Fork 0
/
automated.html
188 lines (183 loc) · 8.03 KB
/
automated.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title></title>
<script type="text/javascript" src="./utilities.js"></script>
</head>
<style>
iframe {
border: none;
height: 70vh;
width: 90vw;
max-width: 40em;
}
input:not([type=checkbox]),
select {
display: block;
}
</style>
<script>
let authorization
window.addEventListener('DOMContentLoaded', (event) => {
initialize()
});
function submit() {
const sender = {
"name": {
"first": document.getElementById("sender-first-name").value,
"last": document.getElementById("sender-last-name").value,
},
"address": {
"city": document.getElementById("sender-city").value,
"countryCode": document.getElementById("sender-country-code").value,
"street": document.getElementById("sender-street").value,
"zipCode": document.getElementById("sender-zip-code").value,
},
"accountType": document.getElementById("sender-account-type").value,
"accountNumber": document.getElementById("sender-account-number").value,
}
const receiver = {
"name": {
"first": document.getElementById("receiver-first-name").value,
"last": document.getElementById("receiver-last-name").value,
},
"address": {
"city": document.getElementById("receiver-city").value,
"countryCode": document.getElementById("receiver-country-code").value,
"street": document.getElementById("receiver-street").value,
"zipCode": document.getElementById("receiver-zip-code").value,
},
"accountType": document.getElementById("receiver-account-type").value,
"accountNumber": document.getElementById("receiver-account-number").value,
}
const category = document.getElementById("category").value
authorization = {
"number": generateUnique(), // "Should be your unique authorization number"
"amount": Number(document.getElementById("amount").value),
"currency": document.getElementById("currency").value,
capture: document.getElementById("auto-capture").checked ? "auto" : undefined,
"category": category,
"card": {
"pan": document.getElementById("pan").value,
"expires": [
Number(document.getElementById("expires").value.split("/")[0]),
Number(document.getElementById("expires").value.split("/")[1])
],
"csc": document.getElementById("csc").value,
},
target: "https://merchant.igacq.com/v1/integration-example",
...((category == "funding" || category == "payout")
&& { sender, receiver: document.getElementById("same-receiver").checked ? sender : receiver })
}
authorize()
}
async function authorize() {
const form = document.getElementById("iframePost")
form.input.value = JSON.stringify(authorization)
form.key.value = "Bearer " + document.getElementById("api-key").value.trim()
form.submit()
}
window.addEventListener("message", async e => {
if (e.data.destination == "parent" && e.data.content.name == "authorization") {
alert(e.data.content.value)
appendToBody("h1", "Created Authorization:")
appendToBody("p", e.data.content.value)
}
})
</script>
<body style="width: 100%; max-width: 20em; margin-left: auto; margin-right: auto;">
<form method="post" id="iframePost" action="https://merchant.intergiro.com/v1/authorization/redirect"
target="verification">
<input type="hidden" id="input" name="input"></input>
<input type="hidden" id="key" name="key"></input>
</form>
<form method="post">
<label for="key">Public API key</label>
<input type="text" id="api-key" name="key" />
<label for="pan">PAN</label>
<input type="text" id="pan" name="pan" autocomplete="cc-number" value="4111111111111111" />
<label for="csc" autocomplete="cc-csc">CSC</label>
<input type="text" id="csc" name="csc" value="987" />
<label for="expires">Expires</label>
<input type="text" id="expires" name="expires" autocomplete="cc-exp" placeholder="MM/YY" value="1/32" />
<input type="checkbox" id="auto-capture" name="auto-capture" checked />
<label for="auto-capture">Auto Capture</label><br />
<label for="category">Category</label>
<select id="category" name="category">
<option value="purchase">purchase</option>
<option value="withdrawal">withdrawal</option>
<option value="payout">payout</option>
<option value="funding">funding</option>
<option value="topup">topup</option>
<option value="tip">tip</option>
</select>
<label for="currency">Currency</label>
<input type="text" id="currency" name="currency" autocomplete="transaction-currency" value="EUR" />
<label for="amount">Amount</label>
<input type="text" id="amount" name="amount" autocomplete="transaction-amount" value="250" />
<div id="sender-receiver" hidden>
<fieldset id="sender">
<legend>Sender</legend>
<label for="sender-first-name">First Name</label>
<input type="text" id="sender-first-name" name="sender-first-name" autocomplete="cc-given-name" value="Jane" />
<label for="sender-last-name">Last Name</label>
<input type="text" id="sender-last-name" name="sender-last-name" autocomplete="cc-family-name" value="Doe" />
<label for="sender-city">City</label>
<input type="text" id="sender-city" name="sender-city" value="Stockholm" />
<label for="sender-country-code">Country Code</label>
<input type="text" id="sender-country-code" name="sender-country-code" autocomplete="country" value="SE" />
<label for="sender-street">Street</label>
<input type="text" id="sender-street" name="sender-street" street-address="street-address"
value="Hammarbyvägen 1" />
<label for="sender-zip-code">Zip Code</label>
<input type="text" id="sender-zip-code" name="sender-zip-code" autocomplete="postal-code" value="75111" />
<label for="sender-account-type">Account Type</label>
<select id="sender-account-type" name="sender-account-type">
<option value="card">card</option>
<option value="bic">bic</option>
<option value="iban">iban</option>
<option value="cash">cash</option>
<option value="wallet">wallet</option>
</select>
<label for="sender-account-number">Account Number</label>
<input type="text" id="sender-account-number" name="sender-account-number" value="4111111111111111" />
<input type="checkbox" id="same-receiver" name="same-receiver" checked />
<label for="same-receiver">Same Receiver</label>
</fieldset>
<fieldset id="receiver" hidden>
<legend>Receiver</legend>
<label for="receiver-first-name">First Name</label>
<input type="text" id="receiver-first-name" name="receiver-first-name" autocomplete="cc-given-name"
value="Joe" />
<label for="receiver-last-name">Last Name</label>
<input type="text" id="receiver-last-name" name="receiver-last-name" autocomplete="cc-family-name"
value="Doe" />
<label for="receiver-city">City</label>
<input type="text" id="receiver-city" name="receiver-city" value="Uppsala" />
<label for="receiver-country-code">Country Code</label>
<input type="text" id="receiver-country-code" name="receiver-country-code" autocomplete="country" value="SE" />
<label for="receiver-street">Street</label>
<input type="text" id="receiver-street" name="receiver-street" street-address="street-address"
value="Rackarbergsgatan 2" />
<label for="receiver-zip-code">Zip Code</label>
<input type="text" id="receiver-zip-code" name="receiver-zip-code" autocomplete="postal-code" value="75222" />
<label for="receiver-account-type">Account Type</label>
<select id="receiver-account-type" name="receiver-account-type">
<option value="iban">iban</option>
<option value="card">card</option>
<option value="bic">bic</option>
<option value="cash">cash</option>
<option value="wallet">wallet</option>
</select>
<label for="receiver-account-number">Account Number</label>
<input type="text" id="receiver-account-number" name="sender-account-number" value="IE12BOFI90000112345678" />
</fieldset>
</div>
</form>
<button onclick="submit()">Submit</button>
<iframe id="verification" name="verification"></iframe>
</body>
</html>