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 | window.checkoutConfig.payment.pagantis.product_simulator!='') { |
||
35 | var locale = window.checkoutConfig.payment.pagantis.locale; |
||
36 | if (locale=='es'|| locale=='') { |
||
37 | var sdk = pmtSDK; |
||
38 | } else { |
||
39 | var sdk = pgSDK; |
||
0 ignored issues
–
show
|
|||
40 | } |
||
41 | |||
42 | var simulator_options = { |
||
43 | numInstalments : window.checkoutConfig.payment.pagantis.quotesStart, |
||
44 | type : eval(window.checkoutConfig.payment.pagantis.type), |
||
45 | skin : eval(window.checkoutConfig.payment.pagantis.skin), |
||
46 | publicKey: window.checkoutConfig.payment.pagantis.publicKey, |
||
47 | selector: window.checkoutConfig.payment.pagantis.position, |
||
48 | totalAmount: window.checkoutConfig.payment.pagantis.total, |
||
49 | locale: window.checkoutConfig.payment.pagantis.locale, |
||
50 | country: window.checkoutConfig.payment.pagantis.country, |
||
51 | totalPromotedAmount : window.checkoutConfig.payment.pagantis.promotedAmount |
||
52 | }; |
||
53 | |||
54 | if (typeof sdk !== 'undefined') { |
||
55 | window.MGSimulatorId = sdk.simulator.init(simulator_options); |
||
56 | return false; |
||
57 | } |
||
58 | } |
||
59 | }, 3000); |
||
60 | }, |
||
61 | |||
62 | getTitle: function () { |
||
63 | return window.checkoutConfig.payment.pagantis.title |
||
64 | }, |
||
65 | |||
66 | getSubtitle: function () { |
||
67 | return window.checkoutConfig.payment.pagantis.subtitle |
||
68 | }, |
||
69 | |||
70 | getDisplayMode: function () { |
||
71 | return window.checkoutConfig.payment.pagantis.displayMode |
||
72 | }, |
||
73 | |||
74 | getImage: function () { |
||
75 | return window.checkoutConfig.payment.pagantis.image |
||
76 | }, |
||
77 | |||
78 | placeOrder: function () { |
||
79 | var paymentUrl = url.build('pagantis/Payment'); |
||
80 | $.post(paymentUrl, { email: window.checkoutConfig.payment.pagantis.guestEmail }, 'json') |
||
81 | .done(function (response) { |
||
82 | window.location.replace(response); |
||
83 | }) |
||
84 | .fail(function (response) { |
||
85 | window.location.replace(response); |
||
86 | }) |
||
87 | }, |
||
88 | }); |
||
89 | } |
||
90 | ); |
||
91 |
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.