|
1
|
|
|
function displayPayolutionOverlay(sCode) |
|
2
|
|
|
{ |
|
3
|
|
|
document.getElementById(sCode + '_overlay').style.display = ""; |
|
4
|
|
|
} |
|
5
|
|
|
function removePayolutionOverlay(sCode) |
|
6
|
|
|
{ |
|
7
|
|
|
document.getElementById(sCode + '_overlay').style.display = "none"; |
|
8
|
|
|
} |
|
9
|
|
|
|
|
10
|
|
|
function switchVisibility(aIds, blShow) |
|
11
|
|
|
{ |
|
12
|
|
|
for(var i = 0; i < aIds.length; i++) { |
|
13
|
|
|
var oElement = $(aIds[i]); |
|
14
|
|
|
if(oElement) { |
|
15
|
|
|
if(blShow == true) { |
|
16
|
|
|
oElement.show(); |
|
17
|
|
|
} else { |
|
18
|
|
|
oElement.hide(); |
|
19
|
|
|
} |
|
20
|
|
|
} |
|
21
|
|
|
} |
|
22
|
|
|
} |
|
23
|
|
|
|
|
24
|
|
|
function payoneSwitchPayolution(oSelect, sCode) |
|
25
|
|
|
{ |
|
26
|
|
|
if (oSelect == undefined) { |
|
27
|
|
|
return; |
|
28
|
|
|
} |
|
29
|
|
|
|
|
30
|
|
|
if(oSelect.value == 'PYV') { |
|
31
|
|
|
var aHide = [ |
|
32
|
|
|
sCode + '_debit_wrap', |
|
33
|
|
|
sCode + '_debit_wrap2', |
|
34
|
|
|
sCode + '_installment_wrap1', |
|
35
|
|
|
sCode + '_installment_wrap2' |
|
36
|
|
|
]; |
|
37
|
|
|
var aShow = [ |
|
38
|
|
|
sCode + '_b2b_wrap', |
|
39
|
|
|
sCode + '_birthday_wrap', |
|
40
|
|
|
sCode + '_acceptance_wrap' |
|
41
|
|
|
]; |
|
42
|
|
|
switchVisibility(aHide, false); |
|
43
|
|
|
switchVisibility(aShow, true); |
|
44
|
|
|
$(sCode + '_selected_installmentplan').value = '0'; |
|
45
|
|
|
} else if(oSelect.value == 'PYD') { |
|
46
|
|
|
var aHide = [ |
|
|
|
|
|
|
47
|
|
|
sCode + '_installment_wrap1', |
|
48
|
|
|
sCode + '_installment_wrap2', |
|
49
|
|
|
sCode + '_debit_subwrap' |
|
50
|
|
|
]; |
|
51
|
|
|
var aShow = [ |
|
|
|
|
|
|
52
|
|
|
sCode + '_debit_wrap', |
|
53
|
|
|
sCode + '_debit_wrap2', |
|
54
|
|
|
sCode + '_b2b_wrap', |
|
55
|
|
|
sCode + '_birthday_wrap', |
|
56
|
|
|
sCode + '_acceptance_wrap' |
|
57
|
|
|
]; |
|
58
|
|
|
switchVisibility(aHide, false); |
|
59
|
|
|
switchVisibility(aShow, true); |
|
60
|
|
|
$(sCode + '_selected_installmentplan').value = '0'; |
|
61
|
|
|
} else if(oSelect.value == 'PYS') { |
|
62
|
|
|
if(!$(sCode + '_installment_wrap2').visible()) {// reset installment init state |
|
63
|
|
|
var aHide = [ |
|
|
|
|
|
|
64
|
|
|
sCode + '_debit_wrap', |
|
65
|
|
|
sCode + '_debit_wrap2', |
|
66
|
|
|
sCode + '_debit_subwrap' |
|
67
|
|
|
]; |
|
68
|
|
|
var aShow = [ |
|
|
|
|
|
|
69
|
|
|
sCode + '_installment_wrap1' |
|
70
|
|
|
]; |
|
71
|
|
|
switchVisibility(aHide, false); |
|
72
|
|
|
switchVisibility(aShow, true); |
|
73
|
|
|
$(sCode + '_selected_installmentplan').value = ''; |
|
74
|
|
|
} |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
if(oSelect.value == '') { |
|
78
|
|
|
$(sCode + '_main_block').hide(); |
|
79
|
|
|
} else { |
|
80
|
|
|
$(sCode + '_main_block').show(); |
|
81
|
|
|
} |
|
82
|
|
|
} |
|
83
|
|
|
|
|
84
|
|
|
function handleInstallmentAllowed(response) |
|
85
|
|
|
{ |
|
86
|
|
|
$(response.code + '_installment_wrap2').update(response.update_section.html); |
|
87
|
|
|
|
|
88
|
|
|
var aHide = [ |
|
89
|
|
|
response.code + '_b2b_wrap', |
|
90
|
|
|
response.code + '_birthday_wrap', |
|
91
|
|
|
response.code + '_acceptance_wrap', |
|
92
|
|
|
response.code + '_installment_wrap1' |
|
93
|
|
|
]; |
|
94
|
|
|
var aShow = [ |
|
95
|
|
|
response.code + '_installment_wrap2' |
|
96
|
|
|
]; |
|
97
|
|
|
switchVisibility(aHide, false); |
|
98
|
|
|
switchVisibility(aShow, true); |
|
99
|
|
|
} |
|
100
|
|
|
|
|
101
|
|
|
function handleInstallment(sCode, sUrl) |
|
102
|
|
|
{ |
|
103
|
|
|
if (checkout.loadWaiting!=false) return; |
|
|
|
|
|
|
104
|
|
|
|
|
105
|
|
|
var validator = new Validation(payment.form); |
|
|
|
|
|
|
106
|
|
|
if (payment.validate() && validator.validate()) { |
|
107
|
|
|
checkout.setLoadWaiting('payment'); |
|
108
|
|
|
|
|
109
|
|
|
var sDob = $(sCode + '_additional_fields_customer_dob_full').value; |
|
110
|
|
|
var sType = $(sCode + '_type_select').value; |
|
111
|
|
|
var sPaymentMethodId = $(sCode + '_payment_method_id').value; |
|
112
|
|
|
|
|
113
|
|
|
new Ajax.Request( |
|
|
|
|
|
|
114
|
|
|
sUrl, { |
|
115
|
|
|
method: 'Post', |
|
116
|
|
|
parameters: { |
|
117
|
|
|
payone_payolution_type : sType, |
|
118
|
|
|
payone_customer_dob : sDob, |
|
119
|
|
|
payone_config_payment_method_id : sPaymentMethodId, |
|
120
|
|
|
code : sCode |
|
121
|
|
|
}, |
|
122
|
|
|
onComplete: function (transport) { |
|
123
|
|
|
checkout.setLoadWaiting(false); |
|
|
|
|
|
|
124
|
|
|
if(transport.responseText) { |
|
125
|
|
|
response = JSON.parse(transport.responseText); |
|
|
|
|
|
|
126
|
|
|
if(response.success == true) { |
|
127
|
|
|
handleInstallmentAllowed(response); |
|
128
|
|
|
return; |
|
129
|
|
|
} |
|
130
|
|
|
} |
|
131
|
|
|
|
|
132
|
|
|
alert(Translator.translate("The installment calculation failed. Please choose another payment type.")); |
|
|
|
|
|
|
133
|
|
|
} |
|
134
|
|
|
} |
|
135
|
|
|
); |
|
136
|
|
|
} |
|
137
|
|
|
} |
|
138
|
|
|
|
|
139
|
|
|
function switchInstallmentPlan(sKey, sCode, iInstallments) |
|
140
|
|
|
{ |
|
141
|
|
|
$$('.payolution_installmentplans').each( |
|
142
|
|
|
function (e) { |
|
143
|
|
|
e.hide(); |
|
144
|
|
|
} |
|
145
|
|
|
); |
|
146
|
|
|
$$('.payolution_installment_overview').each( |
|
147
|
|
|
function (e) { |
|
148
|
|
|
e.hide(); |
|
149
|
|
|
} |
|
150
|
|
|
); |
|
151
|
|
|
|
|
152
|
|
|
var aShow = [ |
|
153
|
|
|
'payolution_installmentplan_' + sKey, |
|
154
|
|
|
'payolution_installment_overview_' + sKey, |
|
155
|
|
|
sCode + '_debit_wrap', |
|
156
|
|
|
sCode + '_debit_subwrap' |
|
157
|
|
|
]; |
|
158
|
|
|
switchVisibility(aShow, true); |
|
159
|
|
|
$(sCode + '_selected_installmentplan').value = iInstallments; |
|
160
|
|
|
} |
This check looks for variables that are declared in multiple lines. There may be several reasons for this.
In the simplest case the variable name was reused by mistake. This may lead to very hard to locate bugs.
If you want to reuse a variable for another purpose, consider declaring it at or near the top of your function and just assigning to it subsequently so it is always declared.