Completed
Push — master ( 1137b9...97c77e )
by
unknown
20s queued 11s
created

web/js/view/payment/method-renderer/paylater.js (2 issues)

Severity
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.pagamastarde.com/pmt-js-client-sdk/3/js/client-sdk.min.js',
11
        'Magento_Checkout/js/action/select-payment-method',
12
        'Magento_Checkout/js/checkout-data'
13
    ],
14
    function ($, Component, url, customerData, errorProcessor, fullScreenLoader, quote, pmtClient, selectPaymentMethodAction, checkoutData) {
15
        'use strict';
16
17
        window.checkoutConfig.payment.paylater.guestEmail = quote.guestEmail;
18
19
        window.pmtClient = pmtClient;
20
21
        require.config({
22
            paths: { "pmtSdk": "https://cdn.pagamastarde.com/pmt-js-client-sdk/3/js/client-sdk.min"},
23
            waitSeconds: 40
24
        });
25
26
        require( ["jquery","pmtSdk"],
27
            function ($, pmtClient) {
28
                $(document).ready(function() {
29
                    if (window.checkoutConfig.payment.paylater.pmtType != '0' &&
30
                        window.checkoutConfig.payment.paylater.publicKey!='') {
31
                        if (typeof pmtClient !== 'undefined') {
32
                            pmtClient.setPublicKey(window.checkoutConfig.payment.paylater.publicKey);
33
                            pmtClient.simulator.reload();
34
                        }
35
                    }
36
                })
37
            }
38
        );
39
40
        return Component.extend({
41
                defaults: {
42
                    template: 'DigitalOrigin_Pmt/payment/checkout-form'
43
                },
44
45
                redirectAfterPlaceOrder: false,
46
47
                /*loadSimulator: function ()
48
                {
49
                        if (window.checkoutConfig.payment.paylater.pmtType  !='0' &&
50
                            window.checkoutConfig.payment.paylater.publicKey!=''  &&
51
                            window.checkoutConfig.payment.paylater.secretKey!='')
52
                        {
53
                            if (typeof window.pmtClient !== 'undefined')
54
                            {
55
                                window.pmtClient.setPublicKey(window.checkoutConfig.payment.paylater.publicKey);
56
                                window.pmtClient.simulator.reload();
57
                                return true;
58
                            }
59
                        }
60
                },*/
61
62
                getPmtNumQuota: function () {
63
                    return window.checkoutConfig.payment.paylater.pmtNumQuota
64
                },
65
66
                dataPmtMaxIns: function () {
67
                    return window.checkoutConfig.payment.paylater.pmtMaxIns
68
                },
69
70
                getPmtType: function () {
71
                    return window.checkoutConfig.payment.paylater.pmtType
72
                },
73
74
                getPmtTotal: function () {
75
                    return window.checkoutConfig.payment.paylater.total
76
                },
77
78
                getPublicKey: function () {
79
                    return window.checkoutConfig.payment.paylater.publicKey
80
                },
81
82
                getSecretKey: function () {
83
                    return window.checkoutConfig.payment.paylater.secretKey
84
                },
85
86
                getDisplayMode: function () {
87
                    return window.checkoutConfig.payment.paylater.displayMode
88
                },
89
90
                selectPaymentMethod: function() {
91
                    selectPaymentMethodAction(this.getData());
92
                    checkoutData.setSelectedPaymentMethod(this.item.method);
93
                    return true;
94
                },
95
96
                placeOrder: function () {
97
                    var paymentUrl = url.build('paylater/Payment');
98
                    $.post(paymentUrl, { email: window.checkoutConfig.payment.paylater.guestEmail }, 'json')
99
                        .done(function (response) {
100
                            console.log(response);
0 ignored issues
show
console.log looks like debug code. Are you sure you do not want to remove it?
Loading history...
101
                            window.location.replace(response);
102
                        })
103
                        .fail(function (response) {
104
                            console.log(response);
0 ignored issues
show
console.log looks like debug code. Are you sure you do not want to remove it?
Loading history...
105
                            window.location.replace(response);
106
                        })
107
                },
108
            });
109
    }
110
);
111