-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathpaymill_payment_sepa.html
149 lines (134 loc) · 6.62 KB
/
paymill_payment_sepa.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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script type="text/javascript">
var PAYMILL_PUBLIC_KEY = 'YOUR_PUBLIC_API_KEY';
</script>
<link rel="stylesheet" type ="text/css" href="css/paymill_styles.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript" src="https://bridge.paymill.com/"></script>
<script type="text/javascript" src="lang/translation.js"></script>
<script type="text/javascript" src="js/Iban.js"></script>
<script type="text/javascript">
$.noConflict();
jQuery(document).ready(function($)
{
var formlang = 'de';
function translateForm(language)
{
formlang = language;
var lang;
if (translation[language] === undefined) {
lang = translation['en'];
} else {
lang = translation[language];
}
$("#btn-paymenttype-elv").text(lang["form"]["elv-paymentname"]);
$(".elv-iban-label").text(lang["form"]["elv-iban"]);
$(".elv-holdername-label").text(lang["form"]["elv-holdername"]);
$(".elv-bic-label").text(lang["form"]["elv-bic"]);
$(".amount-label").text(lang["form"]["amount"]);
$(".currency-label").text(lang["form"]["currency"]);
$(".submit-button").text(lang["form"]["submit-button"]);
}
function PaymillResponseHandler(error, result)
{
if (error) {
$(".payment_errors").text(error.apierror);
$(".payment_errors").css("display", "inline-block");
} else {
$(".payment_errors").css("display", "none");
$(".payment_errors").text("");
var form = $("#payment-form");
// Token
var token = result.token;
form.append("<input type='hidden' name='paymillToken' value='" + token + "'/>");
form.get(0).submit();
}
$(".submit-button").removeAttr("disabled");
}
$("#payment-form").submit(function()
{
iban = new Iban();
$('.submit-button').attr("disabled", "disabled");
if (!paymill.validateHolder($('.elv-holdername').val())) {
$(".payment_errors").text(translation[formlang]["error"]["invalid-elv-holdername"]);
$(".payment_errors").css("display", "inline-block");
$(".submit-button").removeAttr("disabled");
return false;
}
if (!iban.validate($('.elv-iban').val())) {
$(".payment_errors").text(translation[formlang]["error"]["invalid-elv-iban"]);
$(".payment_errors").css("display", "inline-block");
$(".submit-button").removeAttr("disabled");
return false;
}
if ($('.elv-bic').val().length !== 9 && $('.elv-bic').val().length !== 11) {
$(".payment_errors").text(translation[formlang]["error"]["invalid-elv-bic"]);
$(".payment_errors").css("display", "inline-block");
$(".submit-button").removeAttr("disabled");
return false;
}
ibanData = $('.elv-iban').val().replace(/\s+/g, "");
var params = {
iban: ibanData,
bic: $('.elv-bic').val(),
accountholder: $('.elv-holdername').val()
};
paymill.createToken(params, PaymillResponseHandler);
return false;
});
$("#language_switch").click(function()
{
var language = formlang;
var newimg;
if (formlang === 'en') {
newimg = "image/gb.png";
language = "de";
} else {
newimg = "image/de.png";
language = "en";
}
$(this).attr("src", newimg);
translateForm(language);
});
translateForm(formlang);
});
</script>
</head>
<body>
<div id="paymill_example_form">
<div id="top_switch" class="minimal">
<img src="image/gb.png" id="language_switch">
</div>
<form id="payment-form" action="payment.php" method="POST">
<header>
<img alt="Logo" src="image/paymill-logo-signet.png">
<h1 class="form-signin-heading">Title stands here</h1>
<h2 class="form-signin-heading">Description 1-year free</h2>
</header>
<div class="payment_errors"> </div>
<fieldset>
<label for="elv-iban" class="elv-iban-label field-left"></label>
<input id="elv-iban" class="elv-iban field-left" type="text">
<label for="elv-bic" class="elv-bic-label field-right"></label>
<input id="elv-bic" class="elv-bic field-right" type="text">
</fieldset>
<fieldset>
<label for="elv-holdername" class="elv-holdername-label field-full"></label>
<input id="elv-holdername" class="elv-holdername field-full" type="text">
</fieldset>
<fieldset>
<label for="amount" class="amount-label field-left"></label>
<input id="amount" class="amount field-left" type="text" value="10.00" name="amount">
<label for="currency" class="currency-label field-right"></label>
<input id="currency" class="currency field-right" type="text" value="EUR" name="currency">
</fieldset>
<fieldset id="buttonWrapper">
<button id="paymill-submit-button" class="submit-button btn btn-primary" type="submit"></button>
</fieldset>
</form>
</div>
</body>
</html>