Kaynağa Gözat

Ticket #5021 - Payments: PayPal API integration doesn't pass the subscription price correctly.

AntonLV 1 yıl önce
ebeveyn
işleme
ac2ac2ce62

+ 1 - 0
modules/boonex/acl/classes/BxAclDb.php

@@ -101,6 +101,7 @@ class BxAclDb extends BxDolModuleDb
             `tap`.`price` AS `price`,
             `tap`.`trial` AS `trial`,
             `tap`.`immediate` AS `immediate`,
+            `tap`.`added` AS `added`,
             `tap`.`order` AS `order`";
 
         if(!isset($aParams['order']) || empty($aParams['order']))

+ 1 - 1
modules/boonex/acl/classes/BxAclGridAdministration.php

@@ -57,7 +57,7 @@ class BxAclGridAdministration extends BxAclGridLevels
             if(!empty($aPrice) && is_array($aPrice))
                 return echoJson(array('msg' => _t('_bx_acl_err_price_duplicate')));
 
-            $iId = (int)$oForm->insert(array('order' => $this->_oModule->_oDb->getPriceOrderMax($this->_iLevelId) + 1));
+            $iId = (int)$oForm->insert(array('added' => time(), 'order' => $this->_oModule->_oDb->getPriceOrderMax($this->_iLevelId) + 1));
             if($iId != 0) {
             	//TODO: May be we don't need to have this 'Purchasable' flag at all or at least we shouldn't update it from here.
                 $this->_oModule->_oDb->updateLevels(array('Purchasable' => 'yes'), array('ID' => $this->_iLevelId));

+ 2 - 1
modules/boonex/acl/classes/BxAclModule.php

@@ -221,7 +221,8 @@ class BxAclModule extends BxDolModule
             'price_recurring' => $aItem['price'],
             'period_recurring' => $aItem['period'],
             'period_unit_recurring' => $aItem['period_unit'],
-            'trial_recurring' => $aItem['trial']
+            'trial_recurring' => $aItem['trial'],
+            'added' => $aItem['added'],
         );
     }
 

+ 1 - 0
modules/boonex/acl/install/sql/install.sql

@@ -11,6 +11,7 @@ CREATE TABLE `bx_acl_level_prices` (
   `trial` int(11) unsigned NOT NULL default '0',
   `price` float unsigned NOT NULL default '1',
   `immediate` tinyint(4) NOT NULL default '1',
+  `added` int(11) NOT NULL default '0',
   `order` int(11) NOT NULL,
   PRIMARY KEY (`id`),
   UNIQUE KEY `name` (`name`),

+ 13 - 1
modules/boonex/payment/classes/BxPaymentProviderPayPalApi.php

@@ -332,9 +332,12 @@ class BxPaymentProviderPayPalApi extends BxBaseModPaymentProvider implements iBx
                 return $this->_sLangsPrefix . 'err_cannot_perform';
         }
 
-        $aProductPlan = array();
+        $aProductPlan = [];
 
         $aPlans = $this->_getPlans($aProduct['id']);
+        if(!$this->_validateProduct($aItem, $aProduct, $aPlans))
+            return $this->_sLangsPrefix . 'pp_api_err_wrong_item';
+
         if(!empty($aPlans)) 
             foreach($aPlans as $aPlan)
                 if(strcmp($aPlan['name'], $aItem['name']) == 0) {
@@ -439,6 +442,15 @@ class BxPaymentProviderPayPalApi extends BxBaseModPaymentProvider implements iBx
 
         return $mixedResult;
     }
+    
+    protected function _validateProduct($aItem, $aProduct, $aPlans)
+    {
+        //--- by date creation.
+        if(isset($aItem['added'], $aProduct['create_time']) && $aItem['added'] > strtotime($aProduct['create_time']))
+            return false;
+
+        return true;
+    }
 
     protected function _createPlan($sProductId, $aItem)
     {

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

@@ -522,6 +522,7 @@
     <string name="_bx_payment_pp_api_err_cannot_authorize"><![CDATA[Can't authorize the approved order.]]></string>
     <string name="_bx_payment_pp_api_err_cannot_capture"><![CDATA[Can't finalize checkout.]]></string>
     <string name="_bx_payment_pp_api_err_no_item"><![CDATA[There is nothing to subscribe.]]></string>
+    <string name="_bx_payment_pp_api_err_wrong_item"><![CDATA[The product you want to subscribe to has incorrect data on PayPal end. Please report.]]></string>
     <string name="_bx_payment_pp_api_err_no_subscription"><![CDATA[The subscription data isn't available or incorrect.]]></string>
     <string name="_bx_payment_pp_api_err_subscription_not_confirmed"><![CDATA[Subscription wasn't confirmed.]]></string>
     <string name="_bx_payment_pp_api_msg_authorized"><![CDATA[The order was successfully authorized.]]></string>

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

@@ -524,6 +524,7 @@
     <string name="_bx_payment_pp_api_err_cannot_authorize"><![CDATA[Не удалось авторизовать одобренный заказ.]]></string>
     <string name="_bx_payment_pp_api_err_cannot_capture"><![CDATA[Не удалось завершить оплату.]]></string>
     <string name="_bx_payment_pp_api_err_no_item"><![CDATA[Объект для создания подписки отсутствует.]]></string>
+    <string name="_bx_payment_pp_api_err_wrong_item"><![CDATA[Продукт, на который вы хотите подписаться, имеет неверные данные на стороне PayPal. Пожалуйста, сообщите.]]></string>
     <string name="_bx_payment_pp_api_err_no_subscription"><![CDATA[Данные подписки недоступны или неверны.]]></string>
     <string name="_bx_payment_pp_api_err_subscription_not_confirmed"><![CDATA[Подписка не подтверждена.]]></string>
     <string name="_bx_payment_pp_api_msg_authorized"><![CDATA[Заказ авторизован.]]></string>