1
|
|
|
/** |
2
|
|
|
* PAYONE Magento 2 Connector is free software: you can redistribute it and/or modify |
3
|
|
|
* it under the terms of the GNU Lesser General Public License as published by |
4
|
|
|
* the Free Software Foundation, either version 3 of the License, or |
5
|
|
|
* (at your option) any later version. |
6
|
|
|
* |
7
|
|
|
* PAYONE Magento 2 Connector is distributed in the hope that it will be useful, |
8
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
9
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
10
|
|
|
* GNU Lesser General Public License for more details. |
11
|
|
|
* |
12
|
|
|
* You should have received a copy of the GNU Lesser General Public License |
13
|
|
|
* along with PAYONE Magento 2 Connector. If not, see <http://www.gnu.org/licenses/>. |
14
|
|
|
* |
15
|
|
|
* PHP version 5 |
16
|
|
|
* |
17
|
|
|
* @category Payone |
18
|
|
|
* @package Payone_Magento2_Plugin |
19
|
|
|
* @author FATCHIP GmbH <[email protected]> |
20
|
|
|
* @copyright 2003 - 2017 Payone GmbH |
21
|
|
|
* @license <http://www.gnu.org/licenses/> GNU Lesser General Public License |
22
|
|
|
* @link http://www.payone.de |
23
|
|
|
*/ |
24
|
|
|
/*jshint browser:true jquery:true*/ |
25
|
|
|
/*global alert*/ |
26
|
|
|
define([ |
27
|
|
|
'jquery', |
28
|
|
|
'Magento_Checkout/js/model/url-builder', |
29
|
|
|
'mage/storage', |
30
|
|
|
'Magento_Checkout/js/model/full-screen-loader', |
31
|
|
|
'Magento_Checkout/js/model/quote', |
32
|
|
|
'Magento_Customer/js/model/customer' |
33
|
|
|
], function ($, urlBuilder, storage, fullScreenLoader, quote, customer) { |
34
|
|
|
'use strict'; |
35
|
|
|
|
36
|
|
|
/** Override default place order action and add agreement_ids to request */ |
37
|
|
|
return function (baseView, birthday) { |
38
|
|
|
var serviceUrl; |
39
|
|
|
|
40
|
|
|
var request = { |
41
|
|
|
birthday: birthday |
42
|
|
|
}; |
43
|
|
|
if (!customer.isLoggedIn()) { |
44
|
|
|
serviceUrl = urlBuilder.createUrl('/guest-carts/:quoteId/payone-installmentPlan', { |
45
|
|
|
quoteId: quote.getQuoteId() |
46
|
|
|
}); |
47
|
|
|
request.email = quote.guestEmail; |
48
|
|
|
} else { |
49
|
|
|
serviceUrl = urlBuilder.createUrl('/carts/mine/payone-installmentPlan', {}); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
fullScreenLoader.startLoader(); |
53
|
|
|
|
54
|
|
|
return storage.post( |
55
|
|
|
serviceUrl, |
56
|
|
|
JSON.stringify(request) |
57
|
|
|
).done( |
58
|
|
|
function (response) { |
59
|
|
|
if (response.success == true) { |
60
|
|
|
$('#' + baseView.getCode() + '_installmentplan').html(response.installment_plan_html); |
61
|
|
|
$('#' + baseView.getCode() + '_installmentplan').show(); |
62
|
|
|
$('#' + baseView.getCode() + '_check').hide(); |
63
|
|
|
$('#' + baseView.getCode() + '_submit').show(); |
64
|
|
|
$('#' + baseView.getCode() + '_birthday_field').hide(); |
65
|
|
|
$('#' + baseView.getCode() + '_iban_field').show(); |
66
|
|
|
$('#' + baseView.getCode() + '_bic_field').show(); |
67
|
|
|
} else { |
68
|
|
|
alert(response.errormessage); |
69
|
|
|
} |
70
|
|
|
fullScreenLoader.stopLoader(); |
71
|
|
|
} |
72
|
|
|
).fail( |
73
|
|
|
function (response) { |
|
|
|
|
74
|
|
|
//errorProcessor.process(response, messageContainer); |
75
|
|
|
alert('An error occured.'); |
76
|
|
|
fullScreenLoader.stopLoader(); |
77
|
|
|
} |
78
|
|
|
); |
79
|
|
|
}; |
80
|
|
|
}); |
81
|
|
|
|
This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.