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