|
1
|
|
|
/** |
|
2
|
|
|
* |
|
3
|
|
|
* NOTICE OF LICENSE |
|
4
|
|
|
* |
|
5
|
|
|
* This source file is subject to the GNU General Public License (GPL 3) |
|
6
|
|
|
* that is bundled with this package in the file LICENSE.txt |
|
7
|
|
|
* |
|
8
|
|
|
* DISCLAIMER |
|
9
|
|
|
* |
|
10
|
|
|
* Do not edit or add to this file if you wish to upgrade Payone_Core to newer |
|
11
|
|
|
* versions in the future. If you wish to customize Payone_Core for your |
|
12
|
|
|
* needs please refer to http://www.payone.de for more information. |
|
13
|
|
|
* |
|
14
|
|
|
* @category Payone |
|
15
|
|
|
* @package js |
|
16
|
|
|
* @subpackage payone |
|
17
|
|
|
* @copyright Copyright (c) 2012 <[email protected]> - www.noovias.com |
|
18
|
|
|
* @author Matthias Walter <[email protected]> |
|
19
|
|
|
* @license <http://www.gnu.org/licenses/> GNU General Public License (GPL 3) |
|
20
|
|
|
* @link http://www.noovias.com |
|
21
|
|
|
*/ |
|
22
|
|
|
|
|
23
|
|
|
Event.observe( |
|
|
|
|
|
|
24
|
|
|
window, 'load', function () { |
|
25
|
|
|
wrapAddressNextStepEvents(); |
|
26
|
|
|
} |
|
27
|
|
|
); |
|
28
|
|
|
|
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* Place a wrapper for the nextStep function on Magento´s Billing and Shipping objects, to allow additional output on addresscheck failure |
|
32
|
|
|
*/ |
|
33
|
|
|
function wrapAddressNextStepEvents() |
|
34
|
|
|
{ |
|
35
|
|
|
billing.onSave = nextStepWithAddresscheckOutput.bindAsEventListener(billing.nextStep, 'billing', billing.nextStep); |
|
|
|
|
|
|
36
|
|
|
|
|
37
|
|
|
if (typeof shipping != "undefined") // no shipping inputs for virtual orders. |
|
|
|
|
|
|
38
|
|
|
{ |
|
39
|
|
|
shipping.onSave = nextStepWithAddresscheckOutput.bindAsEventListener(shipping.nextStep, 'shipping', shipping.nextStep); |
|
40
|
|
|
} |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
function nextStepWithAddresscheckOutput(transport, address_type, origSaveMethod) |
|
44
|
|
|
{ |
|
45
|
|
|
|
|
46
|
|
|
if (transport && transport.responseText) { |
|
47
|
|
|
var response = transport.responseText.evalJSON(); |
|
48
|
|
|
if (response.error) { |
|
49
|
|
|
if (response.message.payone_address_invalid) { |
|
50
|
|
|
response.message = response.message.payone_address_invalid; |
|
51
|
|
|
transport.responseText = '{"error":1,"message":"' + response.message + '"}'; |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
if (response.message.payone_address_error) { |
|
55
|
|
|
response.message = response.message.payone_address_error; |
|
56
|
|
|
transport.responseText = '{"error":1,"message":"' + response.message + '"}'; |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
if (response.message.payone_address_corrected) { |
|
60
|
|
|
handleCorrectedAddress(response.message.payone_address_corrected, address_type); |
|
61
|
|
|
response.message = response.message.payone_address_corrected.customermessage; |
|
62
|
|
|
|
|
63
|
|
|
//transport.responseText = '{"error":1,"message":"' + response.message + '"}'; |
|
64
|
|
|
} |
|
65
|
|
|
} |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
var result = origSaveMethod(transport); |
|
|
|
|
|
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
|
|
72
|
|
|
function handleCorrectedAddress(data, address_type) |
|
73
|
|
|
{ |
|
74
|
|
|
sConfirmMessage = data.customermessage + "\n\n"; |
|
|
|
|
|
|
75
|
|
|
sConfirmMessage += data.street + "\n"; |
|
76
|
|
|
if(data.street2 != '') { |
|
77
|
|
|
sConfirmMessage += data.street2 + "\n"; |
|
78
|
|
|
} |
|
79
|
|
|
|
|
80
|
|
|
sConfirmMessage += data.city + "\n"; |
|
81
|
|
|
sConfirmMessage += data.postcode; |
|
82
|
|
|
if(confirm(sConfirmMessage)) { |
|
83
|
|
|
$(address_type + ':street1').value = data.street; |
|
84
|
|
|
$(address_type + ':street2').value = data.street2; |
|
85
|
|
|
$(address_type + ':city').value = data.city; |
|
86
|
|
|
$(address_type + ':postcode').value = data.postcode; |
|
87
|
|
|
Element.show(address_type + '-new-address-form'); |
|
|
|
|
|
|
88
|
|
|
|
|
89
|
|
|
var addressSelectBox = $(address_type + '-address-select'); |
|
90
|
|
|
if(addressSelectBox != undefined) |
|
91
|
|
|
addressSelectBox.value = ''; |
|
|
|
|
|
|
92
|
|
|
} else { |
|
93
|
|
|
if($(address_type + '-new-address-form') && !$(address_type + "_change_denied")) { |
|
94
|
|
|
var newHiddenInput = document.createElement("input"); |
|
95
|
|
|
newHiddenInput.setAttribute("type", "hidden"); |
|
96
|
|
|
newHiddenInput.setAttribute("id", address_type + "_change_denied"); |
|
97
|
|
|
newHiddenInput.setAttribute("name", address_type + "_change_denied"); |
|
98
|
|
|
newHiddenInput.setAttribute("value", "1"); |
|
99
|
|
|
|
|
100
|
|
|
document.getElementById(address_type + '-new-address-form').parentNode.appendChild(newHiddenInput); |
|
101
|
|
|
} |
|
102
|
|
|
} |
|
103
|
|
|
} |
This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.
To learn more about declaring variables in Javascript, see the MDN.