-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathpaymill_payment_elv.html
142 lines (130 loc) · 5.67 KB
/
paymill_payment_elv.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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script type="text/javascript">
var PAYMILL_PUBLIC_KEY = 'YOUR_PUBLIC_API_KEY';
var VALIDATE_CVC = true;
</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">
$.noConflict();
jQuery(document).ready(function ($) {
var formlang = 'de';
var doc = document;
var body = $( doc.body );
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-account-label").text(lang["form"]["elv-account"]);
$(".elv-holdername-label").text(lang["form"]["elv-holdername"]);
$(".elv-bankcode-label").text(lang["form"]["elv-bankcode"]);
$(".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 + "'/>");
alert('Teste');
form.get(0).submit();
}
$(".submit-button").removeAttr("disabled");
}
$("#payment-form").submit(function (event) {
$('.submit-button').attr("disabled", "disabled");
if ('' === $('.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 (false === paymill.validateAccountNumber($('.elv-account').val()) || $('.elv-bankcode').val().length > 10) {
$(".payment_errors").text(translation[formlang]["error"]["invalid-elv-accountnumber"]);
$(".payment_errors").css("display","inline-block");
$(".submit-button").removeAttr("disabled");
return false;
}
if (false === paymill.validateBankCode($('.elv-bankcode').val())) {
$(".payment_errors").text(translation[formlang]["error"]["invalid-elv-bankcode"]);
$(".payment_errors").css("display","inline-block");
$(".submit-button").removeAttr("disabled");
return false;
}
var params = {
number: $('.elv-account').val(),
bank: $('.elv-bankcode').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-account" class="elv-account-label field-left"></label>
<input id="elv-account" class="elv-account field-left" type="text">
<label for="elv-bankcode" class="elv-bankcode-label field-right"></label>
<input id="elv-bankcode" class="elv-bankcode 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>