diff --git a/modules/boonex/payment/classes/BxPaymentProviderStripeV3.php b/modules/boonex/payment/classes/BxPaymentProviderStripeV3.php index 8eb5d668d0..33c6dc0c87 100644 --- a/modules/boonex/payment/classes/BxPaymentProviderStripeV3.php +++ b/modules/boonex/payment/classes/BxPaymentProviderStripeV3.php @@ -391,8 +391,7 @@ protected function _getButtonJs($sType, $iClientId, $iVendorId, $aParams = array break; } - $sJsCode = $this->_oModule->_oTemplate->_wrapInTagJs('https://js.stripe.com/v3/'); - $sJsCode .= $this->_oModule->_oTemplate->getJsCode($this->_sName, array_merge(array( + return array($this->_oModule->_oTemplate->getJsCode($this->_sName, array_merge(array( 'js_object' => $sJsObject, 'sProvider' => $this->_sName, 'sPublicKey' => !empty($sPublicKey) ? $sPublicKey : $this->_getPublicKey(), @@ -400,9 +399,7 @@ protected function _getButtonJs($sType, $iClientId, $iVendorId, $aParams = array 'sVendorCurrency' => '', 'sVendorIcon' => '', 'sClientEmail' => $sClientEmail, - ), $aParams)); - - return array($sJsCode, $sJsMethod); + ), $aParams)), $sJsMethod); } } diff --git a/modules/boonex/payment/classes/BxPaymentTemplate.php b/modules/boonex/payment/classes/BxPaymentTemplate.php index b478d637a3..97b004b445 100644 --- a/modules/boonex/payment/classes/BxPaymentTemplate.php +++ b/modules/boonex/payment/classes/BxPaymentTemplate.php @@ -49,14 +49,14 @@ public function addJsCssCart($sType = '', $iVendorId = 0) $oModule = $this->getModule(); if(!empty($iVendorId)) { - $sMethod = 'getVendorInfoProviders' . bx_gen_method_name($sType); - $aProviders = $this->_oDb->$sMethod($iVendorId); - foreach($aProviders as $sProvider => $aProvider) - $oModule->getObjectProvider($sProvider, $iVendorId)->addJsCss(); + $sMethod = 'getVendorInfoProviders' . bx_gen_method_name($sType); + $aProviders = $this->_oDb->$sMethod($iVendorId); + foreach($aProviders as $sProvider => $aProvider) + $oModule->getObjectProvider($sProvider, $iVendorId)->addJsCss(); } } - public function displayCartJs($sType = '', $iVendorId = 0) + public function displayCartJs($sType = '', $iVendorId = 0) { $this->addJsCssCart($sType, $iVendorId); return $this->displayJsCode('cart'); diff --git a/modules/boonex/payment/js/stripe_v3.js b/modules/boonex/payment/js/stripe_v3.js index ad47485676..12bf228820 100644 --- a/modules/boonex/payment/js/stripe_v3.js +++ b/modules/boonex/payment/js/stripe_v3.js @@ -21,8 +21,6 @@ BxPaymentProviderStripeV3.prototype.init = function(oOptions) { this._sAnimationEffect = oOptions.sAnimationEffect == undefined ? 'fade' : oOptions.sAnimationEffect; this._iAnimationSpeed = oOptions.iAnimationSpeed == undefined ? 'slow' : oOptions.iAnimationSpeed; - this._rHandler = Stripe(oOptions.sPublicKey); - //--- For Single payment this._sObjNameGrid = oOptions.sObjNameGrid; @@ -34,6 +32,15 @@ BxPaymentProviderStripeV3.prototype.init = function(oOptions) { this._iItemCount = oOptions.iItemCount; this._sRedirect = oOptions.sRedirect; this._sCustom = oOptions.sCustom; + + var $this = this; + if(window.Stripe === undefined) { + $.getScript('https://js.stripe.com/v3/', function() { + $this._rHandler = Stripe(oOptions.sPublicKey); + }); + } + else + this._rHandler = Stripe(oOptions.sPublicKey); }; BxPaymentProviderStripeV3.prototype.onCartCheckout = function(oData) {