![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/cartforge.co/pub/static/frontend/Magento/luma/en_US/Magento_Paypal/js/view/ |
/** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ define([ 'jquery', 'ko', 'uiElement', 'uiLayout', 'Magento_Paypal/js/in-context/paypal-sdk', 'domReady!' ], function ( $, ko, Component, layout, paypalSdk ) { 'use strict'; return Component.extend({ defaults: { template: 'Magento_Paypal/paylater', sdkUrl: '', attributes: { class: 'pay-later-message' }, dataAttributes: {}, refreshSelector: '', displayAmount: false, amountComponentConfig: { name: '${ $.name }.amountProvider', component: '' } }, paypal: null, amount: null, /** * Initialize * * @returns {*} */ initialize: function () { this._super() .observe(['amount']); if (this.displayAmount) { layout([this.amountComponentConfig]); } if (this.sdkUrl !== '') { this.loadPayPalSdk(this.sdkUrl, this.dataAttributes) .then(this._setPayPalObject.bind(this)); } if (this.refreshSelector) { $(this.refreshSelector).on('click', this._refreshMessages.bind(this)); } return this; }, /** * Get attribute value from configuration * * @param {String} attributeName * @returns {*|null} */ getAttribute: function (attributeName) { return typeof this.attributes[attributeName] !== 'undefined' ? this.attributes[attributeName] : null; }, /** * Load PP SDK with preconfigured options * * @param {String} sdkUrl - the url of the PayPal SDK * @param {Array} dataAttributes - Array of the Attributes for PayPal SDK Script tag */ loadPayPalSdk: function (sdkUrl, dataAttributes) { return paypalSdk(sdkUrl, dataAttributes); }, /** * Set reference to paypal Sdk object * * @param {Object} paypal * @private */ _setPayPalObject: function (paypal) { this.paypal = paypal; }, /** * Render messages * * @private */ _refreshMessages: function () { if (this.paypal) { this.paypal.Messages.render(); } } }); });