-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
240 lines (192 loc) · 8.23 KB
/
index.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
<!DOCTYPE html>
<html>
<head>
<title>Berlin Geekettes Hackathon | PAYMILL Live Demo</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<link rel="stylesheet" href="https://netdna.bootstrapcdn.com/twitter-bootstrap/2.2.1/css/bootstrap.no-responsive.no-icons.min.css">
<!--
PAYMILL public API key (Cockpit -> Settings -> API-Keys)
-->
<script type="text/javascript">
var PAYMILL_PUBLIC_KEY = '<YOUR-PUBLIC-KEY>';
</script>
<!--
PAYMILL bridge (JavaScript lib for the card tokenization)
-->
<script src="https://bridge.paymill.com/"></script>
</head>
<body style="background-color: #ec4f00; padding: 15px 40px; color: #fff; font-family: Arial;">
<img src="img/glogo.png" style="margin-bottom: 30px; height: 120px;">
<img src="img/logo.png" style="margin: 30px 15px; height: 50px;">
<br>
<div class="container span7" style="color: #000;">
<div class="controls">
<div class="span4">
<div class="payment-errors text-error"></div>
</div>
</div>
<div class="clearfix"></div>
<div class="well span5">
<div class="controls controls-row">
<div class="btn-group span4">
<button id="btn-paymenttype-cc" class="paymenttype btn btn-primary disabled" value="cc">Credit card</button>
<button id="btn-paymenttype-elv" class="paymenttype btn" value="elv">ELV</button>
</div><br /><br />
</div>
<!-- Start: Payment form -->
<form id="payment-form" action="request.php" method="POST">
<div class="clearfix"></div>
<!--
Start: CREDIT CARD FORM
-->
<div id="payment-form-cc">
<input class="card-amount-int" type="hidden" value="15"/>
<input class="card-currency" type="hidden" value="EUR"/>
<div class="controls controls-row">
<div class="span3"><label>Card number</label>
<input class="card-number span3" type="text" size="20" value="4111111111111111"/>
</div>
<div class="span1"><label>CVC</label>
<input class="card-cvc span1" type="text" size="4" value="111"/>
</div>
</div>
<div class="controls">
<div class="span4">
<label>Card holder</label>
<input class="card-holdername span4" type="text" size="20" value="Max Mustermann"/>
</div>
</div>
<div class="controls">
<div class="span3">
<label>Valid until (MM/YYYY)</label>
<input class="card-expiry-month span1" type="text" size="2" value="12"/>
<span> / </span>
<input class="card-expiry-year span1" type="text" size="4" value="2015"/>
</div>
</div>
</div>
<!--
End: CREDIT CARD FORM
-->
<div id="payment-form-elv" style="display: none;">
<div class="controls">
<div class="span3">
<label>Account holder</label>
<input class="elv-holdername span3" type="text" size="20" value="Max Mustermann"/>
</div>
</div>
<div class="controls controls-row">
<div class="span3"><label>Account number</label>
<input class="elv-account span3" type="text" size="20" value="1234567890"/>
</div>
</div>
<div class="controls">
<div class="span3">
<label>Bank code</label>
<input class="elv-bankcode span3" type="text" size="20" value="40050150"/>
</div>
</div>
</div>
<div class="controls">
<div class="span3">
<button class="submit-button btn btn-primary" type="submit">Buy now</button> (0,15 EUR)
</div>
</div>
</form>
<!-- End: Payment form -->
</div>
</div>
<div class="row" style="font-size: 120%;">
<strong>< Online payments made easy /></strong><br><br>
1. Build a nice credit card <strong>form</strong><br>
2. Include the PAYMILL <strong>brigde</strong> (for tokenizatoin)<br>
3. Include one of our <strong>API Wrappers</strong> e.g. PHP, Ruby, node.js, JAVA etc. (optional)<br>
4. <strong>Do a transaction</strong> using the received token<br>
5. Be happy about the <strong>simplicity</strong> and win a Kindle Fire :)<br>
<br><br>
Please ask me if you need more help:<br><br>
Tschela Baumann<br>
E-Mail: [email protected]<br>
Twitter: paymill_tb<br>
Visit: www.paymill.com<br>
Github: github.com/paymill
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script src="https://netdna.bootstrapcdn.com/twitter-bootstrap/2.2.1/js/bootstrap.min.js"></script>
<script language="javascript" type="text/javascript">
$(document).ready(function () {
//
// Use brigde functions to receive the token
//
$("#payment-form").submit(function (event) {
// Deactivate the submit button to avoid further clicks
$('.submit-button').attr("disabled", "disabled");
if (false == paymill.validateCardNumber($('.card-number').val())) {
$(".payment-errors").text("Invalid card number");
$(".submit-button").removeAttr("disabled");
return false;
}
if (false == paymill.validateExpiry($('.card-expiry-month').val(), $('.card-expiry-year').val())) {
$(".payment-errors").text("Invalid date of expiry");
$(".submit-button").removeAttr("disabled");
return false;
}
paymenttype = $('.paymenttype.disabled').length ? $('.paymenttype.disabled').val() : 'cc';
switch (paymenttype) {
case "cc":
var params = {
amount_int: $('.card-amount-int').val(), // E.g. "15" for 0.15 Eur
//amount: $('.card-amount').val(), // deprecated!
currency: $('.card-currency').val(), // ISO 4217 e.g. "EUR"
number: $('.card-number').val(),
exp_month: $('.card-expiry-month').val(),
exp_year: $('.card-expiry-year').val(),
cvc: $('.card-cvc').val(),
cardholder: $('.card-holdername').val()
};
break;
case "elv":
var params = {
number: $('.elv-account').val(),
bank: $('.elv-bankcode').val(),
accountholder: $('.elv-holdername').val()
};
break;
}
paymill.createToken(params, PaymillResponseHandler);
return false;
});
//
// Start: Response handler
//
function PaymillResponseHandler(error, result) {
if (error) {
// Show the error message above the form
$(".payment-errors").text(error.apierror);
} else {
$(".payment-errors").text("");
var form = $("#payment-form");
// Token
var token = result.token;
// Insert token into the payment form
form.append("<input type='hidden' name='paymillToken' value='" + token + "'/>");
form.get(0).submit();
}
$(".submit-button").removeAttr("disabled");
}
// Toggle buttons and forms
$(".paymenttype").click(function (event) {
$(this).addClass('btn-primary disabled');
$('#payment-form-cc').toggle();
$('#payment-form-elv').toggle();
if($(this).val()=='cc') {
$('#btn-paymenttype-elv').removeClass('btn-primary disabled');
}
else {
$('#btn-paymenttype-cc').removeClass('btn-primary disabled');
}
});
});
</script>
</body>
</html>