Browse Source

Ticket #259 - Single Currency setting instead of pair Sign and Code.

AntonLV 10 years ago
parent
commit
d70dcc6717

+ 8 - 3
modules/base/payment/classes/BxBaseModPaymentConfig.php

@@ -23,6 +23,10 @@ class BxBaseModPaymentConfig extends BxBaseModGeneralConfig
     protected $_sAnimationEffect;
     protected $_iAnimationSpeed;
 
+    protected static $_aCurrencies = array(
+    	'AUD' => 'A$', 'CAD' => 'C$', 'EUR' => '€', 'GBP' => '£', 'USD' => '$', 'YEN' => '¥'
+    );
+
     function __construct($aModule)
     {
         parent::__construct($aModule);
@@ -70,8 +74,9 @@ class BxBaseModPaymentConfig extends BxBaseModGeneralConfig
     	
     	$sPrefix = $this->getPrefix('options');
         $this->_iSiteId = (int)$this->_oDb->getParam($sPrefix . 'site_admin');
-        $this->_sCurrencySign = $this->_oDb->getParam($sPrefix . 'default_currency_sign');
+
         $this->_sCurrencyCode = $this->_oDb->getParam($sPrefix . 'default_currency_code');
+        $this->_sCurrencySign = self::$_aCurrencies[$this->_sCurrencyCode];
     }
 
     public function getSiteId()
@@ -82,12 +87,12 @@ class BxBaseModPaymentConfig extends BxBaseModGeneralConfig
         return $this->_iSiteId;
     }
 
-    public function getCurrencySign()
+    public function getDefaultCurrencySign()
     {
         return $this->_sCurrencySign;
     }
 
-    public function getCurrencyCode()
+    public function getDefaultCurrencyCode()
     {
         return $this->_sCurrencyCode;
     }

+ 1 - 1
modules/base/payment/classes/BxBaseModPaymentGridCarts.php

@@ -25,7 +25,7 @@ class BxBaseModPaymentGridCarts extends BxTemplGrid
         $this->_oModule = BxDolModule::getInstance($this->MODULE);
         $this->_oCart = $this->_oModule->getObjectCart();
 
-        $this->_sCurrencySign = $this->_oModule->_oConfig->getCurrencySign();
+        $this->_sCurrencySign = $this->_oModule->_oConfig->getDefaultCurrencySign();
 
         $this->_sDefaultSortingOrder = 'DESC';
 

+ 1 - 1
modules/base/payment/classes/BxBaseModPaymentGridOrders.php

@@ -26,7 +26,7 @@ class BxBaseModPaymentGridOrders extends BxTemplGrid
         $this->_oModule = BxDolModule::getInstance($this->MODULE);
 
         $this->_sLangsPrefix = $this->_oModule->_oConfig->getPrefix('langs');
-        $this->_sCurrencySign = $this->_oModule->_oConfig->getCurrencySign();
+        $this->_sCurrencySign = $this->_oModule->_oConfig->getDefaultCurrencySign();
 
         $this->_sDefaultSortingOrder = 'DESC';
 

+ 8 - 4
modules/base/payment/classes/BxBaseModPaymentModule.php

@@ -39,13 +39,17 @@ class BxBaseModPaymentModule extends BxDolModule
     public function serviceGetCurrencyInfo()
     {
         return array(
-            'sign' => $this->_oConfig->getCurrencySign(),
-            'code' => $this->_oConfig->getCurrencyCode()
+            'sign' => $this->_oConfig->getDefaultCurrencySign(),
+            'code' => $this->_oConfig->getDefaultCurrencyCode()
         );
     }
 
 	public function serviceGetOption($sOption)
     {
+    	$sMethod = 'get' . bx_gen_method_name($sOption);
+    	if(method_exists($this->_oConfig, $sMethod))
+    		return $this->_oConfig->$sMethod();
+
     	return $this->_oDb->getParam($this->_oConfig->getPrefix('options') . $sOption);
     }
 
@@ -66,8 +70,8 @@ class BxBaseModPaymentModule extends BxDolModule
 	public function getVendorInfo($iUserId)
     {
         return array_merge($this->getProfileInfo($iUserId), array(
-        	'currency_code' => $this->_oConfig->getCurrencyCode(),
-			'currency_sign' => $this->_oConfig->getCurrencySign()
+        	'currency_code' => $this->_oConfig->getDefaultCurrencyCode(),
+			'currency_sign' => $this->_oConfig->getDefaultCurrencySign()
         ));
     }
 

+ 1 - 1
modules/boonex/payment/classes/BxPaymentProviderChargebee.php

@@ -237,7 +237,7 @@ class BxPaymentProviderChargebee extends BxBaseModPaymentProvider implements iBx
 
 		$fTransactionAmount = (float)$aTransaction['amount'] / 100;
 		$sTransactionCurrency = strtoupper($aTransaction['currency_code']);
-		if($this->_bCheckAmount && ((float)$aPending['amount'] != $fTransactionAmount || strcasecmp($this->_oModule->_oConfig->getCurrencyCode(), $sTransactionCurrency) != 0))
+		if($this->_bCheckAmount && ((float)$aPending['amount'] != $fTransactionAmount || strcasecmp($this->_oModule->_oConfig->getDefaultCurrencyCode(), $sTransactionCurrency) != 0))
 			return false;
 
 		return $this->_oModule->registerPayment($aPending);

+ 1 - 1
modules/boonex/payment/classes/BxPaymentProviderRecurly.php

@@ -281,7 +281,7 @@ class BxPaymentProviderRecurly extends BxBaseModPaymentProvider implements iBxBa
 
 		$fTransactionAmount = (float)$aTransaction['amount'] / 100;
 		$sTransactionCurrency = strtoupper($aTransaction['currency_code']);
-		if($this->_bCheckAmount && ((float)$aPending['amount'] != $fTransactionAmount || strcasecmp($this->_oModule->_oConfig->getCurrencyCode(), $sTransactionCurrency) != 0))
+		if($this->_bCheckAmount && ((float)$aPending['amount'] != $fTransactionAmount || strcasecmp($this->_oModule->_oConfig->getDefaultCurrencyCode(), $sTransactionCurrency) != 0))
 			return false;
 
 		return $this->_oModule->registerPayment($aPending);

+ 1 - 3
modules/boonex/payment/install/langs/en.xml

@@ -3,10 +3,8 @@
 	<string name="_bx_payment"><![CDATA[Payments]]></string>
 
 	<!-- OPTIONS -->
-	<string name="_bx_payment_option_default_currency_code"><![CDATA[Currency code]]></string>
+	<string name="_bx_payment_option_default_currency_code"><![CDATA[Currency]]></string>
 	<string name="_bx_payment_option_err_default_currency_code"><![CDATA[Currency code cannot be empty.]]></string>
-	<string name="_bx_payment_option_default_currency_sign"><![CDATA[Currency sign]]></string>
-	<string name="_bx_payment_option_err_default_currency_sign"><![CDATA[Currency sign cannot be empty.]]></string>	
 	<string name="_bx_payment_option_site_admin"><![CDATA[Site administrator]]></string>
 
 	<!-- PAGES and BLOCKS -->

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

@@ -13,8 +13,7 @@ SET @iCategoryId = LAST_INSERT_ID();
 
 INSERT INTO `sys_options` (`name`, `value`, `category_id`, `caption`, `type`, `check`, `check_params`, `check_error`, `extra`, `order`) VALUES
 ('bx_payment_default_currency_code', 'USD', @iCategoryId, '_bx_payment_option_default_currency_code', 'select', 'Avail', '', '_bx_payment_option_err_default_currency_code', 'AUD,CAD,EUR,GBP,USD,YEN', 0),
-('bx_payment_default_currency_sign', '&#36;', @iCategoryId, '_bx_payment_option_default_currency_sign', 'digit', 'Avail', '', '_bx_payment_option_err_default_currency_sign', '', 1),
-('bx_payment_site_admin', '', @iCategoryId, '_bx_payment_option_site_admin', 'select', '', '', '', 'a:2:{s:6:"module";s:10:"bx_payment";s:6:"method";s:22:"get_options_site_admin";}', 2);
+('bx_payment_site_admin', '', @iCategoryId, '_bx_payment_option_site_admin', 'select', '', '', '', 'a:2:{s:6:"module";s:10:"bx_payment";s:6:"method";s:22:"get_options_site_admin";}', 1);
 
 
 -- PAGES & BLOCKS

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

@@ -5,8 +5,6 @@
 	<!-- OPTIONS -->
 	<string name="_bx_payment_option_default_currency_code"><![CDATA[Код валюты]]></string>
 	<string name="_bx_payment_option_err_default_currency_code"><![CDATA[Код валюты не может быть пуст.]]></string>
-	<string name="_bx_payment_option_default_currency_sign"><![CDATA[Знак валюты]]></string>
-	<string name="_bx_payment_option_err_default_currency_sign"><![CDATA[Знак валюты не может быть пуст.]]></string>	
 	<string name="_bx_payment_option_site_admin"><![CDATA[Администратор сайта]]></string>
 
 	<!-- PAGES and BLOCKS -->