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 - 2016 Payone GmbH |
21
|
|
|
* @license <http://www.gnu.org/licenses/> GNU Lesser General Public License |
22
|
|
|
* @link http://www.payone.de |
23
|
|
|
*/ |
24
|
|
|
define( |
25
|
|
|
[ |
26
|
|
|
'Magento_Checkout/js/view/payment/default', |
27
|
|
|
'Payone_Core/js/action/handle-redirect', |
28
|
|
|
'Payone_Core/js/action/handle-debit', |
29
|
|
|
'Magento_Checkout/js/model/payment/additional-validators' |
30
|
|
|
], |
31
|
|
|
function (Component, handleRedirectAction, handleDebitAction, additionalValidators) { |
32
|
|
|
'use strict'; |
33
|
|
|
return Component.extend({ |
34
|
|
|
continueToPayone: function () { |
35
|
|
|
if (this.validate() && additionalValidators.validate()) { |
|
|
|
|
36
|
|
|
// update payment method information if additional data was changed |
37
|
|
|
this.selectPaymentMethod(); |
38
|
|
|
handleRedirectAction(this.getData(), this.messageContainer); |
39
|
|
|
return false; |
40
|
|
|
} |
41
|
|
|
}, |
42
|
|
|
|
43
|
|
|
handleCreditcardPayment: function () { |
44
|
|
|
var firstValidation = additionalValidators.validate(); |
45
|
|
|
if (!(firstValidation)) { |
46
|
|
|
return false; |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
if (this.validate() && firstValidation) { |
|
|
|
|
50
|
|
|
if (document.getElementById(this.getCode() + '_pseudocardpan').value != '') { |
51
|
|
|
// update payment method information if additional data was changed |
52
|
|
|
this.selectPaymentMethod(); |
53
|
|
|
handleRedirectAction(this.getData(), this.messageContainer); |
54
|
|
|
return false; |
55
|
|
|
} else { |
56
|
|
|
this.handleCreditcardCheck(); |
|
|
|
|
57
|
|
|
} |
58
|
|
|
} |
59
|
|
|
}, |
60
|
|
|
|
61
|
|
|
handleDebitPayment: function () { |
62
|
|
|
if (this.validate() && additionalValidators.validate()) { |
|
|
|
|
63
|
|
|
if (window.checkoutConfig.payment.payone.validateBankCode == true && window.checkoutConfig.payment.payone.bankCodeValidatedAndValid == false) { |
64
|
|
|
this.handleBankaccountCheck(); |
|
|
|
|
65
|
|
|
} else { |
66
|
|
|
// update payment method information if additional data was changed |
67
|
|
|
this.selectPaymentMethod(); |
68
|
|
|
handleDebitAction(this.getData(), this.messageContainer); |
69
|
|
|
return false; |
70
|
|
|
} |
71
|
|
|
} |
72
|
|
|
} |
73
|
|
|
}); |
74
|
|
|
} |
75
|
|
|
); |
76
|
|
|
|
This check looks for functions where a
return
statement is found in some execution paths, but not in all.Consider this little piece of code
The function
isBig
will only return a specific value when its parameter is bigger than 5000. In any other case, it will implicitly returnundefined
.This behaviour may not be what you had intended. In any case, you can add a
return undefined
to the other execution path to make the return value explicit.