Просмотр исходного кода

#2941 Payments: Integrate Apple In-App Purchase

Alex Trofimov 5 лет назад
Родитель
Сommit
05a6cb20ed

+ 25 - 0
inc/classes/BxDolPayments.php

@@ -125,6 +125,31 @@ class BxDolPayments extends BxDolFactory implements iBxDolSingleton
         return bx_srv($this->_sActive, 'get_provider_options', $aSrvParams);
     }
 
+    public function getModulesWithPayments()
+    {
+        if(empty($this->_sActive) || !BxDolRequest::serviceExists($this->_sActive, 'get_modules_with_payments'))
+            return false;
+
+        return bx_srv($this->_sActive, 'get_modules_with_payments', array());
+    }
+
+    public function getProductsNames($iVendor = 0, $iLimit = 1000)
+    {
+        $aRet = array();
+        $aModules = $this->getModulesWithPayments();
+        foreach ($aModules as $sModule) {
+            if(!BxDolRequest::serviceExists($sModule, 'get_products_names'))
+                continue;
+            $aKeys = bx_srv($sModule, 'get_products_names', array($iVendor, $iLimit));
+            if (!$aKeys)
+                continue;
+            $aValues = array_fill(0, count($aKeys), $sModule);
+            $aRet = array_merge($aRet, array_combine($aKeys, $aValues));
+        }
+
+        return $aRet;
+    }
+
     public function getPayments()
     {
         $aPayments = array(

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

@@ -20,6 +20,12 @@ class BxAclDb extends BxDolModuleDb
         $this->_oConfig = $oConfig;
     }
 
+    public function getProductsNames ($iVendor = 0, $iLimit = 1000)
+    {
+        $aBindings = array('limit' => $iLimit);
+        return $this->getColumn("SELECT `name` FROM `bx_acl_level_prices` WHERE 1 LIMIT :limit", $aBindings);
+    }
+
 	public function getLevels($aParams, $bReturnCount = false)
     {
         $aMethod = array('name' => 'getAll', 'params' => array(0 => 'query'));

+ 24 - 0
modules/boonex/acl/classes/BxAclModule.php

@@ -495,6 +495,30 @@ class BxAclModule extends BxDolModule
         });
     }
     
+    /**
+     * @page service Service Calls
+     * @section bx_acl Paid Levels
+     * @subsection bx_acl-other Other
+     * @subsubsection bx_acl-get_products_names get_products_names
+     * 
+     * @code bx_srv('bx_acl', 'get_products_names', [...]); @endcode
+     * 
+     * Get an array of products names.
+     * 
+     * @param $iVendorId return products of 1 vendor only
+     * @param $iLimit limit the result artay
+     * @return an array of products names
+     * 
+     * @see BxAclModule::serviceGetProductsNames
+     */
+    /** 
+     * @ref bx_acl-get_products_names "get_products_names"
+     */
+	public function serviceGetProductsNames($iVendorId = 0, $iLimit = 1000)
+    {
+    	return $this->_oDb->getProductsNames($iVendorId, $iLimit);
+    }
+
     protected function _serviceRegisterItem($iClientId, $iSellerId, $iItemId, $iItemCount, $sOrder, $sLicense, $sType)
     {
         $CNF = &$this->_oConfig->CNF;

+ 14 - 0
modules/boonex/market/classes/BxMarketDb.php

@@ -28,6 +28,20 @@ class BxMarketDb extends BxBaseModTextDb
         );
     }
 
+    public function getProductsNames ($iVendor = 0, $iLimit = 1000)
+    {
+        $CNF = &$this->_oConfig->CNF;
+
+        $sWhere = '';
+        $aBindings = array('limit' => $iLimit);
+        if ($iVendor) {
+            $aBindings['author'] = $iVendor;
+            $sWhere .= "AND `{$CNF['FIELD_AUTHOR']} = :author`";
+        }
+
+        return $this->getColumn("SELECT `{$CNF['FIELD_NAME']}` FROM `{$CNF['TABLE_ENTRIES']}` WHERE (`{$CNF['FIELD_PRICE_SINGLE']}` != '0' OR `{$CNF['FIELD_PRICE_RECURRING']}` != '0') $sWhere LIMIT :limit", $aBindings);
+    }
+    
     public function getContentInfoBy ($aParams)
     {
     	$CNF = &$this->_oConfig->CNF;

+ 24 - 0
modules/boonex/market/classes/BxMarketModule.php

@@ -487,6 +487,30 @@ class BxMarketModule extends BxBaseModTextModule
     	return $this->_oDb->getContentInfoBy($aParams);
     }
 
+    /**
+     * @page service Service Calls
+     * @section bx_market Market
+     * @subsection bx_market-browsing Browsing
+     * @subsubsection bx_market-get_products_names get_products_names
+     * 
+     * @code bx_srv('bx_market', 'get_products_names', [...]); @endcode
+     * 
+     * Get an array of products names.
+     * 
+     * @param $iVendorId return products of 1 vendor only
+     * @param $iLimit limit the result artay
+     * @return an array of products names
+     * 
+     * @see BxMarketModule::serviceGetProductsNames
+     */
+    /** 
+     * @ref bx_market-get_products_names "get_products_names"
+     */
+    public function serviceGetProductsNames($iVendorId, $iLimit = 1000)
+    {
+    	return $this->_oDb->getProductsNames($iVendorId, $iLimit);
+    }
+
     /**
      * @page service Service Calls
      * @section bx_market Market

+ 6 - 0
modules/boonex/payment/classes/BxPaymentDb.php

@@ -16,6 +16,12 @@ class BxPaymentDb extends BxBaseModPaymentDb
         parent::__construct($oConfig);
     }
 
+    public function getModulesWithPayments()
+    {
+    	$sQuery = $this->prepare("SELECT `name` FROM `" . $this->_sPrefix . "modules`");
+        return $this->getColumn($sQuery);
+    }
+
     /**
      * Payment details methods
      */

+ 22 - 0
modules/boonex/payment/classes/BxPaymentModule.php

@@ -170,6 +170,28 @@ class BxPaymentModule extends BxBaseModPaymentModule
         ));
     }
 
+    /**
+     * @page service Service Calls
+     * @section bx_payment Payment
+     * @subsection bx_payment-purchase_processing Purchase Processing
+     * @subsubsection bx_payment-get_modules_with_payments get_modules_with_payments
+     * 
+     * @code bx_srv('bx_payment', 'get_modules_with_payments', []); @endcode
+     * 
+     * Get modules with payments functionality
+     *
+     * @return array with modules names
+     * 
+     * @see BxPaymentModule::serviceGetModulesWithPayments
+     */
+    /** 
+     * @ref bx_payment-get_modules_with_payments "get_modules_with_payments"
+     */
+    public function serviceGetModulesWithPayments()
+    {
+        return $this->_oDb->getModulesWithPayments();
+    }
+
     /**
      * @page service Service Calls
      * @section bx_payment Payment