BxPaymentModule.php 41 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074
  1. <?php defined('BX_DOL') or die('hack attempt');
  2. /**
  3. * Copyright (c) UNA, Inc - https://una.io
  4. * MIT License - https://opensource.org/licenses/MIT
  5. *
  6. * @defgroup Payment Payment
  7. * @ingroup UnaModules
  8. *
  9. * @{
  10. */
  11. define('BX_PAYMENT_ORDERS_TYPE_PENDING', 'pending');
  12. define('BX_PAYMENT_ORDERS_TYPE_PROCESSED', 'processed');
  13. define('BX_PAYMENT_ORDERS_TYPE_SUBSCRIPTION', 'subscription');
  14. define('BX_PAYMENT_ORDERS_TYPE_HISTORY', 'history');
  15. define('BX_PAYMENT_RESULT_SUCCESS', 0);
  16. define('BX_PAYMENT_SBS_STATUS_SCHEDULED', 'scheduled');
  17. define('BX_PAYMENT_SBS_STATUS_TRIAL', 'trial');
  18. define('BX_PAYMENT_SBS_STATUS_ACTIVE', 'active');
  19. define('BX_PAYMENT_SBS_STATUS_UNPAID', 'unpaid');
  20. define('BX_PAYMENT_SBS_STATUS_PAUSED', 'paused');
  21. define('BX_PAYMENT_SBS_STATUS_CANCELED', 'canceled');
  22. define('BX_PAYMENT_SBS_STATUS_UNKNOWN', 'unknown');
  23. /**
  24. * Payment module by BoonEx
  25. *
  26. * This module is needed to work with payment providers and organize the process
  27. * of some item purchasing. Shopping Cart and Orders Manager are included.
  28. *
  29. * Integration notes:
  30. * To integrate your module with this one, you need:
  31. * 1. Get 'Add To Cart' button using serviceGetAddToCartLink service.
  32. * 2. Add info about your module in the 'bx_pmt_modules' table.
  33. * 3. Realize the following service methods in your Module class.
  34. * a. serviceGetItems($iSellerId) - Is used in Orders Administration to get all products of the requested seller(vendor).
  35. * b. serviceGetCartItem($iClientId, $iItemId) - Is used in Shopping Cart to get one product by specified id.
  36. * c. serviceRegisterCartItem($iClientId, $iSellerId, $iItemId, $iItemCount, $sOrderId) - Register purchased product.
  37. * d. serviceUnregisterCartItem($iClientId, $iSellerId, $iItemId, $iItemCount, $sOrderId) - Unregister the product purchased earlier.
  38. * @see You may see an example of integration in Membership module.
  39. *
  40. *
  41. * Profile's Wall:
  42. * no spy events
  43. *
  44. *
  45. *
  46. * Spy:
  47. * no spy events
  48. *
  49. *
  50. *
  51. * Memberships/ACL:
  52. * Doesn't depend on user's membership.
  53. *
  54. *
  55. *
  56. * Service methods:
  57. *
  58. * Is used to get "Add to cart" link for some item(s) in your module.
  59. * @see BxPmtModule::serviceGetAddToCartLink
  60. * BxDolService::call('payment', 'get_add_to_cart_link', array($iSellerId, $mixedModuleId, $iItemId, $iItemCount));
  61. *
  62. * Check transaction(s) in database which satisty all conditions.
  63. * @see BxPmtModule::serviceGetOrdersInfo
  64. * BxDolService::call('payment', 'get_orders_info', array($aConditions), 'Orders');
  65. *
  66. * Get total count of items in Shopping Cart.
  67. * @see BxPmtModule::serviceGetCartItemsCount
  68. * BxDolService::call('payment', 'get_cart_items_count', array($iUserId, $iOldCount));
  69. * @note is needed for internal usage(integration with member tool bar).
  70. *
  71. * Get Shopping cart content.
  72. * @see BxPmtModule::serviceGetCartItems
  73. * BxDolService::call('payment', 'get_cart_items');
  74. * @note is needed for internal usage(integration with member tool bar).
  75. *
  76. *
  77. * Alerts:
  78. * no alerts available
  79. *
  80. */
  81. class BxPaymentModule extends BxBaseModPaymentModule
  82. {
  83. protected $_iUserId;
  84. protected $_aOrderTypes;
  85. function __construct($aModule)
  86. {
  87. parent::__construct($aModule);
  88. $this->_iUserId = $this->getProfileId();
  89. $this->_aOrderTypes = array(
  90. BX_PAYMENT_ORDERS_TYPE_PENDING,
  91. BX_PAYMENT_ORDERS_TYPE_PROCESSED,
  92. BX_PAYMENT_ORDERS_TYPE_SUBSCRIPTION,
  93. BX_PAYMENT_ORDERS_TYPE_HISTORY
  94. );
  95. }
  96. /**
  97. * Manage Orders Methods
  98. */
  99. public function actionGetClients()
  100. {
  101. $sTerm = bx_get('term');
  102. $aResult = BxDolService::call('system', 'profiles_search', array($sTerm), 'TemplServiceProfiles');
  103. echoJson($aResult);
  104. }
  105. public function actionGetItems($sType, $iModuleId)
  106. {
  107. $iSellerId = $this->getProfileId();
  108. $aItems = $this->callGetCartItems((int)$iModuleId, array($iSellerId));
  109. echoJson(array(
  110. 'code' => 0,
  111. 'eval' => $this->_oConfig->getJsObject('processed') . '.onSelectModule(oData);',
  112. 'data' => $this->_oTemplate->displayItems($sType, $aItems)
  113. ));
  114. }
  115. public function serviceGetSafeServices()
  116. {
  117. $a = parent::serviceGetSafeServices();
  118. return array_merge($a, array (
  119. 'GetBlockJoin' => 'BxPaymentJoin',
  120. 'GetBlockCarts' => 'BxPaymentCart',
  121. 'GetBlockCart' => 'BxPaymentCart',
  122. 'GetBlockCartHistory' => 'BxPaymentCart',
  123. 'GetBlockListMy' => 'BxPaymentSubscriptions',
  124. 'GetBlockHistory' => 'BxPaymentSubscriptions',
  125. ));
  126. }
  127. /**
  128. * @page service Service Calls
  129. * @section bx_payment Payment
  130. * @subsection bx_payment-purchase_processing Purchase Processing
  131. * @subsubsection bx_payment-is_accepting_payments is_accepting_payments
  132. *
  133. * @code bx_srv('bx_payment', 'is_accepting_payments', [...]); @endcode
  134. *
  135. * Check whether the specified vendor has a configured payment provider or not.
  136. *
  137. * @param $iVendorId integer value with vendor ID.
  138. * @param $sPaymentType (optional) string value with payment type. If specified then the vendor will be checked for having the payment provider of the requested type.
  139. * @return boolean value determining the result of checking.
  140. *
  141. * @see BxPaymentModule::serviceIsAcceptingPayments
  142. */
  143. /**
  144. * @ref bx_payment-is_accepting_payments "is_accepting_payments"
  145. */
  146. public function serviceIsAcceptingPayments($iVendorId, $sPaymentType = '')
  147. {
  148. $bResult = false;
  149. switch($sPaymentType) {
  150. case BX_PAYMENT_TYPE_SINGLE:
  151. $aProvidersCart = $this->_oDb->getVendorInfoProvidersSingle($iVendorId);
  152. $bResult = !empty($aProvidersCart);
  153. break;
  154. case BX_PAYMENT_TYPE_RECURRING:
  155. $aProvidersSubscription = $this->_oDb->getVendorInfoProvidersRecurring($iVendorId);
  156. $bResult = !empty($aProvidersSubscription);
  157. break;
  158. default:
  159. $aProviders = $this->_oDb->getVendorInfoProviders($iVendorId);
  160. $bResult = !empty($aProviders);
  161. }
  162. return $bResult;
  163. }
  164. /**
  165. * @deprecated since version 11.0.0
  166. *
  167. * @see BxPaymentModule::serviceIsProviderOptions
  168. */
  169. public function serviceIsPaymentProvider($iVendorId, $sVendorProvider, $sPaymentType = '')
  170. {
  171. return $this->serviceIsProviderOptions($iVendorId, $sVendorProvider, $sPaymentType);
  172. }
  173. /**
  174. * @deprecated since version 11.0.0
  175. *
  176. * @see BxPaymentModule::serviceGetProviderOptions
  177. */
  178. public function serviceGetPaymentProvider($iVendorId, $sVendorProvider, $sPaymentType = '')
  179. {
  180. return $this->serviceGetProviderOptions($iVendorId, $sVendorProvider, $sPaymentType);
  181. }
  182. /**
  183. * @page service Service Calls
  184. * @section bx_payment Payment
  185. * @subsection bx_payment-purchase_processing Purchase Processing
  186. * @subsubsection bx_payment-is_provider_options is_provider_options
  187. *
  188. * @code bx_srv('bx_payment', 'is_provider_options', [...]); @endcode
  189. *
  190. * Check whether the specified vendor has configured the specified payment provider or not.
  191. *
  192. * @param $iVendorId integer value with vendor ID.
  193. * @param $sVendorProvider string value with payment provider name.
  194. * @param $sPaymentType (optional) string value with payment type. If specified then the vendor will be checked for having the payment provider of the requested type.
  195. * @return boolean value determining the result of checking.
  196. *
  197. * @see BxPaymentModule::serviceIsProviderOptions
  198. */
  199. /**
  200. * @ref bx_payment-is_provider_options "is_provider_options"
  201. */
  202. public function serviceIsProviderOptions($iVendorId, $sVendorProvider, $sPaymentType = '')
  203. {
  204. $aProvider = $this->serviceGetProviderOptions($iVendorId, $sVendorProvider, $sPaymentType);
  205. return $aProvider !== false;
  206. }
  207. /**
  208. * @page service Service Calls
  209. * @section bx_payment Payment
  210. * @subsection bx_payment-purchase_processing Purchase Processing
  211. * @subsubsection bx_payment-get_provider_options get_provider_options
  212. *
  213. * @code bx_srv('bx_payment', 'get_provider_options', [...]); @endcode
  214. *
  215. * Get configuration settings for the payment provider entered by the specified vendor.
  216. *
  217. * @param $iVendorId integer value with vendor ID.
  218. * @param $sVendorProvider string value with payment provider name.
  219. * @param $sPaymentType (optional) string value with payment type. If specified then the vendor will be checked for having the payment provider of the requested type.
  220. * @return an array with special format describing the payment provider or false value if something is wrong.
  221. *
  222. * @see BxPaymentModule::serviceGetProviderOptions
  223. */
  224. /**
  225. * @ref bx_payment-get_provider_options "get_provider_options"
  226. */
  227. public function serviceGetProviderOptions($iVendorId, $sVendorProvider, $sPaymentType = '')
  228. {
  229. $aProviders = array();
  230. switch($sPaymentType) {
  231. case BX_PAYMENT_TYPE_SINGLE:
  232. $aProviders = $this->_oDb->getVendorInfoProvidersSingle($iVendorId);
  233. break;
  234. case BX_PAYMENT_TYPE_RECURRING:
  235. $aProviders = $this->_oDb->getVendorInfoProvidersRecurring($iVendorId);
  236. break;
  237. default:
  238. $aProviders = $this->_oDb->getVendorInfoProviders($iVendorId);
  239. }
  240. return !empty($aProviders) && !empty($aProviders[$sVendorProvider]) && is_array(($aProviders[$sVendorProvider])) ? $aProviders[$sVendorProvider] : false;
  241. }
  242. /**
  243. * @page service Service Calls
  244. * @section bx_payment Payment
  245. * @subsection bx_payment-other Other
  246. * @subsubsection bx_payment-get_options_default_currency_code get_options_default_currency_code
  247. *
  248. * @code bx_srv('bx_payment', 'get_options_default_currency_code', [...]); @endcode
  249. *
  250. * Get an array with available currencies. Is used in forms.
  251. *
  252. * @return an array with available currencies represented as key => value pairs.
  253. *
  254. * @see BxPaymentModule::serviceGetOptionsDefaultCurrencyCode
  255. */
  256. /**
  257. * @ref bx_payment-get_options_default_currency_code "get_options_default_currency_code"
  258. */
  259. public function serviceGetOptionsDefaultCurrencyCode()
  260. {
  261. $CNF = &$this->_oConfig->CNF;
  262. $aCurrencies = BxDolForm::getDataItems($CNF['OBJECT_FORM_PRELISTS_CURRENCIES']);
  263. $aResult = array();
  264. foreach($aCurrencies as $sKey => $sValue)
  265. $aResult[] = array(
  266. 'key' => $sKey,
  267. 'value' => $sValue
  268. );
  269. return $aResult;
  270. }
  271. /**
  272. * @page service Service Calls
  273. * @section bx_payment Payment
  274. * @subsection bx_payment-other Other
  275. * @subsubsection bx_payment-get_options_site_admin get_options_site_admin
  276. *
  277. * @code bx_srv('bx_payment', 'get_options_site_admin', [...]); @endcode
  278. *
  279. * Get an array with profiles which can be used as 'Site Admin (Owner)'. 'Site Admin' is a person who will be displayed to buyers when something is selling on behalf of the site.
  280. *
  281. * @return an array with profiles represented as key => value pairs.
  282. *
  283. * @see BxPaymentModule::serviceGetOptionsSiteAdmin
  284. */
  285. /**
  286. * @ref bx_payment-get_options_site_admin "get_options_site_admin"
  287. */
  288. public function serviceGetOptionsSiteAdmin()
  289. {
  290. $aResult = array(
  291. array('key' => '', 'value' => _t('_Select_one'))
  292. );
  293. $aIds = $this->_oDb->getAdminsIds();
  294. foreach($aIds as $iId) {
  295. $aUser = $this->getProfileInfo($iId);
  296. $aResult[] = array(
  297. 'key' => $iId,
  298. 'value' => $aUser['name']
  299. );
  300. }
  301. return $aResult;
  302. }
  303. /**
  304. * Cart Processing Methods
  305. */
  306. public function actionAddToCart($iSellerId, $iModuleId, $iItemId, $iItemCount, $sCustom = '')
  307. {
  308. if(empty($sCustom) && bx_get('custom') !== false)
  309. $sCustom = bx_process_input(bx_get('custom'));
  310. $aCustom = array();
  311. if(!empty($sCustom)) {
  312. $aCustom = unserialize(base64_decode($sCustom));
  313. if(empty($aCustom) || !is_array($aCustom))
  314. $aCustom = array();
  315. }
  316. $aResult = $this->getObjectCart()->serviceAddToCart($iSellerId, $iModuleId, $iItemId, $iItemCount, $aCustom);
  317. echoJson($aResult);
  318. }
  319. /**
  320. * Isn't used yet.
  321. */
  322. public function actionDeleteFromCart($iSellerId, $iModuleId, $iItemId)
  323. {
  324. $aResult = $this->getObjectCart()->serviceDeleteFromCart($iSellerId, $iModuleId, $iItemId);
  325. echoJson($aResult);
  326. }
  327. /**
  328. * Isn't used yet.
  329. */
  330. public function actionEmptyCart($iSellerId)
  331. {
  332. $aResult = $this->getObjectCart()->serviceDeleteFromCart($iSellerId);
  333. echoJson($aResult);
  334. }
  335. public function actionSubscribe()
  336. {
  337. $iSellerId = bx_process_input(bx_get('seller_id'), BX_DATA_INT);
  338. $sSellerProvider = bx_process_input(bx_get('seller_provider'));
  339. $iModuleId = bx_process_input(bx_get('module_id'), BX_DATA_INT);
  340. $iItemId = bx_process_input(bx_get('item_id'), BX_DATA_INT);
  341. $iItemCount = bx_process_input(bx_get('item_count'), BX_DATA_INT);
  342. if(empty($iItemCount))
  343. $iItemCount = 1;
  344. $sRedirect = bx_process_input(bx_get('redirect'));
  345. $sCustom = bx_process_input(bx_get('custom'));
  346. $aCustom = array();
  347. if(!empty($sCustom)) {
  348. $aCustom = unserialize(base64_decode($sCustom));
  349. if(empty($aCustom) || !is_array($aCustom))
  350. $aCustom = array();
  351. }
  352. $aResult = $this->getObjectSubscriptions()->serviceSubscribe($iSellerId, $sSellerProvider, $iModuleId, $iItemId, $iItemCount, $sRedirect, $aCustom);
  353. $bRedirect = !empty($aResult['redirect']);
  354. if(!empty($aResult['popup'])) {
  355. $sContent = '';
  356. $sContent .= $this->_oTemplate->displayCartJs(BX_PAYMENT_TYPE_RECURRING, $iSellerId);
  357. $sContent .= !empty($aResult['popup']['html']) ? $aResult['popup']['html'] : $aResult['popup'];
  358. return $this->_oTemplate->displayPageCodeResponse($sContent, false, true);
  359. }
  360. if(!empty($aResult['code']))
  361. return $this->_oTemplate->displayPageCodeError($aResult['message']);
  362. if(!empty($aResult['message']) && !$bRedirect)
  363. return $this->_oTemplate->displayPageCodeResponse($aResult['message']);
  364. if($bRedirect) {
  365. header('Location: ' . $aResult['redirect']);
  366. exit;
  367. }
  368. }
  369. public function actionSubscribeJson()
  370. {
  371. $iSellerId = bx_process_input(bx_get('seller_id'), BX_DATA_INT);
  372. $sSellerProvider = bx_process_input(bx_get('seller_provider'));
  373. $iModuleId = bx_process_input(bx_get('module_id'), BX_DATA_INT);
  374. $iItemId = bx_process_input(bx_get('item_id'), BX_DATA_INT);
  375. $iItemCount = bx_process_input(bx_get('item_count'), BX_DATA_INT);
  376. if(empty($iItemCount))
  377. $iItemCount = 1;
  378. $sItemAddons = array();
  379. if(bx_get('item_addons') !== false) {
  380. $sItemAddons = bx_process_input(bx_get('item_addons'));
  381. if(is_array($sItemAddons))
  382. $sItemAddons = $this->_oConfig->a2s($sItemAddons);
  383. }
  384. $sRedirect = bx_process_input(bx_get('redirect'));
  385. $sCustom = bx_process_input(bx_get('custom'));
  386. $aCustom = array();
  387. if(!empty($sCustom)) {
  388. $aCustom = unserialize(base64_decode($sCustom));
  389. if(empty($aCustom) || !is_array($aCustom))
  390. $aCustom = array();
  391. }
  392. $aResult = $this->getObjectSubscriptions()->serviceSubscribeWithAddons($iSellerId, $sSellerProvider, $iModuleId, $iItemId, $iItemCount, $sItemAddons, $sRedirect, $aCustom);
  393. echoJson($aResult);
  394. }
  395. public function actionSubscriptionGetDetails($iId)
  396. {
  397. $aResult = $this->_oTemplate->displaySubscriptionGetDetails($iId);
  398. echoJson($aResult);
  399. }
  400. public function actionSubscriptionChangeDetails($iId)
  401. {
  402. $aResult = $this->_oTemplate->displaySubscriptionChangeDetails($iId);
  403. echoJson($aResult);
  404. }
  405. public function actionSubscriptionGetBilling($iId)
  406. {
  407. $aResult = $this->_oTemplate->displaySubscriptionGetBilling($iId);
  408. echoJson($aResult);
  409. }
  410. public function actionSubscriptionChangeBilling($iId)
  411. {
  412. $aResult = $this->_oTemplate->displaySubscriptionChangeBilling($iId);
  413. echoJson($aResult);
  414. }
  415. public function actionSubscriptionCancelation($iId)
  416. {
  417. $aResult = array('code' => 1, 'message' => _t('_bx_payment_err_cannot_perform'));
  418. $aPending = $this->_oDb->getOrderPending(array('type' => 'id', 'id' => $iId));
  419. if(empty($aPending) || !is_array($aPending))
  420. return echoJson($aResult);
  421. $aSubscription = $this->_oDb->getSubscription(array('type' => 'pending_id', 'pending_id' => $iId));
  422. if(empty($aSubscription) || !is_array($aSubscription))
  423. return echoJson($aResult);
  424. $oRecipient = BxDolProfile::getInstance((int)$aPending['seller_id']);
  425. if(!$oRecipient)
  426. return echoJson($aResult);
  427. $mixedResult = $this->isAllowedManage($aPending);
  428. if($mixedResult !== true)
  429. return echoJson(array('code' => 2, 'message' => $mixedResult));
  430. $aTemplate = BxDolEmailTemplates::getInstance()->parseTemplate($this->_oConfig->getPrefix('general') . 'cancelation_request', array(
  431. 'sibscription_id' => $aSubscription['subscription_id'],
  432. 'sibscription_customer' => $aSubscription['customer_id'],
  433. 'sibscription_date' => bx_time_js($aSubscription['date'], BX_FORMAT_DATE, true)
  434. ), 0, (int)$aPending['client_id']);
  435. $sEmail = '';
  436. $oProvider = $this->getObjectProvider($aPending['provider'], $aPending['seller_id']);
  437. if($oProvider !== false && $oProvider->isActive())
  438. $sEmail = $oProvider->getOption('cancellation_email');
  439. if(empty($sEmail))
  440. $sEmail = $oRecipient->getAccountObject()->getEmail();
  441. if(!sendMail($sEmail, $aTemplate['Subject'], $aTemplate['Body'], 0, array(), BX_EMAIL_SYSTEM))
  442. return echoJson($aResult);
  443. echoJson(array('code' => 0, 'message' => _t('_bx_payment_msg_cancelation_request_sent')));
  444. }
  445. public function actionSubscriptionCancel($iId, $mixedGridObject = false)
  446. {
  447. $aResult = array('code' => 1, 'message' => _t('_bx_payment_err_cannot_perform'));
  448. $aPending = $this->_oDb->getOrderPending(array('type' => 'id', 'id' => $iId));
  449. if(empty($aPending) || !is_array($aPending))
  450. return echoJson($aResult);
  451. $mixedResult = $this->isAllowedManage($aPending);
  452. if($mixedResult !== true)
  453. return echoJson(array('code' => 2, 'message' => $mixedResult));
  454. if(!$this->getObjectSubscriptions()->cancel($iId))
  455. return echoJson($aResult);
  456. if(empty($mixedGridObject) && bx_get('grid') !== false)
  457. $mixedGridObject = bx_process_input(bx_get('grid'));
  458. if(!empty($mixedGridObject) && $aPending['client_id'] == $this->getProfileId()) {
  459. $oGrid = BxDolGrid::getObjectInstance($mixedGridObject, $this->_oTemplate);
  460. $oGrid->addQueryParam('client_id', $aPending['client_id']);
  461. return echoJson(array('object' => $mixedGridObject, 'grid' => $oGrid->getCode(false), 'blink' => array($iId)));
  462. }
  463. else
  464. return echoJson(array('code' => 0, 'message' => _t('_bx_payment_msg_successfully_performed')));
  465. }
  466. /**
  467. * Payment Processing Methods
  468. */
  469. public function actionInitializeCheckout($sType)
  470. {
  471. if(!$this->isLogged())
  472. return $this->_oTemplate->displayPageCodeError($this->_sLangsPrefix . 'err_required_login');
  473. if(bx_get('seller_id') !== false && bx_get('provider') !== false && bx_get('items') !== false) {
  474. $iSellerId = bx_process_input(bx_get('seller_id'), BX_DATA_INT);
  475. $sProvider = bx_process_input(bx_get('provider'));
  476. $aItems = bx_process_input(bx_get('items'));
  477. $mixedResult = $this->serviceInitializeCheckout(BX_PAYMENT_TYPE_SINGLE, $iSellerId, $sProvider, $aItems);
  478. if($mixedResult !== true)
  479. return $this->_oTemplate->displayPageCodeError($mixedResult);
  480. }
  481. header('Location: ' . $this->_oConfig->getUrl('URL_CART'));
  482. exit;
  483. }
  484. /**
  485. * @page service Service Calls
  486. * @section bx_payment Payment
  487. * @subsection bx_payment-purchase_processing Purchase Processing
  488. * @subsubsection bx_payment-initialize_checkout initialize_checkout
  489. *
  490. * @code bx_srv('bx_payment', 'initialize_checkout', [...]); @endcode
  491. *
  492. * Initialize the checkout process.
  493. *
  494. * @param $sType string value with payment type (single or recurring).
  495. * @param $iSellerId integer value with seller ID.
  496. * @param $sProvider string value with payment provider name.
  497. * @param $aItems (optional) an array with items to be purchased.
  498. * @param $sRedirect (optional) string value with redirect URL if it's needed.
  499. * @param $aCustom (optional) array with custom data to attach to a payment.
  500. * @return the result depends on the payment provider which is used for processing or represented as string value with error message if something is wrong.
  501. *
  502. * @see BxPaymentModule::serviceInitializeCheckout
  503. */
  504. /**
  505. * @ref bx_payment-initialize_checkout "initialize_checkout"
  506. */
  507. public function serviceInitializeCheckout($sType, $iSellerId, $sProvider, $aItems = array(), $sRedirect = '', $aCustoms = array())
  508. {
  509. $bTypeSingle = $sType == BX_PAYMENT_TYPE_SINGLE;
  510. $bTypeRecurring = $sType == BX_PAYMENT_TYPE_RECURRING;
  511. if(!is_array($aItems))
  512. $aItems = array($aItems);
  513. $iSellerId = (int)$iSellerId;
  514. if($iSellerId == BX_PAYMENT_EMPTY_ID)
  515. return $this->_sLangsPrefix . 'err_unknown_vendor';
  516. $oProvider = $this->getObjectProvider($sProvider, $iSellerId);
  517. if($oProvider === false || !$oProvider->isActive())
  518. return $this->_sLangsPrefix . 'err_incorrect_provider';
  519. $aInfo = $this->getObjectCart()->getInfo($sType, $this->_iUserId, $iSellerId, $aItems);
  520. if(empty($aInfo) || $aInfo['vendor_id'] == BX_PAYMENT_EMPTY_ID || empty($aInfo['items']))
  521. return $this->_sLangsPrefix . 'err_empty_order';
  522. /*
  523. * Process FREE (price = 0) items for LOGGED IN members
  524. * WITHOUT processing via payment provider.
  525. * Note. This section isn't used for now!
  526. */
  527. $bProcessedFree = false;
  528. $sKeyPriceSingle = $this->_oConfig->getKey('KEY_ARRAY_PRICE_SINGLE');
  529. $sKeyPriceRecurring = $this->_oConfig->getKey('KEY_ARRAY_PRICE_RECURRING');
  530. foreach($aInfo['items'] as $iIndex => $aItem) {
  531. if((int)$aInfo['client_id'] == 0)
  532. continue;
  533. //--- For Single time payments.
  534. if($bTypeSingle && (float)$aItem[$sKeyPriceSingle] == 0) {
  535. $aCart = $this->_oDb->getCartContent($aInfo['client_id']);
  536. $aCartCustoms = !empty($aCart['customs']) ? unserialize($aCart['customs']) : array();
  537. $aCartItem = array($aInfo['vendor_id'], $aItem['module_id'], $aItem['id'], $aItem['quantity']);
  538. $aCartItemCustom = $this->_oConfig->pullCustom($aCartItem, $aCartCustoms);
  539. $aItemInfo = $this->callRegisterCartItem((int)$aItem['module_id'], array($aInfo['client_id'], $aInfo['vendor_id'], $aItem['id'], $aItem['quantity'], $this->_oConfig->getLicense(), $aCartItemCustom));
  540. if(!empty($aItemInfo) && is_array($aItemInfo)) {
  541. if(!empty($aItemInfo['addons']) && is_array($aItemInfo['addons']))
  542. foreach($aItemInfo['addons'] as $sAddon => $aAddon)
  543. $this->callRegisterCartItem((int)$aAddon['module_id'], array($aInfo['client_id'], $aInfo['vendor_id'], $aAddon['id'], $aAddon['quantity'], $this->_oConfig->getLicense(), $aCartItemCustom));
  544. $bProcessedFree = true;
  545. }
  546. $aInfo['items_count'] -= 1;
  547. unset($aInfo['items'][$iIndex]);
  548. $aCart['items'] = trim(preg_replace("'" . $this->_oConfig->descriptorA2S($aCartItem) . ":?'", "", $aCart['items']), ":");
  549. $this->_oDb->setCartItems($aInfo['client_id'], $aCart['items'], $aCartCustoms);
  550. }
  551. //--- For Recurring payments.
  552. if($bTypeRecurring && (float)$aItem[$sKeyPriceRecurring] == 0) {
  553. //TODO: Process FREE subscription here, if such situation will be possible.
  554. }
  555. }
  556. if(empty($aInfo['items']))
  557. return $this->_sLangsPrefix . ($bProcessedFree ? 'msg_successfully_processed_free' : 'err_empty_order');
  558. if($bTypeSingle && (empty($aCustoms) || !is_array($aCustoms))) {
  559. $aCart = $this->_oDb->getCartContent($aInfo['client_id']);
  560. $aCartCustoms = !empty($aCart['customs']) ? unserialize($aCart['customs']) : array();
  561. $aCustoms = array();
  562. foreach($aInfo['items'] as $aItem) {
  563. $sCartItem = $this->_oConfig->descriptorA2S(array($aInfo['vendor_id'], $aItem['module_id'], $aItem['id']));
  564. $aCartItemCustom = $this->_oConfig->getCustom($sCartItem, $aCartCustoms);
  565. $this->_oConfig->putCustom($sCartItem, $aCartItemCustom, $aCustoms);
  566. }
  567. }
  568. $iPendingId = $this->_oDb->insertOrderPending($this->_iUserId, $sType, $sProvider, $aInfo, $aCustoms);
  569. if(empty($iPendingId))
  570. return $this->_sLangsPrefix . 'err_access_db';
  571. /*
  572. * Perform Join WITHOUT processing via payment provider
  573. * if a client ISN'T logged in and has only ONE FREE item in the card.
  574. * Note. This section isn't used for now because only a member can purchase!
  575. */
  576. if((int)$aInfo['client_id'] == 0 && (int)$aInfo['items_count'] == 1) {
  577. reset($aInfo['items']);
  578. $aItem = current($aInfo['items']);
  579. if(!empty($aItem) && $this->_oConfig->getPrice($sType, $aItem)) {
  580. $this->_oDb->updateOrderPending($iPendingId, array(
  581. 'order' => $this->_oConfig->getLicense(),
  582. 'error_code' => '1',
  583. 'error_msg' => ''
  584. ));
  585. $this->getObjectJoin()->performJoin($iPendingId);
  586. }
  587. }
  588. return $oProvider->initializeCheckout($iPendingId, $aInfo, $sRedirect);
  589. }
  590. public function actionFinalizeCheckout($sProvider, $mixedVendorId = "")
  591. {
  592. $aData = &$_REQUEST;
  593. $oProvider = $this->getObjectProvider($sProvider, $mixedVendorId);
  594. if($oProvider === false || !$oProvider->isActive())
  595. return $this->_oTemplate->displayPageCodeError($this->_sLangsPrefix . 'err_incorrect_provider');
  596. $aResult = $oProvider->finalizeCheckout($aData);
  597. if((int)$aResult['code'] != BX_PAYMENT_RESULT_SUCCESS)
  598. return $this->_oTemplate->displayPageCodeError($aResult['message']);
  599. $aPending = $this->_oDb->getOrderPending(array('type' => 'id', 'id' => (int)$aResult['pending_id']));
  600. $bTypeRecurring = $aPending['type'] == BX_PAYMENT_TYPE_RECURRING;
  601. if($bTypeRecurring) {
  602. $aSubscription = array(
  603. 'customer_id' => $aResult['customer_id'],
  604. 'subscription_id' => $aResult['subscription_id']
  605. );
  606. if(!$this->registerSubscription($aPending, $aSubscription))
  607. return $this->_oTemplate->displayPageCodeError($this->_sLangsPrefix . 'err_already_registered');
  608. }
  609. $this->onPaymentRegisterBefore($aPending);
  610. //--- Check "Pay Before Join" situation
  611. if((int)$aPending['client_id'] == 0)
  612. $this->getObjectJoin()->performJoin((int)$aPending['id'], isset($aResult['client_name']) ? $aResult['client_name'] : '', isset($aResult['client_email']) ? $aResult['client_email'] : '');
  613. //--- Register payment for purchased items in associated modules
  614. if(!empty($aResult['paid']) || ($bTypeRecurring && !empty($aResult['trial'])))
  615. $this->registerPayment($aPending);
  616. bx_alert($this->getName(), 'finalize_checkout', 0, bx_get_logged_profile_id(), array(
  617. 'pending' => $aPending,
  618. 'transactions' => $this->_oDb->getOrderProcessed(array('type' => 'pending_id', 'pending_id' => (int)$aPending['id'])),
  619. 'provider' => $oProvider,
  620. 'message' => &$aResult['message'],
  621. ));
  622. if($oProvider->needRedirect()) {
  623. header('Location: ' . $oProvider->getReturnUrl());
  624. exit;
  625. }
  626. if(!empty($aResult['redirect'])) {
  627. header('Location: ' . base64_decode(urldecode($aResult['redirect'])));
  628. exit;
  629. }
  630. $this->_oTemplate->displayPageCodeResponse($aResult['message']);
  631. }
  632. public function actionFinalizedCheckout($sProvider, $mixedVendorId = "")
  633. {
  634. $oProvider = $this->getObjectProvider($sProvider, $mixedVendorId);
  635. if($oProvider === false || !$oProvider->isActive())
  636. return $this->_oTemplate->displayPageCodeError($this->_sLangsPrefix . 'err_incorrect_provider');
  637. $aResult = $oProvider->finalizedCheckout();
  638. $this->_oTemplate->displayPageCodeResponse($aResult['message']);
  639. }
  640. public function actionNotify($sProvider, $mixedVendorId = "")
  641. {
  642. $oProvider = $this->getObjectProvider($sProvider, $mixedVendorId);
  643. if($oProvider === false || !$oProvider->isActive())
  644. return $this->_oTemplate->displayPageCodeError($this->_sLangsPrefix . 'err_incorrect_provider');
  645. $oProvider->notify();
  646. }
  647. public function actionCall($sProvider, $sAction)
  648. {
  649. $oProvider = $this->getObjectProvider($sProvider);
  650. if($oProvider === false)
  651. BxDolRequest::methodNotFound($sAction, $this->getName());
  652. $sMethod = 'action' . bx_gen_method_name($sAction);
  653. if(!method_exists($oProvider, $sMethod))
  654. BxDolRequest::methodNotFound($sAction, $this->getName());
  655. return call_user_func_array(array($oProvider, $sMethod), array_slice(func_get_args(), 2));
  656. }
  657. public function onProfileJoin($iProfileId)
  658. {
  659. $this->getObjectJoin()->onProfileJoin($iProfileId);
  660. }
  661. public function onProfileDelete($iProfileId)
  662. {
  663. $this->_oDb->onProfileDelete($iProfileId);
  664. }
  665. public function isAllowedPurchase($aItem, $bPerform = false)
  666. {
  667. $iUserId = (int)$this->getProfileId();
  668. $aItemInfo = $this->callGetCartItem((int)$aItem['module_id'], array($aItem['item_id'], isset($aItem['custom']) ? $aItem['custom'] : array()));
  669. if(empty($aItemInfo))
  670. return false;
  671. if(isAdmin())
  672. return true;
  673. $aCheckResult = checkActionModule($iUserId, 'purchase', $this->getName(), $bPerform);
  674. if($aCheckResult[CHECK_ACTION_RESULT] == CHECK_ACTION_RESULT_ALLOWED)
  675. return true;
  676. return $aCheckResult[CHECK_ACTION_MESSAGE];
  677. }
  678. public function isAllowedSell($aItem, $bPerform = false)
  679. {
  680. $iUserId = (int)$this->getProfileId();
  681. if(!$iUserId)
  682. return false;
  683. $aItemInfo = $this->callGetCartItem((int)$aItem['module_id'], array($aItem['item_id']));
  684. if(empty($aItemInfo))
  685. return false;
  686. if(isAdmin())
  687. return true;
  688. $aCheckResult = checkActionModule($iUserId, 'sell', $this->getName(), $bPerform);
  689. if((int)$aItemInfo['author_id'] == $iUserId && $aCheckResult[CHECK_ACTION_RESULT] == CHECK_ACTION_RESULT_ALLOWED)
  690. return true;
  691. return $aCheckResult[CHECK_ACTION_MESSAGE];
  692. }
  693. public function isAllowedManage($aPending, $bPerform = false)
  694. {
  695. $iUserId = (int)$this->getProfileId();
  696. if($iUserId == $aPending['client_id'] || $iUserId == $aPending['seller_id'] || isAdmin())
  697. return true;
  698. $aCheckResult = checkActionModule($iUserId, 'manage any purchase', $this->getName(), $bPerform);
  699. if($aCheckResult[CHECK_ACTION_RESULT] == CHECK_ACTION_RESULT_ALLOWED)
  700. return true;
  701. return $aCheckResult[CHECK_ACTION_MESSAGE];
  702. }
  703. public function checkData($iClientId, $iSellerId, $iModuleId, $iItemId, $iItemCount, $aCustom = array())
  704. {
  705. $CNF = &$this->_oConfig->CNF;
  706. if($iSellerId == BX_PAYMENT_EMPTY_ID || empty($iModuleId) || empty($iItemId) || empty($iItemCount))
  707. return array('code' => 1, 'message' => _t($CNF['T']['ERR_WRONG_DATA']));
  708. $iClientId = $this->getProfileId();
  709. if(empty($iClientId)) {
  710. $sLoginUrl = BxDolPermalinks::getInstance()->permalink('page.php?i=login');
  711. return array('code' => 2, 'eval' => 'window.open("' . $sLoginUrl . '", "_self");');
  712. }
  713. $mixedResult = $this->isAllowedPurchase(array('module_id' => $iModuleId, 'item_id' => $iItemId, 'custom' => $aCustom));
  714. if($mixedResult !== true) {
  715. if(is_string($mixedResult) && !empty($mixedResult))
  716. return array('code' => 2, 'message' => $mixedResult);
  717. else
  718. return array('code' => 1, 'message' => _t($CNF['T']['ERR_WRONG_DATA']));
  719. }
  720. if($iClientId == $iSellerId)
  721. return array('code' => 3, 'message' => _t($CNF['T']['ERR_SELF_PURCHASE']));
  722. $aSeller = $this->getVendorInfo($iSellerId);
  723. if(!$aSeller['active'])
  724. return array('code' => 4, 'message' => _t($CNF['T']['ERR_INACTIVE_VENDOR']));
  725. return true;
  726. }
  727. public function registerPayment($mixedPending)
  728. {
  729. $aPending = is_array($mixedPending) ? $mixedPending : $this->_oDb->getOrderPending(array('type' => 'id', 'id' => (int)$mixedPending));
  730. if(empty($aPending) || !is_array($aPending))
  731. return false;
  732. $sType = $aPending['type'];
  733. $bTypeSingle = $sType == BX_PAYMENT_TYPE_SINGLE;
  734. if($bTypeSingle && (int)$aPending['processed'] == 1)
  735. return true;
  736. $iClientId = (int)$aPending['client_id'];
  737. $sLicense = $this->_oConfig->getLicense();
  738. $aCustoms = !empty($aPending['customs']) ? unserialize($aPending['customs']) : array();
  739. $aCart = array();
  740. if($bTypeSingle) {
  741. $aCart = $this->_oDb->getCartContent($iClientId);
  742. $aCart['customs'] = !empty($aCart['customs']) ? unserialize($aCart['customs']) : array();
  743. }
  744. $bResult = false;
  745. $aItems = $this->_oConfig->descriptorsM2A($aPending['items']);
  746. foreach($aItems as $aItem) {
  747. $sItem = $this->_oConfig->descriptorA2S(array($aItem['vendor_id'], $aItem['module_id'], $aItem['item_id']));
  748. $aItemCustom = $this->_oConfig->getCustom($sItem, $aCustoms);
  749. $sMethod = $bTypeSingle ? 'callRegisterCartItem' : 'callRegisterSubscriptionItem';
  750. $aItemInfo = $this->$sMethod((int)$aItem['module_id'], array($aPending['client_id'], $aPending['seller_id'], $aItem['item_id'], $aItem['item_count'], $aPending['order'], $sLicense, $aItemCustom));
  751. if(empty($aItemInfo) || !is_array($aItemInfo))
  752. continue;
  753. $this->_oDb->insertOrderProcessed(array(
  754. 'pending_id' => $aPending['id'],
  755. 'client_id' => $aPending['client_id'],
  756. 'seller_id' => $aPending['seller_id'],
  757. 'module_id' => (int)$aItem['module_id'],
  758. 'item_id' => (int)$aItem['item_id'],
  759. 'item_count' => (int)$aItem['item_count'],
  760. 'amount' => (int)$aItem['item_count'] * $this->_oConfig->getPrice($sType, $aItemInfo),
  761. 'license' => $sLicense,
  762. ));
  763. if($bTypeSingle) {
  764. $this->_oConfig->pullCustom($sItem, $aCart['customs']);
  765. $aCart['items'] = trim(preg_replace("'" . $this->_oConfig->descriptorA2S($aItem) . ":?'", "", $aCart['items']), ":");
  766. }
  767. $bResult = true;
  768. }
  769. if($bTypeSingle)
  770. $this->_oDb->setCartItems($iClientId, $aCart['items'], $aCart['customs']);
  771. if($bResult) {
  772. $this->_oDb->updateOrderPending($aPending['id'], array('processed' => 1));
  773. $this->onPaymentRegister($aPending);
  774. }
  775. return $bResult;
  776. }
  777. public function refundPayment($mixedPending)
  778. {
  779. $aPending = is_array($mixedPending) ? $mixedPending : $this->_oDb->getOrderPending(array('type' => 'id', 'id' => (int)$mixedPending));
  780. if(empty($aPending) || !is_array($aPending))
  781. return false;
  782. $bTypeSingle = $aPending['type'] == BX_PAYMENT_TYPE_SINGLE;
  783. $iCanceled = 0;
  784. $aOrders = $this->_oDb->getOrderProcessed(array('type' => 'pending_id', 'pending_id' => (int)$aPending['id']));
  785. foreach($aOrders as $aOrder) {
  786. $sMethod = $bTypeSingle ? 'callUnregisterCartItem' : 'callUnregisterSubscriptionItem';
  787. $bResult = $this->$sMethod((int)$aOrder['module_id'], array($aOrder['client_id'], $aOrder['seller_id'], $aOrder['item_id'], $aOrder['item_count'], $aPending['order'], $aOrder['license']));
  788. if(!$bResult)
  789. continue;
  790. if($this->_oDb->deleteOrderProcessed($aOrder['id']))
  791. $iCanceled++;
  792. }
  793. if($iCanceled != count($aOrders))
  794. return false;
  795. $bResult = $this->_oDb->deleteOrderPending($aPending['id']);
  796. if($bResult)
  797. $this->onPaymentRefund($aPending);
  798. return $bResult;
  799. }
  800. public function registerSubscription($aPending, $aParams = array())
  801. {
  802. if($this->_oDb->isSubscriptionByPending($aPending['id']))
  803. return false;
  804. $aSubscription = array(
  805. 'pending_id' => $aPending['id'],
  806. 'customer_id' => $aParams['customer_id'],
  807. 'subscription_id' => $aParams['subscription_id']
  808. );
  809. if(!$this->_oDb->insertSubscription($aSubscription))
  810. return false;
  811. $this->onSubscriptionCreate($aPending);
  812. return true;
  813. }
  814. public function updateSubscription($aPending, $aParams = array())
  815. {
  816. $this->_oDb->updateSubscription($aParams, array(
  817. 'pending_id' => $aPending['id']
  818. ));
  819. $this->onSubscriptionUpdate($aPending);
  820. }
  821. public function cancelSubscription($mixedPending)
  822. {
  823. $aPending = is_array($mixedPending) ? $mixedPending : $this->_oDb->getOrderPending(array('type' => 'id', 'id' => (int)$mixedPending));
  824. if(empty($aPending) || !is_array($aPending) || $aPending['type'] != BX_PAYMENT_TYPE_RECURRING)
  825. return false;
  826. $aItems = $this->_oConfig->descriptorsM2A($aPending['items']);
  827. foreach($aItems as $aItem)
  828. $this->callCancelSubscriptionItem((int)$aItem['module_id'], array($aPending['client_id'], $aPending['seller_id'], $aItem['item_id'], $aItem['item_count'], $aPending['order']));
  829. $this->onSubscriptionCancel($aPending);
  830. }
  831. public function onPaymentRegisterBefore($aPending, $aResult = array())
  832. {
  833. //--- 'System' -> 'Before Register Payment' for Alerts Engine ---//
  834. bx_alert('system', 'before_register_payment', 0, $aPending['client_id'], array('pending' => $aPending));
  835. //--- 'System' -> 'Before Register Payment' for Alerts Engine ---//
  836. }
  837. public function onPaymentRegister($aPending, $aResult = array())
  838. {
  839. $bTypeSingle = $aPending['type'] == BX_PAYMENT_TYPE_SINGLE;
  840. if($bTypeSingle) {
  841. $aItems = $this->_oConfig->descriptorsM2A($aPending['items']);
  842. foreach($aItems as $aItem)
  843. $this->isAllowedPurchase(array('module_id' => $aItem['module_id'], 'item_id' => $aItem['item_id']), true);
  844. }
  845. //--- 'System' -> 'Register Payment' for Alerts Engine ---//
  846. bx_alert('system', 'register_payment', 0, $aPending['client_id'], array('pending' => $aPending));
  847. //--- 'System' -> 'Register Payment' for Alerts Engine ---//
  848. }
  849. public function onPaymentRefund($aPending, $aResult = array())
  850. {
  851. //--- 'System' -> 'Refund Payment' for Alerts Engine ---//
  852. bx_alert('system', 'refund_payment', 0, $aPending['client_id'], array('pending' => $aPending));
  853. //--- 'System' -> 'Refund Payment' for Alerts Engine ---//
  854. }
  855. public function onSubscriptionCreate($aPending, $aResult = array())
  856. {
  857. $aItems = $this->_oConfig->descriptorsM2A($aPending['items']);
  858. $this->isAllowedPurchase(array('module_id' => $aItems[0]['module_id'], 'item_id' => $aItems[0]['item_id']), true);
  859. //--- 'System' -> 'Create Subscription' for Alerts Engine ---//
  860. bx_alert('system', 'create_subscription', 0, $aPending['client_id'], array('pending' => $aPending));
  861. //--- 'System' -> 'Create Subscription' for Alerts Engine ---//
  862. }
  863. public function onSubscriptionUpdate($aPending, $aResult = array())
  864. {
  865. //--- 'System' -> 'Update Subscription' for Alerts Engine ---//
  866. bx_alert('system', 'update_subscription', 0, $aPending['client_id'], array('pending' => $aPending));
  867. //--- 'System' -> 'Update Subscription' for Alerts Engine ---//
  868. }
  869. public function onSubscriptionCancel($aPending, $aResult = array())
  870. {
  871. //--- 'System' -> 'Cancel Subscription' for Alerts Engine ---//
  872. bx_alert('system', 'cancel_subscription', 0, $aPending['client_id'], array('pending' => $aPending));
  873. //--- 'System' -> 'Cancel Subscription' for Alerts Engine ---//
  874. }
  875. public function setSiteSubmenu($sSubmenu, $sSelModule, $sSelName)
  876. {
  877. $oSiteSubmenu = BxDolMenu::getObjectInstance('sys_site_submenu');
  878. if(!$oSiteSubmenu)
  879. return;
  880. $sModuleSubmenu = $this->_oConfig->getObject($sSubmenu);
  881. $oModuleSubmenu = BxDolMenu::getObjectInstance($sModuleSubmenu);
  882. if(!$oModuleSubmenu)
  883. return;
  884. $oSiteSubmenu->setObjectSubmenu($sModuleSubmenu);
  885. $oModuleSubmenu->setSelected($sSelModule, $sSelName);
  886. }
  887. }
  888. /** @} */