AntonLV 8 år sedan
förälder
incheckning
1d399b621a

+ 22 - 4
modules/base/payment/classes/BxBaseModPaymentProvider.php

@@ -40,18 +40,36 @@ class BxBaseModPaymentProvider extends BxDol
 
         $this->_sLangsPrefix = $this->_oModule->_oConfig->getPrefix('langs');
 
+        $this->_bRedirectOnResult = false;
+        $this->_bUseSsl = false;
+
         $this->_iId = (int)$aConfig['id'];
         $this->_sName = $aConfig['name'];
         $this->_sCaption = _t($aConfig['caption']);
         $this->_sPrefix = $aConfig['option_prefix'];
-        $this->_aOptions = !empty($aConfig['options']) ? $aConfig['options'] : array();
-        $this->_bUseSsl = false;
-        $this->_bRedirectOnResult = false;
+
+        $this->_sLogFile = BX_DIRECTORY_PATH_LOGS . 'bx_pp_' . $this->_sName . '.log';
+
+        $this->_aOptions = array();
+        if(!empty($aConfig['options']) && is_array($aConfig['options']))
+        	$this->setOptions($aConfig['options']);
+    }
+
+    public function setOptions($aOptions)
+    {
+    	$this->_aOptions = $aOptions;
+
+    	/*
+    	 * Note: Any settings related to Vendor Options
+    	 * should be initialized here.
+    	 */
     }
 
     public function setOptionsByVendor($iVendorId)
     {
-        $this->_aOptions = $this->_oModule->_oDb->getOptions((int)$iVendorId, $this->_iId);
+        $aOptions = $this->_oModule->_oDb->getOptions((int)$iVendorId, $this->_iId);
+        if(!empty($aOptions) && is_array($aOptions))
+	        $this->setOptions($aOptions);
     }
 
     public function isActive()

+ 0 - 3
modules/boonex/payment/classes/BxPaymentProviderBitPay.php

@@ -28,9 +28,6 @@ class BxPaymentProviderBitPay extends BxBaseModPaymentProvider implements iBxBas
 
         parent::__construct($aConfig);
 
-        $this->_bRedirectOnResult = false;
-        $this->_sLogFile = BX_DIRECTORY_PATH_LOGS . 'bx_pp_' . $this->_sName . '.log';
-
         $this->_initializeOptions();
     }
 

+ 8 - 6
modules/boonex/payment/classes/BxPaymentProviderChargebee.php

@@ -23,14 +23,16 @@ class BxPaymentProviderChargebee extends BxBaseModPaymentProvider implements iBx
     {
     	$this->MODULE = 'bx_payment';
 
-        parent::__construct($aConfig);
+        parent::__construct($aConfig);        
+    }
 
-        $this->_bRedirectOnResult = false;
-        $this->_bUseSsl = $this->getOption('ssl') == 'on';
-        $this->_sLogFile = BX_DIRECTORY_PATH_LOGS . 'bx_pp_' . $this->_sName . '.log';        
+    public function setOptions($aOptions)
+    {
+    	parent::setOptions($aOptions);
 
-        $this->_iMode = (int)$this->getOption('mode');
-        $this->_bCheckAmount = false; // Disabled for easier processing of discounted subscriptions.
+    	$this->_iMode = (int)$this->getOption('mode');
+        $this->_bCheckAmount = $this->getOption('check_amount') == 'on';
+        $this->_bUseSsl = $this->getOption('ssl') == 'on';
     }
 
     public function initializeCheckout($iPendingId, $aCartInfo)

+ 0 - 3
modules/boonex/payment/classes/BxPaymentProviderPayPal.php

@@ -34,9 +34,6 @@ class BxPaymentProviderPayPal extends BxBaseModPaymentProvider implements iBxBas
     	$this->MODULE = 'bx_payment';
 
         parent::__construct($aConfig);
-
-        $this->_bRedirectOnResult = false;
-        $this->_sLogFile = BX_DIRECTORY_PATH_LOGS . 'bx_pp_' . $this->_sName . '.log';
     }
 
     public function initializeCheckout($iPendingId, $aCartInfo, $bRecurring = false, $iRecurringDays = 0)

+ 7 - 4
modules/boonex/payment/classes/BxPaymentProviderRecurly.php

@@ -41,14 +41,17 @@ class BxPaymentProviderRecurly extends BxBaseModPaymentProvider implements iBxBa
         $this->_sFormCard = 'bx_payment_form_rcrl_card';
         $this->_sFormDisplayCardAdd = 'bx_payment_form_rcrl_card_add';
 
-        $this->_bRedirectOnResult = false;
         $this->_bUseSsl = true;
-        $this->_sLogFile = BX_DIRECTORY_PATH_LOGS . 'bx_pp_' . $this->_sName . '.log';        
-
-        $this->_iMode = (int)$this->getOption('mode');
         $this->_bCheckAmount = false; // Disabled for easier processing of discounted subscriptions.
     }
 
+    public function setOptions($aOptions)
+    {
+    	parent::setOptions($aOptions);
+
+    	$this->_iMode = (int)$this->getOption('mode');
+    }
+
 	public function addJsCss()
     {
     	if(!$this->isActive())

+ 11 - 6
modules/boonex/payment/classes/BxPaymentProviderStripe.php

@@ -1,4 +1,5 @@
-<?php defined('BX_DOL') or die('hack attempt');
+<?php use Twilio\Rest\Accounts\V1\Credential\PublicKeyContext;
+defined('BX_DOL') or die('hack attempt');
 /**
  * Copyright (c) UNA, Inc - https://una.io
  * MIT License - https://opensource.org/licenses/MIT
@@ -44,12 +45,7 @@ class BxPaymentProviderStripe extends BxBaseModPaymentProvider implements iBxBas
         $this->_sFormCard = 'bx_payment_form_strp_card';
         $this->_sFormDisplayCardAdd = 'bx_payment_form_strp_card_add';
 
-        $this->_bRedirectOnResult = false;
-        $this->_iMode = (int)$this->getOption('mode');
-        $this->_bCheckAmount = $this->getOption('check_amount') == 'on'; 
-        $this->_bUseSsl = $this->getOption('ssl') == 'on';
         $this->_bProrate = false;
-        $this->_sLogFile = BX_DIRECTORY_PATH_LOGS . 'bx_pp_' . $this->_sName . '.log';
 
         $this->_aIncludeJs = array(
         	'https://checkout.stripe.com/checkout.js',
@@ -65,6 +61,15 @@ class BxPaymentProviderStripe extends BxBaseModPaymentProvider implements iBxBas
         \Stripe\Stripe::setApiKey($this->_getSecretKey());
     }
 
+    public function setOptions($aOptions)
+    {
+    	parent::setOptions($aOptions);
+
+    	$this->_iMode = (int)$this->getOption('mode');
+    	$this->_bCheckAmount = $this->getOption('check_amount') == 'on';
+    	$this->_bUseSsl = $this->getOption('ssl') == 'on';
+    }
+
 	public function addJsCss()
     {
     	if(!$this->isActive())

+ 2 - 0
modules/boonex/payment/install/langs/en.xml

@@ -349,6 +349,8 @@
 	<string name="_bx_payment_cbee_test_site_dsc"><![CDATA[Your site name registered in Chargebee for 'test' mode]]></string>
 	<string name="_bx_payment_cbee_test_api_key_cpt"><![CDATA[API Key (test)]]></string>
 	<string name="_bx_payment_cbee_test_api_key_dsc"><![CDATA[Your Chargebee API Access key for 'test' mode]]></string>
+	<string name="_bx_payment_cbee_check_amount_cpt"><![CDATA[Enable amount checking]]></string>
+	<string name="_bx_payment_cbee_check_amount_dsc"><![CDATA[Enable amount checking for Chargebee Webhooks (recomended). However checking should be disabled when discounts and coupons are used.]]></string>
 	<string name="_bx_payment_cbee_ssl_cpt"><![CDATA[Enable SSL]]></string>
 	<string name="_bx_payment_cbee_ssl_dsc"><![CDATA[Enable SSL connection to communicate with Chargebee. Note. URLs below will be updated after saving.]]></string>
 	<string name="_bx_payment_cbee_return_data_url_cpt"><![CDATA[Data return URL]]></string>

+ 8 - 6
modules/boonex/payment/install/sql/install.sql

@@ -164,9 +164,10 @@ INSERT INTO `bx_payment_providers_options`(`provider_id`, `name`, `type`, `capti
 (@iProviderId, 'cbee_live_api_key', 'text', '_bx_payment_cbee_live_api_key_cpt', '_bx_payment_cbee_live_api_key_dsc', '', '', '', '', 4),
 (@iProviderId, 'cbee_test_site', 'text', '_bx_payment_cbee_test_site_cpt', '_bx_payment_cbee_test_site_dsc', '', '', '', '', 5),
 (@iProviderId, 'cbee_test_api_key', 'text', '_bx_payment_cbee_test_api_key_cpt', '_bx_payment_cbee_test_api_key_dsc', '', '', '', '', 6),
-(@iProviderId, 'cbee_ssl', 'checkbox', '_bx_payment_cbee_ssl_cpt', '_bx_payment_cbee_ssl_dsc', '', '', '', '', 7),
-(@iProviderId, 'cbee_return_data_url', 'value', '_bx_payment_cbee_return_data_url_cpt', '', '', '', '', '', 8),
-(@iProviderId, 'cbee_notify_url', 'value', '_bx_payment_cbee_notify_url_cpt', '', '', '', '', '', 9);
+(@iProviderId, 'cbee_check_amount', 'checkbox', '_bx_payment_cbee_check_amount_cpt', '_bx_payment_cbee_check_amount_dsc', '', '', '', '', 7),
+(@iProviderId, 'cbee_ssl', 'checkbox', '_bx_payment_cbee_ssl_cpt', '_bx_payment_cbee_ssl_dsc', '', '', '', '', 8),
+(@iProviderId, 'cbee_return_data_url', 'value', '_bx_payment_cbee_return_data_url_cpt', '', '', '', '', '', 9),
+(@iProviderId, 'cbee_notify_url', 'value', '_bx_payment_cbee_notify_url_cpt', '', '', '', '', '', 10);
 
 -- Chargebee V3 payment provider
 INSERT INTO `bx_payment_providers`(`name`, `caption`, `description`, `option_prefix`, `for_visitor`, `for_single`, `for_recurring`, `class_name`) VALUES
@@ -180,9 +181,10 @@ INSERT INTO `bx_payment_providers_options`(`provider_id`, `name`, `type`, `capti
 (@iProviderId, 'cbee_v3_live_api_key', 'text', '_bx_payment_cbee_live_api_key_cpt', '_bx_payment_cbee_live_api_key_dsc', '', '', '', '', 4),
 (@iProviderId, 'cbee_v3_test_site', 'text', '_bx_payment_cbee_test_site_cpt', '_bx_payment_cbee_test_site_dsc', '', '', '', '', 5),
 (@iProviderId, 'cbee_v3_test_api_key', 'text', '_bx_payment_cbee_test_api_key_cpt', '_bx_payment_cbee_test_api_key_dsc', '', '', '', '', 6),
-(@iProviderId, 'cbee_v3_ssl', 'checkbox', '_bx_payment_cbee_ssl_cpt', '_bx_payment_cbee_ssl_dsc', '', '', '', '', 7),
-(@iProviderId, 'cbee_v3_return_data_url', 'value', '_bx_payment_cbee_return_data_url_cpt', '', '', '', '', '', 8),
-(@iProviderId, 'cbee_v3_notify_url', 'value', '_bx_payment_cbee_notify_url_cpt', '', '', '', '', '', 9);
+(@iProviderId, 'cbee_v3_check_amount', 'checkbox', '_bx_payment_cbee_check_amount_cpt', '_bx_payment_cbee_check_amount_dsc', '', '', '', '', 7),
+(@iProviderId, 'cbee_v3_ssl', 'checkbox', '_bx_payment_cbee_ssl_cpt', '_bx_payment_cbee_ssl_dsc', '', '', '', '', 8),
+(@iProviderId, 'cbee_v3_return_data_url', 'value', '_bx_payment_cbee_return_data_url_cpt', '', '', '', '', '', 9),
+(@iProviderId, 'cbee_v3_notify_url', 'value', '_bx_payment_cbee_notify_url_cpt', '', '', '', '', '', 10);
 
 -- Recurly payment provider
 INSERT INTO `bx_payment_providers`(`name`, `caption`, `description`, `option_prefix`, `for_visitor`, `for_single`, `for_recurring`, `class_name`) VALUES

+ 2 - 0
modules/boonex/russian/data/langs/bx_payment/ru.xml

@@ -349,6 +349,8 @@
 	<string name="_bx_payment_cbee_test_site_dsc"><![CDATA[Имя вашего сайта зарегистрированного в Chargebee для "тестового" режима.]]></string>
 	<string name="_bx_payment_cbee_test_api_key_cpt"><![CDATA[API ключ (тестовый)]]></string>
 	<string name="_bx_payment_cbee_test_api_key_dsc"><![CDATA[Ваш API ключ доступа, предоставленный Chargebee, для "тестового" режима.]]></string>
+	<string name="_bx_payment_cbee_check_amount_cpt"><![CDATA[Активировать проверку суммы]]></string>
+	<string name="_bx_payment_cbee_check_amount_dsc"><![CDATA[Активировать проверку суммы для Chargebee Webhooks (рекомендуется). Однако проверка должна быть отключена когда используются скидки и купоны.]]></string>
 	<string name="_bx_payment_cbee_ssl_cpt"><![CDATA[Активировать SSL]]></string>
 	<string name="_bx_payment_cbee_ssl_dsc"><![CDATA[Активировать SSL соединение для связи с Chargebee. Внимание. Нижеприведенные ссылки будут обновлены после сохранения.]]></string>
 	<string name="_bx_payment_cbee_return_data_url_cpt"><![CDATA[URL для возврата данных]]></string>