1
|
|
|
define( |
2
|
|
|
[ |
3
|
|
|
'jquery', |
4
|
|
|
'Magento_Checkout/js/view/payment/default', |
5
|
|
|
'mage/url', |
6
|
|
|
'Magento_Customer/js/customer-data', |
7
|
|
|
'Magento_Checkout/js/model/error-processor', |
8
|
|
|
'Magento_Checkout/js/model/full-screen-loader', |
9
|
|
|
'Magento_Checkout/js/model/quote', |
10
|
|
|
'//cdn.pagantis.com/js/pg-v2/sdk.js', |
11
|
|
|
'//cdn.pagamastarde.com/js/pmt-v2/sdk.js', |
12
|
|
|
'Magento_Checkout/js/action/select-payment-method', |
13
|
|
|
'Magento_Checkout/js/checkout-data', |
14
|
|
|
'Magento_Checkout/js/model/totals', |
15
|
|
|
'Magento_Catalog/js/price-utils' |
16
|
|
|
], |
17
|
|
|
function ($, Component, url, customerData, errorProcessor, fullScreenLoader, quote, pgSDK, pmtSDK, selectPaymentMethodAction, checkoutData, totals, priceUtils) { |
|
|
|
|
18
|
|
|
'use strict'; |
19
|
|
|
|
20
|
|
|
window.checkoutConfig.payment.pagantis.guestEmail = quote.guestEmail; |
21
|
|
|
|
22
|
|
|
return Component.extend({ |
23
|
|
|
defaults: { |
24
|
|
|
template: 'Pagantis_Pagantis/payment/checkout-form' |
25
|
|
|
}, |
26
|
|
|
|
27
|
|
|
redirectAfterPlaceOrder: false, |
28
|
|
|
|
29
|
|
|
loadSimulator: function () { |
30
|
|
|
window.loadingSimulator = setTimeout(function () { |
31
|
|
|
if (window.checkoutConfig.payment.pagantis.enabled !='0' && |
|
|
|
|
32
|
|
|
window.checkoutConfig.payment.pagantis.publicKey!='' && |
33
|
|
|
window.checkoutConfig.payment.pagantis.secretKey!='') { |
34
|
|
|
var locale = window.checkoutConfig.payment.pagantis.locale; |
35
|
|
|
if (locale=='es'|| locale=='') { |
36
|
|
|
var sdk = pmtSDK; |
37
|
|
|
} else { |
38
|
|
|
var sdk = pgSDK; |
|
|
|
|
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
var simulator_options = { |
42
|
|
|
numInstalments : window.checkoutConfig.payment.pagantis.quotesStart, |
43
|
|
|
type : eval(window.checkoutConfig.payment.pagantis.type), |
|
|
|
|
44
|
|
|
skin : eval(window.checkoutConfig.payment.pagantis.skin), |
|
|
|
|
45
|
|
|
publicKey: window.checkoutConfig.payment.pagantis.publicKey, |
46
|
|
|
selector: window.checkoutConfig.payment.pagantis.position, |
47
|
|
|
totalAmount: window.checkoutConfig.payment.pagantis.total, |
48
|
|
|
locale: window.checkoutConfig.payment.pagantis.locale, |
49
|
|
|
country: window.checkoutConfig.payment.pagantis.country, |
50
|
|
|
totalPromotedAmount : window.checkoutConfig.payment.pagantis.promotedAmount |
51
|
|
|
}; |
52
|
|
|
|
53
|
|
|
if (typeof sdk !== 'undefined') { |
|
|
|
|
54
|
|
|
window.MGSimulatorId = sdk.simulator.init(simulator_options); |
55
|
|
|
return false; |
56
|
|
|
} |
57
|
|
|
} |
58
|
|
|
}, 3000); |
59
|
|
|
}, |
60
|
|
|
|
61
|
|
|
getTitle: function () { |
62
|
|
|
return window.checkoutConfig.payment.pagantis.title |
63
|
|
|
}, |
64
|
|
|
|
65
|
|
|
getSubtitle: function () { |
66
|
|
|
return window.checkoutConfig.payment.pagantis.subtitle |
67
|
|
|
}, |
68
|
|
|
|
69
|
|
|
getDisplayMode: function () { |
70
|
|
|
return window.checkoutConfig.payment.pagantis.displayMode |
71
|
|
|
}, |
72
|
|
|
|
73
|
|
|
getImage: function () { |
74
|
|
|
return window.checkoutConfig.payment.pagantis.image |
75
|
|
|
}, |
76
|
|
|
|
77
|
|
|
placeOrder: function () { |
78
|
|
|
var paymentUrl = url.build('pagantis/Payment'); |
79
|
|
|
$.post(paymentUrl, { email: window.checkoutConfig.payment.pagantis.guestEmail }, 'json') |
80
|
|
|
.done(function (response) { |
81
|
|
|
window.location.replace(response); |
82
|
|
|
}) |
83
|
|
|
.fail(function (response) { |
84
|
|
|
window.location.replace(response); |
85
|
|
|
}) |
86
|
|
|
}, |
87
|
|
|
}); |
88
|
|
|
} |
89
|
|
|
); |
90
|
|
|
|
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.