Quellcode durchsuchen

Merge branch 'master' of https://github.com/unaio/una

RomanL vor 6 Jahren
Ursprung
Commit
70dc620d4e

+ 65 - 53
inc/classes/BxDolPayments.php

@@ -66,7 +66,7 @@ class BxDolPayments extends BxDolFactory implements iBxDolSingleton
     	if(!BxDolRequest::serviceExists($this->_sActive, 'get_details_url', 'Details'))
             return '';
 
-    	return BxDolService::call($this->_sActive, 'get_details_url', array(), 'Details');
+    	return bx_srv($this->_sActive, 'get_details_url', array(), 'Details');
     }
 
     public function isAcceptingPayments($iVendorId, $sPaymentType = '')
@@ -75,7 +75,7 @@ class BxDolPayments extends BxDolFactory implements iBxDolSingleton
     		return false;
 
     	$aSrvParams = array($iVendorId, $sPaymentType);
-        return BxDolService::call($this->_sActive, 'is_accepting_payments', $aSrvParams);
+        return bx_srv($this->_sActive, 'is_accepting_payments', $aSrvParams);
     }
 
     /**
@@ -104,7 +104,7 @@ class BxDolPayments extends BxDolFactory implements iBxDolSingleton
             return false;
 
         $aSrvParams = array($iVendorId, $sVendorProvider, $sPaymentType);
-        return BxDolService::call($this->_sActive, 'is_provider_options', $aSrvParams);
+        return bx_srv($this->_sActive, 'is_provider_options', $aSrvParams);
     }
 
     public function getProvider($sProvider, $mixedVendorId = BX_PAYMENT_EMPTY_ID)
@@ -113,7 +113,7 @@ class BxDolPayments extends BxDolFactory implements iBxDolSingleton
             return false;
 
         $aSrvParams = array($sProvider, $mixedVendorId);
-        return BxDolService::call($this->_sActive, 'get_provider', $aSrvParams);
+        return bx_srv($this->_sActive, 'get_provider', $aSrvParams);
     }
 
     public function getProviderOptions($iVendorId, $sVendorProvider, $sPaymentType = '')
@@ -122,7 +122,7 @@ class BxDolPayments extends BxDolFactory implements iBxDolSingleton
             return false;
 
         $aSrvParams = array($iVendorId, $sVendorProvider, $sPaymentType);
-        return BxDolService::call($this->_sActive, 'get_provider_options', $aSrvParams);
+        return bx_srv($this->_sActive, 'get_provider_options', $aSrvParams);
     }
 
     public function getPayments()
@@ -143,9 +143,9 @@ class BxDolPayments extends BxDolFactory implements iBxDolSingleton
     public function updateDependentModules($sModule = 'all', $bInstall = true)
     {
     	if(!BxDolRequest::serviceExists($this->_sActive, 'update_dependent_modules'))
-    		return;
+            return;
 
-		BxDolService::call($this->_sActive, 'update_dependent_modules', array($sModule, $bInstall));
+        bx_srv($this->_sActive, 'update_dependent_modules', array($sModule, $bInstall));
     }
 
     public function getProvidersCart($iVendorId)
@@ -154,15 +154,15 @@ class BxDolPayments extends BxDolFactory implements iBxDolSingleton
     		return array();
 
     	$aSrvParams = array($iVendorId);
-        return BxDolService::call($this->_sActive, 'get_providers_cart', $aSrvParams);
+        return bx_srv($this->_sActive, 'get_providers_cart', $aSrvParams);
     }
 
-	public function getOption($sOption)
+    public function getOption($sOption)
     {
     	if(!BxDolRequest::serviceExists($this->_sActive, 'get_option'))
-    		return '';
+            return '';
 
-    	return BxDolService::call($this->_sActive, 'get_option', array($sOption));
+    	return bx_srv($this->_sActive, 'get_option', array($sOption));
     }
 
     public function getOrdersUrl()
@@ -170,7 +170,7 @@ class BxDolPayments extends BxDolFactory implements iBxDolSingleton
     	if(!BxDolRequest::serviceExists($this->_sActive, 'get_orders_url', 'Orders'))
             return '';
 
-    	return BxDolService::call($this->_sActive, 'get_orders_url', array(), 'Orders');
+    	return bx_srv($this->_sActive, 'get_orders_url', array(), 'Orders');
     }
 
     public function getOrdersCount($sType)
@@ -179,7 +179,7 @@ class BxDolPayments extends BxDolFactory implements iBxDolSingleton
             return array();
 
         $aSrvParams = array($sType);
-        return BxDolService::call($this->_sActive, 'get_orders_count', $aSrvParams, 'Orders');
+        return bx_srv($this->_sActive, 'get_orders_count', $aSrvParams, 'Orders');
     }
 
     public function getOrdersInfo($aConditions)
@@ -188,7 +188,7 @@ class BxDolPayments extends BxDolFactory implements iBxDolSingleton
             return array();
 
         $aSrvParams = array($aConditions);
-        return BxDolService::call($this->_sActive, 'get_orders_info', $aSrvParams, 'Orders');
+        return bx_srv($this->_sActive, 'get_orders_info', $aSrvParams, 'Orders');
     }
 
     public function getPendingOrdersInfo($aConditions)
@@ -197,7 +197,7 @@ class BxDolPayments extends BxDolFactory implements iBxDolSingleton
             return array();
 
         $aSrvParams = array($aConditions);
-        return BxDolService::call($this->_sActive, 'get_pending_orders_info', $aSrvParams, 'Orders');
+        return bx_srv($this->_sActive, 'get_pending_orders_info', $aSrvParams, 'Orders');
     }
 
     public function getSubscriptionOrdersInfo($aConditions)
@@ -206,7 +206,7 @@ class BxDolPayments extends BxDolFactory implements iBxDolSingleton
             return array();
 
         $aSrvParams = array($aConditions);
-        return BxDolService::call($this->_sActive, 'get_subscription_orders_info', $aSrvParams, 'Subscriptions');
+        return bx_srv($this->_sActive, 'get_subscription_orders_info', $aSrvParams, 'Subscriptions');
     }
 
     public function getSubscriptionsInfo($aConditions, $bCheckInProvider = false)
@@ -215,7 +215,7 @@ class BxDolPayments extends BxDolFactory implements iBxDolSingleton
             return array();
 
         $aSrvParams = array($aConditions, $bCheckInProvider);
-        return BxDolService::call($this->_sActive, 'get_subscriptions_info', $aSrvParams, 'Subscriptions');
+        return bx_srv($this->_sActive, 'get_subscriptions_info', $aSrvParams, 'Subscriptions');
     }
 
     public function getCartUrl($iVendor = 0)
@@ -223,34 +223,34 @@ class BxDolPayments extends BxDolFactory implements iBxDolSingleton
     	if(!BxDolRequest::serviceExists($this->_sActive, 'get_cart_url', 'Cart'))
     		return '';
 
-    	return BxDolService::call($this->_sActive, 'get_cart_url', array($iVendor), 'Cart');
+    	return bx_srv($this->_sActive, 'get_cart_url', array($iVendor), 'Cart');
     }
 
     public function getCartItemsCount()
     {
     	if(!BxDolRequest::serviceExists($this->_sActive, 'get_cart_items_count', 'Cart'))
-    		return 0;
+            return 0;
 
-		$aSrvParams = array();
-		return BxDolService::call($this->_sActive, 'get_cart_items_count', $aSrvParams, 'Cart');
+        $aSrvParams = array();
+        return bx_srv($this->_sActive, 'get_cart_items_count', $aSrvParams, 'Cart');
     }
     
     public function getCartItems($iVendorId, $iModuleId)
     {
     	if(!BxDolRequest::serviceExists($this->_sActive, 'get_cart_items', 'Cart'))
-    		return 0;
+            return 0;
 
-		$aSrvParams = array($iVendorId, $iModuleId);
-		return BxDolService::call($this->_sActive, 'get_cart_items', $aSrvParams, 'Cart');
+        $aSrvParams = array($iVendorId, $iModuleId);
+        return bx_srv($this->_sActive, 'get_cart_items', $aSrvParams, 'Cart');
     }
 
     public function getCartItemDescriptor($iVendorId, $iModuleId, $iItemId, $iItemCount)
     {
     	if(!BxDolRequest::serviceExists($this->_sActive, 'get_cart_item_descriptor', 'Cart'))
-    		return '';
+            return '';
 
     	$aSrvParams = array($iVendorId, $iModuleId, $iItemId, $iItemCount);
-		return BxDolService::call($this->_sActive, 'get_cart_item_descriptor', $aSrvParams, 'Cart');
+        return bx_srv($this->_sActive, 'get_cart_item_descriptor', $aSrvParams, 'Cart');
     }
 
     /**
@@ -259,10 +259,10 @@ class BxDolPayments extends BxDolFactory implements iBxDolSingleton
     public function getCartJs($sType = '', $iVendorId = 0)
     {
     	if(!BxDolRequest::serviceExists($this->_sActive, 'get_cart_js', 'Cart'))
-			return '';
+            return '';
 
-		$aSrvParams = array($sType, $iVendorId);
-		return BxDolService::call($this->_sActive, 'get_cart_js', $aSrvParams, 'Cart');
+        $aSrvParams = array($sType, $iVendorId);
+        return bx_srv($this->_sActive, 'get_cart_js', $aSrvParams, 'Cart');
     }
 
     /**
@@ -271,10 +271,10 @@ class BxDolPayments extends BxDolFactory implements iBxDolSingleton
 	public function addToCart($iVendorId, $mixedModuleId, $iItemId, $iItemCount, $aCustom = array())
     {
     	if(!BxDolRequest::serviceExists($this->_sActive, 'add_to_cart', 'Cart'))
-			return array();
+            return array();
 
-		$aSrvParams = array($iVendorId, $mixedModuleId, $iItemId, $iItemCount, $aCustom);
-		return BxDolService::call($this->_sActive, 'add_to_cart', $aSrvParams, 'Cart');
+        $aSrvParams = array($iVendorId, $mixedModuleId, $iItemId, $iItemCount, $aCustom);
+        return bx_srv($this->_sActive, 'add_to_cart', $aSrvParams, 'Cart');
     }
 
     /**
@@ -283,10 +283,10 @@ class BxDolPayments extends BxDolFactory implements iBxDolSingleton
     public function getAddToCartJs($iVendorId, $mixedModuleId, $iItemId, $iItemCount, $bNeedRedirect = false, $aCustom = array())
     {
     	if(!BxDolRequest::serviceExists($this->_sActive, 'get_add_to_cart_js', 'Cart'))
-			return array();
+            return array();
 
-		$aSrvParams = array($iVendorId, $mixedModuleId, $iItemId, $iItemCount, $bNeedRedirect, $aCustom);
-		return BxDolService::call($this->_sActive, 'get_add_to_cart_js', $aSrvParams, 'Cart');
+        $aSrvParams = array($iVendorId, $mixedModuleId, $iItemId, $iItemCount, $bNeedRedirect, $aCustom);
+        return bx_srv($this->_sActive, 'get_add_to_cart_js', $aSrvParams, 'Cart');
     }
 
     /**
@@ -294,39 +294,51 @@ class BxDolPayments extends BxDolFactory implements iBxDolSingleton
      */
     public function getAddToCartLink($iVendorId, $mixedModuleId, $iItemId, $iItemCount, $bNeedRedirect = false, $aCustom = array())
     {
-		if(!BxDolRequest::serviceExists($this->_sActive, 'get_add_to_cart_link', 'Cart'))
-			return '';
+        if(!BxDolRequest::serviceExists($this->_sActive, 'get_add_to_cart_link', 'Cart'))
+            return '';
 
-		$aSrvParams = array($iVendorId, $mixedModuleId, $iItemId, $iItemCount, $bNeedRedirect, $aCustom);
-		return BxDolService::call($this->_sActive, 'get_add_to_cart_link', $aSrvParams, 'Cart');
+        $aSrvParams = array($iVendorId, $mixedModuleId, $iItemId, $iItemCount, $bNeedRedirect, $aCustom);
+        return bx_srv($this->_sActive, 'get_add_to_cart_link', $aSrvParams, 'Cart');
     }
 
     public function getSubscriptionsUrl()
     {
     	if(!BxDolRequest::serviceExists($this->_sActive, 'get_subscriptions_url', 'Subscriptions'))
-    		return '';
+            return '';
 
-    	return BxDolService::call($this->_sActive, 'get_subscriptions_url', array(), 'Subscriptions');
+    	return bx_srv($this->_sActive, 'get_subscriptions_url', array(), 'Subscriptions');
     }
 
-	public function getSubscribeUrl($iVendorId, $sVendorProvider, $mixedModuleId, $iItemId, $iItemCount = 1)
+    public function getSubscribeUrl($iVendorId, $sVendorProvider, $mixedModuleId, $iItemId, $iItemCount = 1)
     {
     	if(!BxDolRequest::serviceExists($this->_sActive, 'get_subscribe_url', 'Subscriptions'))
-    		return '';
+            return '';
 
-    	return BxDolService::call($this->_sActive, 'get_subscribe_url', array($iVendorId, $sVendorProvider, $mixedModuleId, $iItemId, $iItemCount), 'Subscriptions');
+    	return bx_srv($this->_sActive, 'get_subscribe_url', array($iVendorId, $sVendorProvider, $mixedModuleId, $iItemId, $iItemCount), 'Subscriptions');
     }
 
-	/**
+    /**
      * Returns "Subscribe" JavaScript code to use in onclick attribute.
      */
     public function getSubscribeJs($iVendorId, $sVendorProvider, $mixedModuleId, $iItemId, $iItemCount = 1, $sRedirect = '', $aCustom = array())
     {
     	if(!BxDolRequest::serviceExists($this->_sActive, 'get_subscribe_js', 'Subscriptions'))
-			return array();
+            return array();
+
+        $aSrvParams = array($iVendorId, $sVendorProvider, $mixedModuleId, $iItemId, $iItemCount, $sRedirect, $aCustom);
+        return bx_srv($this->_sActive, 'get_subscribe_js', $aSrvParams, 'Subscriptions');
+    }
+
+    /**
+     * Returns "Subscribe" JavaScript code to use in onclick attribute.
+     */
+    public function getSubscribeJsWithAddons($iVendorId, $sVendorProvider, $mixedModuleId, $iItemId, $iItemCount = 1, $sItemAddons = '', $sRedirect = '', $aCustom = array())
+    {
+    	if(!BxDolRequest::serviceExists($this->_sActive, 'get_subscribe_js_with_addons', 'Subscriptions'))
+            return array();
 
-		$aSrvParams = array($iVendorId, $sVendorProvider, $mixedModuleId, $iItemId, $iItemCount, $sRedirect, $aCustom);
-		return BxDolService::call($this->_sActive, 'get_subscribe_js', $aSrvParams, 'Subscriptions');
+        $aSrvParams = array($iVendorId, $sVendorProvider, $mixedModuleId, $iItemId, $iItemCount, $sItemAddons, $sRedirect, $aCustom);
+        return bx_srv($this->_sActive, 'get_subscribe_js_with_addons', $aSrvParams, 'Subscriptions');
     }
 
     /**
@@ -338,7 +350,7 @@ class BxDolPayments extends BxDolFactory implements iBxDolSingleton
             return '';
 
         $aSrvParams = array($iVendorId, $sVendorProvider, $mixedModuleId, $iItemId, $iItemCount, $sRedirect, $aCustom);
-        return BxDolService::call($this->_sActive, 'get_subscribe_link', $aSrvParams, 'Subscriptions');
+        return bx_srv($this->_sActive, 'get_subscribe_link', $aSrvParams, 'Subscriptions');
     }
 
     public function sendSubscriptionExpirationLetters($iPendingId, $sOrderId)
@@ -347,7 +359,7 @@ class BxDolPayments extends BxDolFactory implements iBxDolSingleton
             return '';
 
         $aSrvParams = array($iPendingId, $sOrderId);
-        return BxDolService::call($this->_sActive, 'send_subscription_expiration_letters', $aSrvParams, 'Subscriptions');
+        return bx_srv($this->_sActive, 'send_subscription_expiration_letters', $aSrvParams, 'Subscriptions');
     }
 
     public function initializeCheckout($iVendorId, $sProvider, $aItems = array())
@@ -356,7 +368,7 @@ class BxDolPayments extends BxDolFactory implements iBxDolSingleton
             return '';
 
         $aSrvParams = array($iVendorId, $sProvider, $aItems);
-        return BxDolService::call($this->_sActive, 'initialize_checkout', $aSrvParams);
+        return bx_srv($this->_sActive, 'initialize_checkout', $aSrvParams);
     }
 
     /**
@@ -368,7 +380,7 @@ class BxDolPayments extends BxDolFactory implements iBxDolSingleton
             return '';
 
         $aSrvParams = array($sOrderId);
-        return BxDolService::call($this->_sActive, 'prolong_subscription', $aSrvParams);
+        return bx_srv($this->_sActive, 'prolong_subscription', $aSrvParams);
     }
 
     public function generateLicense()
@@ -377,7 +389,7 @@ class BxDolPayments extends BxDolFactory implements iBxDolSingleton
             return '';
 
         $aSrvParams = array();
-        return BxDolService::call($this->_sActive, 'generate_license', $aSrvParams, 'Module', true);
+        return bx_srv($this->_sActive, 'generate_license', $aSrvParams, 'Module', true);
     }
 }
 

+ 34 - 1
modules/base/payment/classes/BxBaseModPaymentSubscriptions.php

@@ -111,12 +111,45 @@ class BxBaseModPaymentSubscriptions extends BxDol
      */
     public function serviceGetSubscribeJs($iVendorId, $sVendorProvider, $mixedModuleId, $iItemId, $iItemCount = 1, $sRedirect = '', $aCustom = array())
     {
-		$iModuleId = $this->_oModule->_oConfig->getModuleId($mixedModuleId);
+        $iModuleId = $this->_oModule->_oConfig->getModuleId($mixedModuleId);
         if(empty($iModuleId))
             return '';
 
         return $this->_oModule->_oTemplate->displaySubscribeJs($iVendorId, $sVendorProvider, $iModuleId, $iItemId, $iItemCount, $sRedirect, $aCustom);
     }
+    
+    /**
+     * @page service Service Calls
+     * @section bx_base_payment Base Payment
+     * @subsection bx_base_payment-integration Integration
+     * @subsubsection bx_base_payment-get_subscribe_js get_subscribe_js
+     * 
+     * @code bx_srv('bx_payment', 'get_subscribe_js', [...], 'Subscriptions'); @endcode
+     * 
+     * Get JavaScript code to use in OnClick attributes of HTML elements.
+     *
+     * @param $iVendor integer value with vendor ID.
+     * @param $sVendorProvider string value with a name of payment provider to be used for processing.
+     * @param $mixedModuleId mixed value (ID, Name or URI) determining a module from which the action was initiated.
+     * @param $iItemId integer value with item ID.
+     * @param $iItemCount (optional) integer value with a number of items for purchasing. It's equal to 1 in case of subscription.
+     * @param $sItemAddons (optional) string with attached addons.
+     * @param $sRedirect (optional) string value with redirect URL, if it's needed.
+     * @return string with JavaScript code.
+     * 
+     * @see BxBaseModPaymentSubscriptions::serviceGetSubscribeJs
+     */
+    /** 
+     * @ref bx_base_payment-get_subscribe_js "get_subscribe_js"
+     */
+    public function serviceGetSubscribeJsWithAddons($iVendorId, $sVendorProvider, $mixedModuleId, $iItemId, $iItemCount = 1, $sItemAddons = '', $sRedirect = '', $aCustom = array())
+    {
+        $iModuleId = $this->_oModule->_oConfig->getModuleId($mixedModuleId);
+        if(empty($iModuleId))
+            return '';
+
+        return $this->_oModule->_oTemplate->displaySubscribeJsWithAddons($iVendorId, $sVendorProvider, $iModuleId, $iItemId, $iItemCount, $sItemAddons, $sRedirect, $aCustom);
+    }
 
     /**
      * @page service Service Calls

+ 43 - 19
modules/boonex/acl/classes/BxAclGridView.php

@@ -13,15 +13,23 @@ require_once('BxAclGridLevels.php');
 
 class BxAclGridView extends BxAclGridLevels
 {
-	protected $_iOwner;
-	protected $_oPayment;
-	protected $_bTypeSingle;
-	protected $_bTypeRecurring;
+    /**
+     * Array with check_sum => JS_code pairs of all JS codes 
+     * which should be added to the page.
+     */
+    protected $_aJsCodes;
+
+    protected $_iOwner;
+    protected $_oPayment;
+    protected $_bTypeSingle;
+    protected $_bTypeRecurring;
 
     public function __construct ($aOptions, $oTemplate = false)
     {
         parent::__construct ($aOptions, $oTemplate);
 
+        $this->_aJsCodes = array();
+
         $this->_iOwner = $this->_oModule->_oConfig->getOwner();
         $this->_oPayment = BxDolPayments::getInstance();
         $this->_bTypeSingle = $this->_oPayment->isAcceptingPayments($this->_iOwner, BX_PAYMENT_TYPE_SINGLE);
@@ -52,7 +60,15 @@ class BxAclGridView extends BxAclGridLevels
 
     public function getCode($isDisplayHeader = true)
     {
-    	return $this->_oPayment->getCartJs() . parent::getCode($isDisplayHeader);
+    	return parent::getCode($isDisplayHeader) . $this->getJsCode();
+    }
+
+    public function getJsCode()
+    {
+        if(empty($this->_aJsCodes) || !is_array($this->_aJsCodes))
+            return '';
+
+        return implode('', $this->_aJsCodes);
     }
 
     protected function _getCellLevelIcon($mixedValue, $sKey, $aField, $aRow)
@@ -69,19 +85,23 @@ class BxAclGridView extends BxAclGridLevels
         return  parent::_getActionDefault($sType, $sKey, $a, false, $isDisabled, $aRow);
     }
 
-	protected function _getActionBuy ($sType, $sKey, $a, $isSmall = false, $isDisabled = false, $aRow = array())
+    protected function _getActionBuy ($sType, $sKey, $a, $isSmall = false, $isDisabled = false, $aRow = array())
     {
         if((float)$aRow['price'] == 0 || !$this->_bTypeSingle || $this->_bTypeRecurring)
             return '';
 
     	$aJs = $this->_oPayment->getAddToCartJs($this->_iOwner, $this->MODULE, $aRow['id'], 1, true);
     	if(!empty($aJs) && is_array($aJs)) {
-    		list($sJsCode, $sJsMethod) = $aJs;
+            list($sJsCode, $sJsMethod) = $aJs;
 
-    		$a['attr'] = array(
-    		    'title' => bx_html_attribute(_t('_bx_acl_grid_action_buy_title')),
-    			'onclick' => $sJsMethod
-    		);
+            $sJsCodeCheckSum = md5($sJsCode);
+            if(!isset($this->_aJsCodes[$sJsCodeCheckSum]))
+                $this->_aJsCodes[$sJsCodeCheckSum] = $sJsCode;
+
+            $a['attr'] = array(
+                'title' => bx_html_attribute(_t('_bx_acl_grid_action_buy_title')),
+                'onclick' => $sJsMethod
+            );
     	}
 
         return  parent::_getActionDefault($sType, $sKey, $a, false, $isDisabled, $aRow);
@@ -93,16 +113,20 @@ class BxAclGridView extends BxAclGridLevels
             return '';
 
     	$aJs = $this->_oPayment->getSubscribeJs($this->_iOwner, '', $this->MODULE, $aRow['id'], 1);
-		if(!empty($aJs) && is_array($aJs)) {
-			list($sJsCode, $sJsMethod) = $aJs;
+        if(!empty($aJs) && is_array($aJs)) {
+            list($sJsCode, $sJsMethod) = $aJs;
+
+            $sJsCodeCheckSum = md5($sJsCode);
+            if(!isset($this->_aJsCodes[$sJsCodeCheckSum]))
+                $this->_aJsCodes[$sJsCodeCheckSum] = $sJsCode;
 
-    		$a['attr'] = array(
-    			'title' => bx_html_attribute(_t('_bx_acl_grid_action_subscribe_title')),
-    			'onclick' => $sJsMethod
-    		);
-		}
+            $a['attr'] = array(
+                'title' => bx_html_attribute(_t('_bx_acl_grid_action_subscribe_title')),
+                'onclick' => $sJsMethod
+            );
+        }
 
-    	return  parent::_getActionDefault($sType, $sKey, $a, false, $isDisabled, $aRow);
+    	return parent::_getActionDefault($sType, $sKey, $a, false, $isDisabled, $aRow);
     }
 }
 

+ 28 - 1
modules/boonex/market/classes/BxMarketMenuView.php

@@ -14,11 +14,20 @@
  */
 class BxMarketMenuView extends BxBaseModTextMenuView
 {
+    /**
+     * Array with check_sum => JS_code pairs of all JS codes 
+     * which should be added to the page.
+     */
+    protected $_aJsCodes;
+
     public function __construct($aObject, $oTemplate = false)
     {
         $this->MODULE = 'bx_market';
+
         parent::__construct($aObject, $oTemplate);
 
+        $this->_aJsCodes = array();
+
         $this->addMarkers(array(
             'js_object' => $this->_oModule->_oConfig->getJsObject('entry')
         ));
@@ -26,7 +35,15 @@ class BxMarketMenuView extends BxBaseModTextMenuView
 
     public function getCode ()
     {
-    	return parent::getCode() . BxDolPayments::getInstance()->getCartJs();
+    	return parent::getCode() . $this->getJsCode();
+    }
+
+    public function getJsCode()
+    {
+        if(empty($this->_aJsCodes) || !is_array($this->_aJsCodes))
+            return '';
+
+        return implode('', $this->_aJsCodes);
     }
 
     protected function _isVisible ($a)
@@ -59,6 +76,11 @@ class BxMarketMenuView extends BxBaseModTextMenuView
                     break;
 
                 list($sJsCode, $sJsMethod) = $aJs;
+
+                $sJsCodeCheckSum = md5($sJsCode);
+                if(!isset($this->_aJsCodes[$sJsCodeCheckSum]))
+                    $this->_aJsCodes[$sJsCodeCheckSum] = $sJsCode;
+
                 $aCurrency = $this->_oModule->_oConfig->getCurrency();
 
                 $bResult = true;
@@ -87,6 +109,11 @@ class BxMarketMenuView extends BxBaseModTextMenuView
                     break;
 
                 list($sJsCode, $sJsMethod) = $aJs;
+
+                $sJsCodeCheckSum = md5($sJsCode);
+                if(!isset($this->_aJsCodes[$sJsCodeCheckSum]))
+                    $this->_aJsCodes[$sJsCodeCheckSum] = $sJsCode;
+
                 $aCurrency = $this->_oModule->_oConfig->getCurrency();
 
                 $bResult = true;

+ 10 - 0
modules/boonex/market/classes/BxMarketMenuViewActions.php

@@ -21,6 +21,16 @@ class BxMarketMenuViewActions extends BxBaseModTextMenuViewActions
         parent::__construct($aObject, $oTemplate);
     }
 
+    public function getCode ()
+    {
+        $sCode = parent::getCode();
+
+        if(!empty($this->_oMenuActions))
+            $sCode .= $this->_oMenuActions->getJsCode();
+
+    	return $sCode;
+    }
+    
     protected function _getMenuItemDownload($aItem)
     {
         return $this->_getMenuItemByNameActions($aItem);

+ 18 - 8
modules/boonex/payment/classes/BxPaymentGridSbsAdministration.php

@@ -28,17 +28,17 @@ class BxPaymentGridSbsAdministration extends BxBaseModPaymentGridOrders
     {
     	$aIds = bx_get('ids');
         if(!$aIds || !is_array($aIds)) 
-        	return echoJson(array());
+            return echoJson(array());
 
-		$oSubscriptions = $this->_oModule->getObjectSubscriptions();
+        $oSubscriptions = $this->_oModule->getObjectSubscriptions();
 
-		$iAffected = 0;
-		$aAffected = array();
-		foreach($aIds as $iId)
-			if($oSubscriptions->cancel($iId)) {
-				$aAffected[] = $iId;
+        $iAffected = 0;
+        $aAffected = array();
+        foreach($aIds as $iId)
+            if($oSubscriptions->cancel($iId)) {
+                $aAffected[] = $iId;
             	$iAffected++;
-			}
+            }
 
         echoJson($iAffected ? array('grid' => $this->getCode(false), 'blink' => $aAffected) : array('msg' => _t($this->_sLangsPrefix . 'err_cannot_perform')));
     }
@@ -73,6 +73,7 @@ class BxPaymentGridSbsAdministration extends BxBaseModPaymentGridOrders
         $aStates = array(0 => 'no', 1 => 'yes');
         return parent::_getCellDefault(_t('_bx_payment_txt_' . $aStates[(int)$mixedValue]), $sKey, $aField, $aRow);
     }
+
     protected function _addJsCss()
     {
         parent::_addJsCss();
@@ -83,6 +84,15 @@ class BxPaymentGridSbsAdministration extends BxBaseModPaymentGridOrders
             '_bx_payment_txt_unsubscribe_no'
         ));
     }
+
+    protected function _delete ($mixedId)
+    {
+        $aSubscription = $this->_oModule->_oDb->getSubscription(array('type' => 'pending_id', 'pending_id' => $mixedId));
+        if(empty($aSubscription) || !is_array($aSubscription))
+            return false;
+
+        return $this->_oModule->_oDb->deleteSubscription($aSubscription['id'], 'delete');
+    }
 }
 
 /** @} */

+ 134 - 97
modules/boonex/payment/classes/BxPaymentModule.php

@@ -398,8 +398,7 @@ class BxPaymentModule extends BxBaseModPaymentModule
      */
     public function actionDeleteFromCart($iSellerId, $iModuleId, $iItemId)
     {
-        $aResult = $this->getObjectCart()->serviceDeleteFromCart($iSellerId, $iModuleId, $iItemId);
-        echoJson($aResult);
+        echoJson($this->getObjectCart()->serviceDeleteFromCart($iSellerId, $iModuleId, $iItemId));
     }
 
     /**
@@ -407,11 +406,10 @@ class BxPaymentModule extends BxBaseModPaymentModule
      */
     public function actionEmptyCart($iSellerId)
     {
-        $aResult = $this->getObjectCart()->serviceDeleteFromCart($iSellerId);
-		echoJson($aResult);
+        echoJson($this->getObjectCart()->serviceDeleteFromCart($iSellerId));
     }
 
-	public function actionSubscribe()
+    public function actionSubscribe()
     {
     	$iSellerId = bx_process_input(bx_get('seller_id'), BX_DATA_INT);
     	$sSellerProvider = bx_process_input(bx_get('seller_provider'));
@@ -482,32 +480,27 @@ class BxPaymentModule extends BxBaseModPaymentModule
                 $aCustom = array();
         }
 
-        $aResult = $this->getObjectSubscriptions()->serviceSubscribeWithAddons($iSellerId, $sSellerProvider, $iModuleId, $iItemId, $iItemCount, $sItemAddons, $sRedirect, $aCustom);
-        echoJson($aResult);
+        echoJson($this->getObjectSubscriptions()->serviceSubscribeWithAddons($iSellerId, $sSellerProvider, $iModuleId, $iItemId, $iItemCount, $sItemAddons, $sRedirect, $aCustom));
     }
 
     public function actionSubscriptionGetDetails($iId)
     {
-        $aResult = $this->_oTemplate->displaySubscriptionGetDetails($iId);
-		echoJson($aResult);
+        echoJson($this->_oTemplate->displaySubscriptionGetDetails($iId));
     }
 
     public function actionSubscriptionChangeDetails($iId)
     {
-        $aResult = $this->_oTemplate->displaySubscriptionChangeDetails($iId);
-		echoJson($aResult);
+        echoJson($this->_oTemplate->displaySubscriptionChangeDetails($iId));
     }
 
     public function actionSubscriptionGetBilling($iId)
     {
-        $aResult = $this->_oTemplate->displaySubscriptionGetBilling($iId);
-		echoJson($aResult);
+        echoJson($this->_oTemplate->displaySubscriptionGetBilling($iId));
     }
 
     public function actionSubscriptionChangeBilling($iId)
     {
-        $aResult = $this->_oTemplate->displaySubscriptionChangeBilling($iId);
-		echoJson($aResult);
+        echoJson($this->_oTemplate->displaySubscriptionChangeBilling($iId));
     }
 
     public function actionSubscriptionCancelation($iId)
@@ -581,7 +574,7 @@ class BxPaymentModule extends BxBaseModPaymentModule
     /**
      * Payment Processing Methods
      */
-	public function actionInitializeCheckout($sType)
+    public function actionInitializeCheckout($sType)
     {
     	if(!$this->isLogged())
             return $this->_oTemplate->displayPageCodeError($this->_sLangsPrefix . 'err_required_login');
@@ -1002,106 +995,106 @@ class BxPaymentModule extends BxBaseModPaymentModule
         return $bResult;
     }
 
-	public function registerSubscription($aPending, $aParams = array())
-	{
-		if($this->_oDb->isSubscriptionByPending($aPending['id']))
-			return false;
+    public function registerSubscription($aPending, $aParams = array())
+    {
+            if($this->_oDb->isSubscriptionByPending($aPending['id']))
+                    return false;
 
-		$aSubscription = array(
-	        'pending_id' => $aPending['id'],
-	        'customer_id' => $aParams['customer_id'],
-	        'subscription_id' => $aParams['subscription_id']
-	    );
-	    if(!$this->_oDb->insertSubscription($aSubscription))
-	    	return false;
+            $aSubscription = array(
+            'pending_id' => $aPending['id'],
+            'customer_id' => $aParams['customer_id'],
+            'subscription_id' => $aParams['subscription_id']
+        );
+        if(!$this->_oDb->insertSubscription($aSubscription))
+            return false;
 
-	    $this->onSubscriptionCreate($aPending);
+        $this->onSubscriptionCreate($aPending);
 
-	    return true;
-	}
+        return true;
+    }
 
-	public function updateSubscription($aPending, $aParams = array())
-	{
-	    $this->_oDb->updateSubscription($aParams, array(
-	        'pending_id' => $aPending['id']
-	    ));
+    public function updateSubscription($aPending, $aParams = array())
+    {
+        $this->_oDb->updateSubscription($aParams, array(
+            'pending_id' => $aPending['id']
+        ));
 
-	    $this->onSubscriptionUpdate($aPending);
+        $this->onSubscriptionUpdate($aPending);
 
-            return true;
-	}
+        return true;
+    }
 
-	public function cancelSubscription($mixedPending)
-	{
-            $aPending = is_array($mixedPending) ? $mixedPending : $this->_oDb->getOrderPending(array('type' => 'id', 'id' => (int)$mixedPending));
-            if(empty($aPending) || !is_array($aPending) || $aPending['type'] != BX_PAYMENT_TYPE_RECURRING)
-    		return false;
+    public function cancelSubscription($mixedPending)
+    {
+        $aPending = is_array($mixedPending) ? $mixedPending : $this->_oDb->getOrderPending(array('type' => 'id', 'id' => (int)$mixedPending));
+        if(empty($aPending) || !is_array($aPending) || $aPending['type'] != BX_PAYMENT_TYPE_RECURRING)
+            return false;
 
-            $aItems = $this->_oConfig->descriptorsM2A($aPending['items']);
-            foreach($aItems as $aItem)
-                $this->callCancelSubscriptionItem((int)$aItem['module_id'], array($aPending['client_id'], $aPending['seller_id'], $aItem['item_id'], $aItem['item_count'], $aPending['order']));
+        $aItems = $this->_oConfig->descriptorsM2A($aPending['items']);
+        foreach($aItems as $aItem)
+            $this->callCancelSubscriptionItem((int)$aItem['module_id'], array($aPending['client_id'], $aPending['seller_id'], $aItem['item_id'], $aItem['item_count'], $aPending['order']));
 
-            $aSubscription = $this->_oDb->getSubscription(array('type' => 'pending_id', 'pending_id' => $aPending['id']));
-            if(!empty($aSubscription) && is_array($aSubscription) && !$this->_oDb->deleteSubscription($aSubscription['id'], 'cancel'))
-                return false;
+        $aSubscription = $this->_oDb->getSubscription(array('type' => 'pending_id', 'pending_id' => $aPending['id']));
+        if(!empty($aSubscription) && is_array($aSubscription) && !$this->_oDb->deleteSubscription($aSubscription['id'], 'cancel'))
+            return false;
 
-            $this->onSubscriptionCancel($aPending);
+        $this->onSubscriptionCancel($aPending);
 
-            return true;
-	}
+        return true;
+    }
 
-	public function onPaymentRegisterBefore($aPending, $aResult = array())
-	{
-            //--- 'System' -> 'Before Register Payment' for Alerts Engine ---//
-            bx_alert('system', 'before_register_payment', 0, $aPending['client_id'], array('pending' => $aPending));
-            //--- 'System' -> 'Before Register Payment' for Alerts Engine ---//
-	}
+    public function onPaymentRegisterBefore($aPending, $aResult = array())
+    {
+        //--- 'System' -> 'Before Register Payment' for Alerts Engine ---//
+        bx_alert('system', 'before_register_payment', 0, $aPending['client_id'], array('pending' => $aPending));
+        //--- 'System' -> 'Before Register Payment' for Alerts Engine ---//
+    }
+
+    public function onPaymentRegister($aPending, $aResult = array())
+    {
+        $bTypeSingle = $aPending['type'] == BX_PAYMENT_TYPE_SINGLE;
 
-	public function onPaymentRegister($aPending, $aResult = array())
-	{
-	    $bTypeSingle = $aPending['type'] == BX_PAYMENT_TYPE_SINGLE;
+        if($bTypeSingle) {
+        $aItems = $this->_oConfig->descriptorsM2A($aPending['items']);
+        foreach($aItems as $aItem)
+            $this->isAllowedPurchase(array('module_id' => $aItem['module_id'], 'item_id' => $aItem['item_id']), true);
+        }
 
-	    if($bTypeSingle) {
-    	    $aItems = $this->_oConfig->descriptorsM2A($aPending['items']);
-            foreach($aItems as $aItem)
-                $this->isAllowedPurchase(array('module_id' => $aItem['module_id'], 'item_id' => $aItem['item_id']), true);
-	    }
+        //--- 'System' -> 'Register Payment' for Alerts Engine ---//
+        bx_alert('system', 'register_payment', 0, $aPending['client_id'], array('pending' => $aPending));
+        //--- 'System' -> 'Register Payment' for Alerts Engine ---//
+    }
 
-            //--- 'System' -> 'Register Payment' for Alerts Engine ---//
-            bx_alert('system', 'register_payment', 0, $aPending['client_id'], array('pending' => $aPending));
-            //--- 'System' -> 'Register Payment' for Alerts Engine ---//
-	}
+    public function onPaymentRefund($aPending, $aResult = array())
+    {
+        //--- 'System' -> 'Refund Payment' for Alerts Engine ---//
+        bx_alert('system', 'refund_payment', 0, $aPending['client_id'], array('pending' => $aPending));
+        //--- 'System' -> 'Refund Payment' for Alerts Engine ---//
+    }
 
-	public function onPaymentRefund($aPending, $aResult = array())
-	{
-            //--- 'System' -> 'Refund Payment' for Alerts Engine ---//
-            bx_alert('system', 'refund_payment', 0, $aPending['client_id'], array('pending' => $aPending));
-            //--- 'System' -> 'Refund Payment' for Alerts Engine ---//
-	}
+    public function onSubscriptionCreate($aPending, $aResult = array())
+    {
+        $aItems = $this->_oConfig->descriptorsM2A($aPending['items']);
+        $this->isAllowedPurchase(array('module_id' => $aItems[0]['module_id'], 'item_id' => $aItems[0]['item_id']), true);
 
-	public function onSubscriptionCreate($aPending, $aResult = array())
-	{
-	    $aItems = $this->_oConfig->descriptorsM2A($aPending['items']);
-	    $this->isAllowedPurchase(array('module_id' => $aItems[0]['module_id'], 'item_id' => $aItems[0]['item_id']), true);
+        //--- 'System' -> 'Create Subscription' for Alerts Engine ---//
+        bx_alert('system', 'create_subscription', 0, $aPending['client_id'], array('pending' => $aPending));
+        //--- 'System' -> 'Create Subscription' for Alerts Engine ---//
+    }
 
-            //--- 'System' -> 'Create Subscription' for Alerts Engine ---//
-            bx_alert('system', 'create_subscription', 0, $aPending['client_id'], array('pending' => $aPending));
-            //--- 'System' -> 'Create Subscription' for Alerts Engine ---//
-	}
+    public function onSubscriptionUpdate($aPending, $aResult = array())
+    {
+        //--- 'System' -> 'Update Subscription' for Alerts Engine ---//
+        bx_alert('system', 'update_subscription', 0, $aPending['client_id'], array('pending' => $aPending));
+        //--- 'System' -> 'Update Subscription' for Alerts Engine ---//
+    }
 
-	public function onSubscriptionUpdate($aPending, $aResult = array())
-	{
-            //--- 'System' -> 'Update Subscription' for Alerts Engine ---//
-            bx_alert('system', 'update_subscription', 0, $aPending['client_id'], array('pending' => $aPending));
-            //--- 'System' -> 'Update Subscription' for Alerts Engine ---//
-	}
-	
-	public function onSubscriptionCancel($aPending, $aResult = array())
-	{
-            //--- 'System' -> 'Cancel Subscription' for Alerts Engine ---//
-            bx_alert('system', 'cancel_subscription', 0, $aPending['client_id'], array('pending' => $aPending));
-            //--- 'System' -> 'Cancel Subscription' for Alerts Engine ---//
-	}
+    public function onSubscriptionCancel($aPending, $aResult = array())
+    {
+        //--- 'System' -> 'Cancel Subscription' for Alerts Engine ---//
+        bx_alert('system', 'cancel_subscription', 0, $aPending['client_id'], array('pending' => $aPending));
+        //--- 'System' -> 'Cancel Subscription' for Alerts Engine ---//
+    }
 
     public function setSiteSubmenu($sSubmenu, $sSelModule, $sSelName)
     {
@@ -1117,6 +1110,50 @@ class BxPaymentModule extends BxBaseModPaymentModule
         $oSiteSubmenu->setObjectSubmenu($sModuleSubmenu);
         $oModuleSubmenu->setSelected($sSelModule, $sSelName);
     }
+
+    public function getProviderButtonJs($aCartItem, $aProvider, $sRedirect = '', $aCustom = array())
+    {
+        $aButtonJs = array();
+        $iClientId = $this->getProfileId();
+
+        $sItemAddons = '';
+        if(count($aCartItem) == 5)
+            $sItemAddons = array_pop($aCartItem);
+
+        list($iSellerId, $iModuleId, $iItemId, $iItemCount) = $aCartItem;
+
+        $oProvider = $this->getObjectProvider($aProvider['name'], $iSellerId);
+        if($oProvider !== false && method_exists($oProvider, 'getButtonRecurring')) {
+            $aParams = array(
+                'sObjNameCart' => $this->_oConfig->getJsObject('cart'),
+                'iSellerId' => $iSellerId,
+                'iModuleId' => $iModuleId,
+                'iItemId' => $iItemId,
+                'iItemCount' => $iItemCount,
+                'sItemAddons' => $sItemAddons,
+                'sRedirect' => $sRedirect,
+                'sCustom' => base64_encode(serialize($aCustom))
+            );
+
+            $aCartInfo = $this->getObjectCart()->getInfo(BX_PAYMENT_TYPE_RECURRING, $iClientId, $iSellerId, $this->_oConfig->descriptorA2S($aCartItem));
+            if(!empty($aCartInfo['items_price']) && !empty($aCartInfo['items']) && is_array($aCartInfo['items'])) {
+                $aItem = array_shift($aCartInfo['items']);
+
+                $aParams = array_merge($aParams, array(
+                    'iAmount' => (int)round(100 * (float)$aCartInfo['items_price']),
+                    'sItemName' => $aItem['name'],
+                    'sItemTitle' => $aItem['title']
+                ));
+            }
+
+            $aButtonJs = $oProvider->getButtonRecurringJs($iClientId, $iSellerId, $aParams);
+        }
+
+        if(empty($aButtonJs) || !is_array($aButtonJs))
+            $aButtonJs = $this->getObjectSubscriptions()->serviceGetSubscribeJs($iSellerId, $aProvider['name'], $iModuleId, $iItemId, $iItemCount, $sRedirect, $aCustom);
+
+        return $aButtonJs;
+    }
 }
 
 /** @} */

+ 44 - 11
modules/boonex/payment/classes/BxPaymentProviderChargebeeV3.php

@@ -222,32 +222,65 @@ class BxPaymentProviderChargebeeV3 extends BxPaymentProviderChargebee
         return '';
     }
 
+    public function getButtonSingleJs($iClientId, $iVendorId, $aParams = array())
+    {
+        return array();
+    }
+
     public function getButtonRecurring($iClientId, $iVendorId, $aParams = array())
     {
         return $this->_getButton(BX_PAYMENT_TYPE_RECURRING, $iClientId, $iVendorId, $aParams);
     }
 
+    public function getButtonRecurringJs($iClientId, $iVendorId, $aParams = array())
+    {
+        return $this->_getButtonJs(BX_PAYMENT_TYPE_RECURRING, $iClientId, $iVendorId, $aParams);
+    }
+
     protected function _getButton($sType, $iClientId, $iVendorId, $aParams = array())
     {
-        $sSite = '';
-        bx_alert($this->_oModule->_oConfig->getName(), $this->_sName . '_get_button', 0, $iClientId, array(
-            'type' => &$sType, 
-            'site' => &$sSite,
-            'params' => &$aParams
-        ));
+        list($sJsCode, $sJsMethod) = $this->_getButtonJs($sType, $iClientId, $iVendorId, $aParams);        
 
         return $this->_oModule->_oTemplate->parseHtmlByName('cbee_v3_button_' . $sType . '.html', array(
             'type' => $sType,
             'link' => 'javascript:void(0)',
             'caption' => _t($this->_sLangsPrefix . 'cbee_txt_checkout_with_' . $sType, $this->_sCaption),
+            'onclick' => $sJsMethod,
             'js_object' => $this->_oModule->_oConfig->getJsObject($this->_sName),
-            'js_code' => $this->_oModule->_oTemplate->getJsCode($this->_sName, array_merge(array(
-                'sProvider' => $this->_sName,
-                'sSite' => !empty($sSite) ? $sSite : $this->_getSite(),
-                'iClientId' => $iClientId
-            ), $aParams))
+            'js_code' => $sJsCode
         ));
     }
+    
+    protected function _getButtonJs($sType, $iClientId, $iVendorId, $aParams = array())
+    {
+        $sJsObject = $this->_oModule->_oConfig->getJsObject($this->_sName);
+
+        $sSite = '';
+        bx_alert($this->_oModule->_oConfig->getName(), $this->_sName . '_get_button', 0, $iClientId, array(
+            'type' => &$sType, 
+            'site' => &$sSite,
+            'params' => &$aParams
+        ));
+
+        $sJsMethod = '';
+        switch($sType) {
+            case BX_PAYMENT_TYPE_SINGLE:
+                /**
+                 * Single time payments aren't available with Chargebee.
+                 */
+                break;
+
+            case BX_PAYMENT_TYPE_RECURRING:
+                $sJsMethod = $sJsObject . '.subscribe(this)';
+                break;
+        }
+
+        return array($this->_oModule->_oTemplate->getJsCode($this->_sName, array_merge(array(
+            'sProvider' => $this->_sName,
+            'sSite' => !empty($sSite) ? $sSite : $this->_getSite(),
+            'iClientId' => $iClientId
+        ), $aParams)), $sJsMethod);
+    }
 
     public function getMenuItemsActionsRecurring($iClientId, $iVendorId, $aParams = array())
     {

+ 76 - 33
modules/boonex/payment/classes/BxPaymentProviderStripe.php

@@ -79,7 +79,7 @@ class BxPaymentProviderStripe extends BxBaseModPaymentProvider implements iBxBas
     	$this->_bUseSsl = $this->getOption('ssl') == 'on';
     }
 
-	public function addJsCss()
+    public function addJsCss()
     {
     	if(!$this->isActive())
     		return;
@@ -230,9 +230,23 @@ class BxPaymentProviderStripe extends BxBaseModPaymentProvider implements iBxBas
             return '';
 
     	return $this->_getButton(BX_PAYMENT_TYPE_SINGLE, $iClientId, $iVendorId, array_merge($aParams, array(
-			'sVendorName' => _t($this->_sLangsPrefix . 'txt_payment_to', $aCartInfo['vendor_name']),
-			'sVendorCurrency' => $aCartInfo['vendor_currency_code'],
-			'sVendorIcon' => $aCartInfo['vendor_avatar'],
+            'sVendorName' => _t($this->_sLangsPrefix . 'txt_payment_to', $aCartInfo['vendor_name']),
+            'sVendorCurrency' => $aCartInfo['vendor_currency_code'],
+            'sVendorIcon' => $aCartInfo['vendor_avatar'],
+    	)));
+    }
+
+    public function getButtonSingleJs($iClientId, $iVendorId, $aParams = array())
+    {
+        $aItems = array();
+        $aCartInfo = $this->_oModule->getObjectCart()->getInfo(BX_PAYMENT_TYPE_SINGLE, $iClientId, (int)$iVendorId, $aItems);
+        if(empty($aCartInfo) || !is_array($aCartInfo))
+            return '';
+
+    	return $this->_getButtonJs(BX_PAYMENT_TYPE_SINGLE, $iClientId, $iVendorId, array_merge($aParams, array(
+            'sVendorName' => _t($this->_sLangsPrefix . 'txt_payment_to', $aCartInfo['vendor_name']),
+            'sVendorCurrency' => $aCartInfo['vendor_currency_code'],
+            'sVendorIcon' => $aCartInfo['vendor_avatar'],
     	)));
     }
 
@@ -240,11 +254,22 @@ class BxPaymentProviderStripe extends BxBaseModPaymentProvider implements iBxBas
     {
     	$aVendor = $this->_oModule->getVendorInfo((int)$iVendorId);
 
-		return $this->_getButton(BX_PAYMENT_TYPE_RECURRING, $iClientId, $iVendorId, array_merge($aParams, array(
-			'sVendorName' => _t($this->_sLangsPrefix . 'txt_payment_to', $aVendor['name']),
-			'sVendorCurrency' => $aVendor['currency_code'],
-			'sVendorIcon' => $aVendor['avatar'],
-		)));
+        return $this->_getButton(BX_PAYMENT_TYPE_RECURRING, $iClientId, $iVendorId, array_merge($aParams, array(
+            'sVendorName' => _t($this->_sLangsPrefix . 'txt_payment_to', $aVendor['name']),
+            'sVendorCurrency' => $aVendor['currency_code'],
+            'sVendorIcon' => $aVendor['avatar'],
+        )));
+    }
+    
+    public function getButtonRecurringJs($iClientId, $iVendorId, $aParams = array())
+    {
+    	$aVendor = $this->_oModule->getVendorInfo((int)$iVendorId);
+
+        return $this->_getButtonJs(BX_PAYMENT_TYPE_RECURRING, $iClientId, $iVendorId, array_merge($aParams, array(
+            'sVendorName' => _t($this->_sLangsPrefix . 'txt_payment_to', $aVendor['name']),
+            'sVendorCurrency' => $aVendor['currency_code'],
+            'sVendorIcon' => $aVendor['avatar'],
+        )));
     }
 
     public function getMenuItemsActionsRecurring($iClientId, $iVendorId, $aParams = array())
@@ -347,7 +372,7 @@ class BxPaymentProviderStripe extends BxBaseModPaymentProvider implements iBxBas
 
         return $this->_oModule->_oTemplate->parseHtmlByName('strp_billing_recurring.html', array(
             'brand' => $aCard['brand'],
-        	'origin' => $aCard['country'],
+            'origin' => $aCard['country'],
             'type' => $aCard['funding'],
             'number' => _t('_bx_payment_strp_txt_card_number_mask', $aCard['last4']),
             'expires' => _t('_bx_payment_strp_txt_card_expires_mask', $aCard['exp_month'], $aCard['exp_year']),
@@ -911,33 +936,51 @@ class BxPaymentProviderStripe extends BxBaseModPaymentProvider implements iBxBas
 
     protected function _getButton($sType, $iClientId, $iVendorId, $aParams = array())
     {
-    	$sClientEmail = '';
-    	if(!empty($iClientId)) {
-    		$oClient = BxDolProfile::getInstance($iClientId);
-    		if($oClient)
-    			$sClientEmail = $oClient->getAccountObject()->getEmail();
-    	}
-
-    	$sPublicKey = '';
-    	bx_alert($this->_oModule->_oConfig->getName(), $this->_sName . '_get_button', 0, $iClientId, array(
-			'type' => &$sType, 
-			'public_key' => &$sPublicKey
-		));
+        list($sJsCode, $sJsMethod) = $this->_getButtonJs($sType, $iClientId, $iVendorId, $aParams);
 
     	return $this->_oModule->_oTemplate->parseHtmlByName('strp_button_' . $sType . '.html', array(
-    		'type' => $sType,
-    		'caption' => _t($this->_sLangsPrefix . 'strp_txt_checkout_with_' . $sType, $this->_sCaption),
-    		'js_object' => $this->_oModule->_oConfig->getJsObject($this->_sName),
-    		'js_code' => $this->_oModule->_oTemplate->getJsCode($this->_sName, array_merge(array(
-	    		'sProvider' => $this->_sName,
-	    		'sPublicKey' => !empty($sPublicKey) ? $sPublicKey : $this->_getPublicKey(),
-	    		'sVendorName' => '',
-	    		'sVendorCurrency' => '',
-	    		'sVendorIcon' => '',
-	    		'sClientEmail' => $sClientEmail,
-	    	), $aParams))
+            'type' => $sType,
+            'caption' => _t($this->_sLangsPrefix . 'strp_txt_checkout_with_' . $sType, $this->_sCaption),  
+            'onclick' => $sJsMethod,
+            'js_object' => $this->_oModule->_oConfig->getJsObject($this->_sName),
+            'js_code' => $sJsCode,
     	));
     }
+
+    protected function _getButtonJs($sType, $iClientId, $iVendorId, $aParams = array())
+    {
+        $sJsObject = $this->_oModule->_oConfig->getJsObject($this->_sName);
+
+        $sClientEmail = '';
+    	if(!empty($iClientId) && ($oClient = BxDolProfile::getInstance($iClientId)) !== false)
+            $sClientEmail = $oClient->getAccountObject()->getEmail();
+
+        $sPublicKey = '';
+    	bx_alert($this->_oModule->_oConfig->getName(), $this->_sName . '_get_button', 0, $iClientId, array(
+            'type' => &$sType, 
+            'public_key' => &$sPublicKey
+        ));
+
+        $sJsMethod = '';
+        switch($sType) {
+            case BX_PAYMENT_TYPE_SINGLE:
+                $sJsMethod = $sJsObject . '.checkout(this)';
+                break;
+
+            case BX_PAYMENT_TYPE_RECURRING:
+                $sJsMethod = $sJsObject . '.subscribe(this)';
+                break;
+        }
+
+        return array($this->_oModule->_oTemplate->getJsCode($this->_sName, array_merge(array(
+            'sProvider' => $this->_sName,
+            'sPublicKey' => !empty($sPublicKey) ? $sPublicKey : $this->_getPublicKey(),
+            'sVendorName' => '',
+            'sVendorCurrency' => '',
+            'sVendorIcon' => '',
+            'sClientEmail' => $sClientEmail,
+        ), $aParams)), $sJsMethod);
+    }
 }
 
 /** @} */

+ 2 - 2
modules/boonex/payment/classes/BxPaymentSubscriptions.php

@@ -194,7 +194,7 @@ class BxPaymentSubscriptions extends BxBaseModPaymentSubscriptions
      */
     public function serviceSubscribe($iSellerId, $sSellerProvider, $iModuleId, $iItemId, $iItemCount, $sRedirect = '', $aCustom = array())
     {
-        return $this->serviceSubscribeWithAddons($iSellerId, $sSellerProvider, $iModuleId, $iItemId, $iItemCount, array(), $sRedirect, $aCustom);
+        return $this->serviceSubscribeWithAddons($iSellerId, $sSellerProvider, $iModuleId, $iItemId, $iItemCount, '', $sRedirect, $aCustom);
     }
     
     /**
@@ -212,7 +212,7 @@ class BxPaymentSubscriptions extends BxBaseModPaymentSubscriptions
      * @param $iModuleId integer value with module ID.
      * @param $iItemId integer value with item ID.
      * @param $iItemCount integer value with a number of items for purchasing. It's equal to 1 in case of subscription.
-     * @param $aItemAddons (optional) array with attached addons.
+     * @param $sItemAddons (optional) string with attached addons.
      * @param $sRedirect (optional) string value with redirect URL, if it's needed. 
      * @return an array with special format which describes the result of operation.
      * 

+ 41 - 70
modules/boonex/payment/classes/BxPaymentTemplate.php

@@ -82,44 +82,57 @@ class BxPaymentTemplate extends BxBaseModPaymentTemplate
     {
         $this->addJsCssCart(BX_PAYMENT_TYPE_SINGLE, $iVendorId);
         return $this->parseHtmlByName('add_to_cart.html', array(
-        	'js_object' => $this->_oConfig->getJsObject('cart'),
-        	'js_content' => $this->displayJsCode('cart'),
-        	'txt_add_to_cart' => _t($this->_sLangsPrefix . 'txt_add_to_cart'),
+            'js_object' => $this->_oConfig->getJsObject('cart'),
+            'js_content' => $this->displayJsCode('cart'),
+            'txt_add_to_cart' => _t($this->_sLangsPrefix . 'txt_add_to_cart'),
             'vendor_id' => $iVendorId,
             'module_id' => $iModuleId,
             'item_id' => $iItemId,
             'item_count' => $iItemCount,
             'need_redirect' => (int)$bNeedRedirect,
-        	'custom' => !empty($aCustom) && is_array($aCustom) ? base64_encode(serialize($aCustom)) : ''
+            'custom' => !empty($aCustom) && is_array($aCustom) ? base64_encode(serialize($aCustom)) : ''
         ));
     }
 
-	public function displaySubscribeJs($iVendorId, $sVendorProvider, $iModuleId, $iItemId, $iItemCount = 1, $sRedirect = '', $aCustom = array())
+    public function displaySubscribeJs($iVendorId, $sVendorProvider, $iModuleId, $iItemId, $iItemCount = 1, $sRedirect = '', $aCustom = array())
     {
-        $sJsCode = $this->displayCartJs(BX_PAYMENT_TYPE_RECURRING, $iVendorId);
-        $sJsMethod = $this->parseHtmlByName('subscribe_js.html', array(
-            'js_object' => $this->_oConfig->getJsObject('cart'),
-            'vendor_id' => $iVendorId,
-        	'vendor_provider' => $sVendorProvider,
-            'module_id' => $iModuleId,
-            'item_id' => $iItemId,
-            'item_count' => $iItemCount,
-            'redirect' => !empty($sRedirect) ? $sRedirect : '',
-            'custom' => !empty($aCustom) && is_array($aCustom) ? base64_encode(serialize($aCustom)) : ''
-        ));
+        return $this->displaySubscribeJsWithAddons($iVendorId, $sVendorProvider, $iModuleId, $iItemId, $iItemCount, '', $sRedirect, $aCustom);
+    }
 
-        return array($sJsCode, $sJsMethod);
+    public function displaySubscribeJsWithAddons($iVendorId, $sVendorProvider, $iModuleId, $iItemId, $iItemCount = 1, $sItemAddons = '', $sRedirect = '', $aCustom = array())
+    {
+        $aSellerProviders = $this->_oDb->getVendorInfoProvidersRecurring($iVendorId);
+        if(empty($sVendorProvider) && count($aSellerProviders) == 1) {
+            $aCartItem = array($iVendorId, $iModuleId, $iItemId, $iItemCount, $sItemAddons);
+
+            $this->addJsCssCart(BX_PAYMENT_TYPE_RECURRING, $iVendorId);
+            return $this->getModule()->getProviderButtonJs($aCartItem, array_shift($aSellerProviders), $sRedirect, $aCustom);
+        }
+
+        return array(
+            $this->displayCartJs(BX_PAYMENT_TYPE_RECURRING, $iVendorId),
+            $this->parseHtmlByName('subscribe_js.html', array(
+                'js_object' => $this->_oConfig->getJsObject('cart'),
+                'vendor_id' => $iVendorId,
+                'vendor_provider' => $sVendorProvider,
+                'module_id' => $iModuleId,
+                'item_id' => $iItemId,
+                'item_count' => $iItemCount,
+                'redirect' => !empty($sRedirect) ? $sRedirect : '',
+                'custom' => !empty($aCustom) && is_array($aCustom) ? base64_encode(serialize($aCustom)) : ''
+            ))
+        );
     }
 
     public function displaySubscribeLink($iVendorId, $sVendorProvider, $iModuleId, $iItemId, $iItemCount = 1, $sRedirect = '', $aCustom = array())
     {
         $this->addJsCssCart(BX_PAYMENT_TYPE_RECURRING, $iVendorId);
         return $this->parseHtmlByName('subscribe.html', array(
-        	'js_object' => $this->_oConfig->getJsObject('cart'),
-        	'js_content' => $this->displayJsCode('cart'),
-        	'txt_add_to_cart' => _t($this->_sLangsPrefix . 'txt_subscribe'),
+            'js_object' => $this->_oConfig->getJsObject('cart'),
+            'js_content' => $this->displayJsCode('cart'),
+            'txt_add_to_cart' => _t($this->_sLangsPrefix . 'txt_subscribe'),
             'vendor_id' => $iVendorId,
-        	'vendor_provider' => $sVendorProvider,
+            'vendor_provider' => $sVendorProvider,
             'module_id' => $iModuleId,
             'item_id' => $iItemId,
             'item_count' => $iItemCount,
@@ -349,64 +362,22 @@ class BxPaymentTemplate extends BxBaseModPaymentTemplate
     public function displayProvidersSelector($aCartItem, $aProviders, $sRedirect = '', $aCustom = array())
     {
     	$oModule = $this->getModule();
-    	$iClientId = $oModule->getProfileId();
-
-        $oCart = $oModule->getObjectCart();
-        $oSubscriptions = $oModule->getObjectSubscriptions();
-
-        $sItemAddons = '';
-        if(count($aCartItem) == 5)
-            $sItemAddons = array_pop($aCartItem);
-
-        list($iSellerId, $iModuleId, $iItemId, $iItemCount) = $aCartItem;
 
         $aTmplVarsProviders = array();
         foreach($aProviders as $sProvider => $aProvider) {
-            $sButton = '';
-
-            $oProvider = $oModule->getObjectProvider($sProvider, $iSellerId);
-            if($oProvider !== false && method_exists($oProvider, 'getButtonRecurring')) {
-                $aParams = array(
-                    'sObjNameCart' => $oModule->_oConfig->getJsObject('cart'),
-                    'iSellerId' => $iSellerId,
-                    'iModuleId' => $iModuleId,
-                    'iItemId' => $iItemId,
-                    'iItemCount' => $iItemCount,
-                    'sItemAddons' => $sItemAddons,
-                    'sRedirect' => $sRedirect,
-                    'sCustom' => base64_encode(serialize($aCustom))
-                );
-
-                $aCartInfo = $oCart->getInfo(BX_PAYMENT_TYPE_RECURRING, $iClientId, $iSellerId, $this->_oConfig->descriptorA2S($aCartItem));
-                if(!empty($aCartInfo['items_price']) && !empty($aCartInfo['items']) && is_array($aCartInfo['items'])) {
-                    $aItem = array_shift($aCartInfo['items']);
-
-                    $aParams = array_merge($aParams, array(
-                        'iAmount' => (int)round(100 * (float)$aCartInfo['items_price']),
-                        'sItemName' => $aItem['name'],
-                        'sItemTitle' => $aItem['title']
-                    ));
-                }
-
-                $sButton = $oProvider->getButtonRecurring($iClientId, $iSellerId, $aParams);
-            }
-
-            if(empty($sButton)) {
-                list($sJsCode, $sJsOnclick) = $oSubscriptions->serviceGetSubscribeJs($iSellerId, $aProvider['name'], $iModuleId, $iItemId, $iItemCount, $sRedirect, $aCustom);
-
-                $sButton = $this->parsePageByName('providers_select_button.html', array(
-                    'onclick' => $sJsOnclick,
-                    'title' => _t('_bx_payment_txt_checkout_with', _t($aProvider['caption']))
-                ));
-            }
+            list($sJsCode, $sJsOnclick) = $oModule->getProviderButtonJs($aCartItem, $aProvider, $sRedirect, $aCustom);
 
             $aTmplVarsProviders[] = array(
-                'button' => $sButton
+                'button' => $this->parseHtmlByName('providers_select_button.html', array(
+                    'onclick' => $sJsOnclick,
+                    'title' => _t('_bx_payment_txt_checkout_with', _t($aProvider['caption'])),
+                    'js_code' => $sJsCode
+                ))
             );
         }
 
         return $this->parseHtmlByName('providers_select.html', array(
-                'bx_repeat:providers' => $aTmplVarsProviders
+            'bx_repeat:providers' => $aTmplVarsProviders
         ));
     }
 

+ 38 - 37
modules/boonex/payment/install/langs/en.xml

@@ -90,24 +90,24 @@
     <string name="_bx_payment_menu_item_title_system_sbs_cancel"><![CDATA[Cancel Subscription]]></string>
     <string name="_bx_payment_menu_item_title_sbs_cancel"><![CDATA[Cancel Subscription]]></string>
 
-	<!-- GRIDS -->
-        <string name="_bx_payment_grid_column_title_pdrs_caption"><![CDATA[Caption]]></string>
-        <string name="_bx_payment_grid_column_title_pdrs_description"><![CDATA[Description]]></string>
-        <string name="_bx_payment_grid_column_title_pdrs_for_visitor"><![CDATA[For visitors]]></string>
-        <string name="_bx_payment_grid_column_title_pdrs_for_single"><![CDATA[One Time]]></string>
-        <string name="_bx_payment_grid_column_title_pdrs_for_recurring"><![CDATA[Recurring]]></string>
-	<string name="_bx_payment_grid_column_title_ods_client_id"><![CDATA[Client]]></string>
-	<string name="_bx_payment_grid_column_title_ods_seller_id"><![CDATA[Seller]]></string>
-	<string name="_bx_payment_grid_column_title_ods_transaction"><![CDATA[Transaction]]></string>
-	<string name="_bx_payment_grid_column_title_ods_license"><![CDATA[License]]></string>
-        <string name="_bx_payment_grid_column_title_ods_item"><![CDATA[Product]]></string>
-	<string name="_bx_payment_grid_column_title_ods_amount"><![CDATA[Amount]]></string>
-	<string name="_bx_payment_grid_column_title_ods_date"><![CDATA[Date]]></string>
-	<string name="_bx_payment_grid_column_title_sbs_seller_id"><![CDATA[Seller]]></string>
-	<string name="_bx_payment_grid_column_title_sbs_client_id"><![CDATA[Client]]></string>
-        <string name="_bx_payment_grid_column_title_sbs_client_email"><![CDATA[Email]]></string>
-	<string name="_bx_payment_grid_column_title_sbs_customer_id"><![CDATA[Customer ID]]></string>
-	<string name="_bx_payment_grid_column_title_sbs_subscription_id"><![CDATA[Subscription]]></string>
+    <!-- GRIDS -->
+    <string name="_bx_payment_grid_column_title_pdrs_caption"><![CDATA[Caption]]></string>
+    <string name="_bx_payment_grid_column_title_pdrs_description"><![CDATA[Description]]></string>
+    <string name="_bx_payment_grid_column_title_pdrs_for_visitor"><![CDATA[For visitors]]></string>
+    <string name="_bx_payment_grid_column_title_pdrs_for_single"><![CDATA[One Time]]></string>
+    <string name="_bx_payment_grid_column_title_pdrs_for_recurring"><![CDATA[Recurring]]></string>
+    <string name="_bx_payment_grid_column_title_ods_client_id"><![CDATA[Client]]></string>
+    <string name="_bx_payment_grid_column_title_ods_seller_id"><![CDATA[Seller]]></string>
+    <string name="_bx_payment_grid_column_title_ods_transaction"><![CDATA[Transaction]]></string>
+    <string name="_bx_payment_grid_column_title_ods_license"><![CDATA[License]]></string>
+    <string name="_bx_payment_grid_column_title_ods_item"><![CDATA[Product]]></string>
+    <string name="_bx_payment_grid_column_title_ods_amount"><![CDATA[Amount]]></string>
+    <string name="_bx_payment_grid_column_title_ods_date"><![CDATA[Date]]></string>
+    <string name="_bx_payment_grid_column_title_sbs_seller_id"><![CDATA[Seller]]></string>
+    <string name="_bx_payment_grid_column_title_sbs_client_id"><![CDATA[Client]]></string>
+    <string name="_bx_payment_grid_column_title_sbs_client_email"><![CDATA[Email]]></string>
+    <string name="_bx_payment_grid_column_title_sbs_customer_id"><![CDATA[Customer ID]]></string>
+    <string name="_bx_payment_grid_column_title_sbs_subscription_id"><![CDATA[Subscription]]></string>
     <string name="_bx_payment_grid_column_title_sbs_transaction"><![CDATA[Transaction]]></string>
     <string name="_bx_payment_grid_column_title_sbs_license"><![CDATA[License]]></string>
     <string name="_bx_payment_grid_column_title_sbs_amount"><![CDATA[Amount]]></string>
@@ -115,25 +115,26 @@
     <string name="_bx_payment_grid_column_title_sbs_paid"><![CDATA[Paid]]></string>
     <string name="_bx_payment_grid_column_title_sbs_date"><![CDATA[Date]]></string>
     <string name="_bx_payment_grid_column_title_sbs_date_created"><![CDATA[Created]]></string>
-	<string name="_bx_payment_grid_column_title_crts_vendor_id"><![CDATA[Vendor]]></string>
-	<string name="_bx_payment_grid_column_title_crts_items_count"><![CDATA[Count]]></string>
-	<string name="_bx_payment_grid_column_title_crts_items_price"><![CDATA[Price]]></string>
-	<string name="_bx_payment_grid_column_title_crt_title"><![CDATA[Product]]></string>
-	<string name="_bx_payment_grid_column_title_crt_description"><![CDATA[Description]]></string>
-	<string name="_bx_payment_grid_column_title_crt_quantity"><![CDATA[Quantity]]></string>
-	<string name="_bx_payment_grid_column_title_crt_price"><![CDATA[Price]]></string>
-
-	<string name="_bx_payment_grid_action_title_ods_add"><![CDATA[Manual Order]]></string>
-	<string name="_bx_payment_grid_action_title_ods_cancel"><![CDATA[Cancel]]></string>
-	<string name="_bx_payment_grid_action_title_ods_process"><![CDATA[Process]]></string>
-	<string name="_bx_payment_grid_action_title_ods_view_order"><![CDATA[View]]></string>
-	<string name="_bx_payment_grid_action_title_sbs_actions"><![CDATA[Actions]]></string>
-	<string name="_bx_payment_grid_action_title_sbs_view_order"><![CDATA[View]]></string>
-	<string name="_bx_payment_grid_action_title_sbs_cancel"><![CDATA[Cancel]]></string>
-	<string name="_bx_payment_grid_action_title_crts_delete"><![CDATA[Delete]]></string>
-	<string name="_bx_payment_grid_action_title_crts_continue"><![CDATA[Continue to checkout]]></string>
-	<string name="_bx_payment_grid_action_title_crt_checkout"><![CDATA[Checkout with {0}]]></string>
-	<string name="_bx_payment_grid_action_title_crt_delete"><![CDATA[Delete]]></string>
+    <string name="_bx_payment_grid_column_title_crts_vendor_id"><![CDATA[Vendor]]></string>
+    <string name="_bx_payment_grid_column_title_crts_items_count"><![CDATA[Count]]></string>
+    <string name="_bx_payment_grid_column_title_crts_items_price"><![CDATA[Price]]></string>
+    <string name="_bx_payment_grid_column_title_crt_title"><![CDATA[Product]]></string>
+    <string name="_bx_payment_grid_column_title_crt_description"><![CDATA[Description]]></string>
+    <string name="_bx_payment_grid_column_title_crt_quantity"><![CDATA[Quantity]]></string>
+    <string name="_bx_payment_grid_column_title_crt_price"><![CDATA[Price]]></string>
+
+    <string name="_bx_payment_grid_action_title_ods_add"><![CDATA[Manual Order]]></string>
+    <string name="_bx_payment_grid_action_title_ods_cancel"><![CDATA[Cancel]]></string>
+    <string name="_bx_payment_grid_action_title_ods_process"><![CDATA[Process]]></string>
+    <string name="_bx_payment_grid_action_title_ods_view_order"><![CDATA[View]]></string>
+    <string name="_bx_payment_grid_action_title_sbs_actions"><![CDATA[Actions]]></string>
+    <string name="_bx_payment_grid_action_title_sbs_view_order"><![CDATA[View]]></string>
+    <string name="_bx_payment_grid_action_title_sbs_cancel"><![CDATA[Cancel]]></string>
+    <string name="_bx_payment_grid_action_title_sbs_delete"><![CDATA[Remove]]></string>
+    <string name="_bx_payment_grid_action_title_crts_delete"><![CDATA[Delete]]></string>
+    <string name="_bx_payment_grid_action_title_crts_continue"><![CDATA[Continue to checkout]]></string>
+    <string name="_bx_payment_grid_action_title_crt_checkout"><![CDATA[Checkout with {0}]]></string>
+    <string name="_bx_payment_grid_action_title_crt_delete"><![CDATA[Delete]]></string>
 
     <string name="_bx_payment_popup_title_ods_order_subscription_view"><![CDATA[Subscription]]></string>
     <string name="_bx_payment_popup_title_ods_order_subscription_get_details"><![CDATA[Subscription Details]]></string>

+ 2 - 1
modules/boonex/payment/install/sql/install.sql

@@ -344,7 +344,8 @@ INSERT INTO `sys_grid_actions` (`object`, `type`, `name`, `title`, `icon`, `icon
 ('bx_payment_grid_sbs_list_my', 'single', 'actions', '_bx_payment_grid_action_title_sbs_actions', 'cog', 1, 0, 2),
 
 ('bx_payment_grid_sbs_list_all', 'single', 'view_order', '_bx_payment_grid_action_title_sbs_view_order', 'ellipsis-h', 1, 0, 1),
-('bx_payment_grid_sbs_list_all', 'single', 'cancel', '_bx_payment_grid_action_title_sbs_cancel', 'times', 1, 1, 2),
+('bx_payment_grid_sbs_list_all', 'single', 'cancel', '_bx_payment_grid_action_title_sbs_cancel', 'ban', 1, 1, 2),
+('bx_payment_grid_sbs_list_all', 'single', 'delete', '_bx_payment_grid_action_title_sbs_delete', 'times', 1, 1, 3),
 
 ('bx_payment_grid_sbs_history', 'single', 'view_order', '_bx_payment_grid_action_title_sbs_view_order', 'ellipsis-h', 1, 0, 1),
 

+ 2 - 1
modules/boonex/payment/template/providers_select_button.html

@@ -1 +1,2 @@
-<a class="bx-btn bx-def-margin-top-auto" href="javascript:void(0)" onclick="javascript:__onclick__">__title__</a>
+<a class="bx-btn bx-def-margin-top-auto" href="javascript:void(0)" onclick="javascript:__onclick__">__title__</a>
+__js_code__

+ 1 - 1
modules/boonex/payment/template/strp_button_recurring.html

@@ -1,2 +1,2 @@
-<a class="bx-btn bx-def-margin-top-auto" href="javascript:void(0)" onclick="javascript:__js_object__.subscribe(this)">__caption__</a>
+<a class="bx-btn bx-def-margin-top-auto" href="javascript:void(0)" onclick="javascript:__onclick__">__caption__</a>
 __js_code__

+ 2 - 2
modules/boonex/payment/template/strp_button_single.html

@@ -1,4 +1,4 @@
 <div class="bx-payment-strp-button-__type__">
-	<button class="bx-btn bx-def-margin-thd" type="button" onclick="javascript:__js_object__.checkout(this)">__caption__</button>
-	__js_code__
+    <button class="bx-btn bx-def-margin-thd" type="button" onclick="javascript:__onclick__">__caption__</button>
+    __js_code__
 </div>

+ 37 - 36
modules/boonex/russian/data/langs/bx_payment/ru.xml

@@ -89,23 +89,23 @@
     <string name="_bx_payment_menu_item_title_system_sbs_cancel"><![CDATA[Отменить подписку]]></string>
     <string name="_bx_payment_menu_item_title_sbs_cancel"><![CDATA[Отменить подписку]]></string>
 
-	<!-- GRIDS -->
-        <string name="_bx_payment_grid_column_title_pdrs_caption"><![CDATA[Название]]></string>
-        <string name="_bx_payment_grid_column_title_pdrs_description"><![CDATA[Описание]]></string>
-        <string name="_bx_payment_grid_column_title_pdrs_for_visitor"><![CDATA[Для посетителей]]></string>
-        <string name="_bx_payment_grid_column_title_pdrs_for_single"><![CDATA[Разовые]]></string>
-        <string name="_bx_payment_grid_column_title_pdrs_for_recurring"><![CDATA[Периодические]]></string>
-	<string name="_bx_payment_grid_column_title_ods_client_id"><![CDATA[Покупатель]]></string>
-	<string name="_bx_payment_grid_column_title_ods_seller_id"><![CDATA[Продавец]]></string>
-	<string name="_bx_payment_grid_column_title_ods_transaction"><![CDATA[Транзакция]]></string>
-	<string name="_bx_payment_grid_column_title_ods_license"><![CDATA[Лицензия]]></string>
-        <string name="_bx_payment_grid_column_title_ods_item"><![CDATA[Продукт]]></string>
-	<string name="_bx_payment_grid_column_title_ods_amount"><![CDATA[Сумма]]></string>
-	<string name="_bx_payment_grid_column_title_ods_date"><![CDATA[Дата]]></string>
-	<string name="_bx_payment_grid_column_title_sbs_seller_id"><![CDATA[Продавец]]></string>
-	<string name="_bx_payment_grid_column_title_sbs_client_id"><![CDATA[Покупатель]]></string>
-        <string name="_bx_payment_grid_column_title_sbs_client_email"><![CDATA[Email]]></string>
-	<string name="_bx_payment_grid_column_title_sbs_customer_id"><![CDATA[ID Покупателя]]></string>
+    <!-- GRIDS -->
+    <string name="_bx_payment_grid_column_title_pdrs_caption"><![CDATA[Название]]></string>
+    <string name="_bx_payment_grid_column_title_pdrs_description"><![CDATA[Описание]]></string>
+    <string name="_bx_payment_grid_column_title_pdrs_for_visitor"><![CDATA[Для посетителей]]></string>
+    <string name="_bx_payment_grid_column_title_pdrs_for_single"><![CDATA[Разовые]]></string>
+    <string name="_bx_payment_grid_column_title_pdrs_for_recurring"><![CDATA[Периодические]]></string>
+    <string name="_bx_payment_grid_column_title_ods_client_id"><![CDATA[Покупатель]]></string>
+    <string name="_bx_payment_grid_column_title_ods_seller_id"><![CDATA[Продавец]]></string>
+    <string name="_bx_payment_grid_column_title_ods_transaction"><![CDATA[Транзакция]]></string>
+    <string name="_bx_payment_grid_column_title_ods_license"><![CDATA[Лицензия]]></string>
+    <string name="_bx_payment_grid_column_title_ods_item"><![CDATA[Продукт]]></string>
+    <string name="_bx_payment_grid_column_title_ods_amount"><![CDATA[Сумма]]></string>
+    <string name="_bx_payment_grid_column_title_ods_date"><![CDATA[Дата]]></string>
+    <string name="_bx_payment_grid_column_title_sbs_seller_id"><![CDATA[Продавец]]></string>
+    <string name="_bx_payment_grid_column_title_sbs_client_id"><![CDATA[Покупатель]]></string>
+    <string name="_bx_payment_grid_column_title_sbs_client_email"><![CDATA[Email]]></string>
+    <string name="_bx_payment_grid_column_title_sbs_customer_id"><![CDATA[ID Покупателя]]></string>
     <string name="_bx_payment_grid_column_title_sbs_subscription_id"><![CDATA[Подписка]]></string>
     <string name="_bx_payment_grid_column_title_sbs_transaction"><![CDATA[Транзакция]]></string>
     <string name="_bx_payment_grid_column_title_sbs_license"><![CDATA[Лицензия]]></string>
@@ -114,25 +114,26 @@
     <string name="_bx_payment_grid_column_title_sbs_date"><![CDATA[Дата]]></string>
     <string name="_bx_payment_grid_column_title_sbs_date_created"><![CDATA[Дата создания]]></string>
     <string name="_bx_payment_grid_column_title_sbs_paid"><![CDATA[Оплачено]]></string>
-	<string name="_bx_payment_grid_column_title_crts_vendor_id"><![CDATA[Продавец]]></string>
-	<string name="_bx_payment_grid_column_title_crts_items_count"><![CDATA[Количество]]></string>
-	<string name="_bx_payment_grid_column_title_crts_items_price"><![CDATA[Цена]]></string>
-	<string name="_bx_payment_grid_column_title_crt_title"><![CDATA[Продукт]]></string>
-	<string name="_bx_payment_grid_column_title_crt_description"><![CDATA[Описание]]></string>
-	<string name="_bx_payment_grid_column_title_crt_quantity"><![CDATA[Количество]]></string>
-	<string name="_bx_payment_grid_column_title_crt_price"><![CDATA[Цена]]></string>
-
-	<string name="_bx_payment_grid_action_title_ods_add"><![CDATA[Добавить вручную]]></string>
-	<string name="_bx_payment_grid_action_title_ods_cancel"><![CDATA[Отменить]]></string>
-	<string name="_bx_payment_grid_action_title_ods_process"><![CDATA[Обработать]]></string>
-	<string name="_bx_payment_grid_action_title_ods_view_order"><![CDATA[Детали заказа]]></string>
-	<string name="_bx_payment_grid_action_title_sbs_actions"><![CDATA[Действия]]></string>
-	<string name="_bx_payment_grid_action_title_sbs_view_order"><![CDATA[Детали выплаты]]></string>
-	<string name="_bx_payment_grid_action_title_sbs_cancel"><![CDATA[Отменить]]></string>
-	<string name="_bx_payment_grid_action_title_crts_delete"><![CDATA[Удалить]]></string>
-	<string name="_bx_payment_grid_action_title_crts_continue"><![CDATA[Продолжить оплату]]></string>
-	<string name="_bx_payment_grid_action_title_crt_checkout"><![CDATA[Оплатить через {0}]]></string>
-	<string name="_bx_payment_grid_action_title_crt_delete"><![CDATA[Удалить]]></string>
+    <string name="_bx_payment_grid_column_title_crts_vendor_id"><![CDATA[Продавец]]></string>
+    <string name="_bx_payment_grid_column_title_crts_items_count"><![CDATA[Количество]]></string>
+    <string name="_bx_payment_grid_column_title_crts_items_price"><![CDATA[Цена]]></string>
+    <string name="_bx_payment_grid_column_title_crt_title"><![CDATA[Продукт]]></string>
+    <string name="_bx_payment_grid_column_title_crt_description"><![CDATA[Описание]]></string>
+    <string name="_bx_payment_grid_column_title_crt_quantity"><![CDATA[Количество]]></string>
+    <string name="_bx_payment_grid_column_title_crt_price"><![CDATA[Цена]]></string>
+
+    <string name="_bx_payment_grid_action_title_ods_add"><![CDATA[Добавить вручную]]></string>
+    <string name="_bx_payment_grid_action_title_ods_cancel"><![CDATA[Отменить]]></string>
+    <string name="_bx_payment_grid_action_title_ods_process"><![CDATA[Обработать]]></string>
+    <string name="_bx_payment_grid_action_title_ods_view_order"><![CDATA[Детали заказа]]></string>
+    <string name="_bx_payment_grid_action_title_sbs_actions"><![CDATA[Действия]]></string>
+    <string name="_bx_payment_grid_action_title_sbs_view_order"><![CDATA[Детали выплаты]]></string>
+    <string name="_bx_payment_grid_action_title_sbs_cancel"><![CDATA[Отменить]]></string>
+    <string name="_bx_payment_grid_action_title_sbs_delete"><![CDATA[Удалить]]></string>
+    <string name="_bx_payment_grid_action_title_crts_delete"><![CDATA[Удалить]]></string>
+    <string name="_bx_payment_grid_action_title_crts_continue"><![CDATA[Продолжить оплату]]></string>
+    <string name="_bx_payment_grid_action_title_crt_checkout"><![CDATA[Оплатить через {0}]]></string>
+    <string name="_bx_payment_grid_action_title_crt_delete"><![CDATA[Удалить]]></string>
 
     <string name="_bx_payment_popup_title_ods_order_subscription_view"><![CDATA[Подписка]]></string>
     <string name="_bx_payment_popup_title_ods_order_subscription_get_details"><![CDATA[Детали подписки]]></string>

+ 7 - 2
template/scripts/BxBaseLiveUpdates.php

@@ -32,13 +32,18 @@ class BxBaseLiveUpdates extends BxDolLiveUpdates
          * Load and cache(if it's needed) default(system) 
          * live updates for current user.
          */ 
-        //$aCached = $this->_getCachedData();
+        $aCached = $this->_getCachedData();
+
+        /* tmp fix for #3002 */
+        foreach ($aCached as $sName => $a)
+            if (!in_array($sName, $this->_aSystemsTransient))
+                $aCached[$sName] = 0;
 
         $aParams = array_merge(array(
             'sActionsUrl' => BX_DOL_URL_ROOT . 'live_updates.php',
             'sObjName' => $this->_sJsObject,
             'iInterval' => $this->_iInterval,
-            'aSystemsActive' => /*array_intersect_key($aCached, */array_flip($this->_aSystemsActive)/*)*/,
+            'aSystemsActive' => array_intersect_key($aCached, array_flip($this->_aSystemsActive)),
             'aSystemsTransient' => array_flip($this->_aSystemsTransient),
             'bServerRequesting' => !empty($this->_aSystems),
             'sHash' => base64_encode($this->_sCacheKey),