This repository has been archived by the owner on Jan 16, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample.html
256 lines (243 loc) · 8.46 KB
/
example.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
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
<!DOCTYPE html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>ePay Events Example</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="css/normalize.css">
<link href="css/bootstrap.min.css" rel="stylesheet" media="screen">
<link rel="stylesheet" href="css/main.css">
<script src="js/vendor/modernizr-2.6.2.min.js"></script>
</head>
<body>
<!--[if lt IE 7]>
<p class="browsehappy">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> to improve your experience.</p>
<![endif]-->
<div id="wrap">
<div class="navbar navbar-default navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<a class="navbar-brand" href="#">ePay Events Example</a>
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li><a href="index.html">Introduction</a></li>
<li class="active"><a href="example.html">Example</a></li>
<li><a href="http://tech.epay.dk" target="_blank">Documentation</a></li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li><a href="http://www.epay.eu" target="_blank">ePay</a></li>
</ul>
</div>
</div>
</div>
<div id="accept">
<div class="container">
<div class="alert alert-success">Your order is completed!</div>
<div id="accept-params">
<ul class="list-group">
</ul>
</div>
</div>
</div>
<div id="checkout">
<div class="container">
<table class="table table-bordered">
<thead>
<th>#</th>
<th>Product</th>
<th>Quantity</th>
<th>Total</th>
</thead>
<tr>
<td>1</td>
<td>ePay Test</td>
<td>1</td>
<td>DKK 100,95</td>
</tr>
<tfoot>
<tr>
<td colspan="3" class="text-right">
Fee:
</td>
<td>
<span id="fee">DKK 0,00</span>
</td>
</tr>
<tr>
<td colspan="3" class="text-right">
Total:
</td>
<td>
<span id="total">DKK 100,95</span>
</td>
</tr>
</tfoot>
</table>
<div class="alert alert-warning alert-dismissable" id="customer-alert">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
<strong>Could not save customer information.</strong>
</div>
<div class="row">
<div class="col-md-8">
<form role="form" id="customer-form" method="POST">
<div class="form-group">
<label for="firstname">Email address</label>
<input name="emailaddress" type="email" class="form-control" id="emailaddress" placeholder="Enter email address">
</div>
<div class="row">
<div class="col-md-6">
<div class="form-group">
<label for="firstname">First name</label>
<input name="firstname" type="text" class="form-control" id="firstname" placeholder="Enter first name">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label for="lastname">Last name</label>
<input name="lastname" type="text" class="form-control" id="lastname" placeholder="Enter last name">
</div>
</div>
</div>
<div class="form-group">
<label for="address">Address</label>
<input name="address" type="text" class="form-control" id="address" placeholder="Enter address">
</div>
<div class="row">
<div class="col-md-4">
<div class="form-group">
<label for="postcode">Post code</label>
<input name="postcode" type="text" class="form-control" id="postcode" placeholder="Enter post code">
</div>
</div>
<div class="col-md-8">
<div class="form-group">
<label for="city">City</label>
<input name="city" type="text" class="form-control" id="city" placeholder="Enter city">
</div>
</div>
</div>
<div class="form-group">
<label for="address">Comments</label>
<textarea name="comments" class="form-control" rows="3"></textarea>
</div>
</form>
</div>
<div class="col-md-4">
<div id="payment-div"></div>
<input onclick="javascript: checkout.openPaymentWindow();" type="button" class="btn btn-lg btn-success" id="epay_submit" value="Go to payment" style="visibility: hidden;">
</div>
</div>
</div>
</div>
</div>
<div id="footer">
<div class="container">
<p class="text-muted credit">Example by <a href="mailto:[email protected]">Michael Korsgaard</a>.</p>
</div>
</div>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script>window.jQuery || document.write('<script src="js/vendor/jquery-1.10.2.min.js"><\/script>')</script>
<script src="js/plugins.js"></script>
<script src="js/bootstrap.min.js"></script>
<script type="text/javascript">
function checkout ()
{
this.saveCustomerInformation = function ()
{
$.post("customer.html", $("#customer-form").serialize(),
function(data) {
if(data == "OK") {
paymentwindow.submit();
}
else {
checkout.showError();
}
}).fail(function(){ checkout.showError(); });
}
this.openPaymentWindow = function ()
{
$.post("customer.html", $("#customer-form").serialize(),
function(data) {
if(data == "OK") {
paymentwindow.open();
}
else {
checkout.showError();
}
}).fail(function(){ checkout.showError(); });;
}
this.showError = function ()
{
$("#customer-alert").show();
}
this.formatAmount = function(number)
{
number = number.toFixed(2) + '';
x = number.split('.');
x1 = x[0];
x2 = x.length > 1 ? ',' + x[1] : '';
var rgx = /(\d+)(\d{3})/;
while (rgx.test(x1)) {
x1 = x1.replace(rgx, '$1' + '.' + '$2');
}
return x1 + x2;
}
}
function PaymentWindowReady ()
{
checkout = new checkout();
paymentwindow = new PaymentWindow({
'merchantnumber': "99999999",
'amount': "10095",
'currency': "DKK",
'windowstate': "4",
'ownreceipt': "1",
'paymentcollection': "1",
'lockpaymentcollection': "1",
'iframewidth': "350",
'iframeheight': "400",
'mobile': "0",
'language': "en-GB",
});
if(paymentwindow.canUseEvents)
{
paymentwindow.options['cssurl'] = "https://raw.github.com/ePay/opc-example/master/css/style.css";
paymentwindow.on('completed', function(params) {
$("#checkout").hide();
$("#accept").show();
var acceptHtml = "";
var acceptParams = params.split('&');
for (acceptParam in acceptParams)
{
acceptHtml = acceptHtml + "<li class=\"list-group-item\">" + acceptParams[acceptParam].split('=')[0] + ": " +acceptParams[acceptParam].split('=')[1] + "</li>";
}
$("#accept-params > .list-group").html(acceptHtml);
});
paymentwindow.on('precompleted', function() {
checkout.saveCustomerInformation()
});
paymentwindow.on('feecalculated', function(fee){
$("#fee").html(paymentwindow.options['currency'] + " " + checkout.formatAmount(fee/100));
$("#total").html(paymentwindow.options['currency'] + " " + checkout.formatAmount((parseInt(paymentwindow.options['amount']) + parseInt(fee))/100));
})
paymentwindow.insert('payment-div');
paymentwindow.open();
}
else
{
paymentwindow.options['accepturl'] = "http://www.epay.dk/epay-payment-solutions/";
paymentwindow.options['cancelurl'] = "http://www.epay.dk";
paymentwindow.options['windowstate'] = "3";
document.getElementById('epay_submit').style.visibility = 'visible';
}
}
</script>
<script charset="UTF-8" src="https://ssl.ditonlinebetalingssystem.dk/integration/ewindow/paymentwindow.js" type="text/javascript"></script>
</body>
</html>