BxPaymentModule.php 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582
  1. <?php defined('BX_DOL') or die('hack attempt');
  2. /**
  3. * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
  4. * CC-BY License - http://creativecommons.org/licenses/by/3.0/
  5. *
  6. * @defgroup Payment Payment
  7. * @ingroup TridentModules
  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_EMPTY_ID', 0);
  16. define('BX_PAYMENT_RESULT_SUCCESS', 0);
  17. /**
  18. * Payment module by BoonEx
  19. *
  20. * This module is needed to work with payment providers and organize the process
  21. * of some item purchasing. Shopping Cart and Orders Manager are included.
  22. *
  23. * Integration notes:
  24. * To integrate your module with this one, you need:
  25. * 1. Get 'Add To Cart' button using serviceGetAddToCartLink service.
  26. * 2. Add info about your module in the 'bx_pmt_modules' table.
  27. * 3. Realize the following service methods in your Module class.
  28. * a. serviceGetItems($iSellerId) - Is used in Orders Administration to get all products of the requested seller(vendor).
  29. * b. serviceGetCartItem($iClientId, $iItemId) - Is used in Shopping Cart to get one product by specified id.
  30. * c. serviceRegisterCartItem($iClientId, $iSellerId, $iItemId, $iItemCount, $sOrderId) - Register purchased product.
  31. * d. serviceUnregisterCartItem($iClientId, $iSellerId, $iItemId, $iItemCount, $sOrderId) - Unregister the product purchased earlier.
  32. * @see You may see an example of integration in Membership module.
  33. *
  34. *
  35. * Profile's Wall:
  36. * no spy events
  37. *
  38. *
  39. *
  40. * Spy:
  41. * no spy events
  42. *
  43. *
  44. *
  45. * Memberships/ACL:
  46. * Doesn't depend on user's membership.
  47. *
  48. *
  49. *
  50. * Service methods:
  51. *
  52. * Is used to get "Add to cart" link for some item(s) in your module.
  53. * @see BxPmtModule::serviceGetAddToCartLink
  54. * BxDolService::call('payment', 'get_add_to_cart_link', array($iSellerId, $mixedModuleId, $iItemId, $iItemCount));
  55. *
  56. * Check transaction(s) in database which satisty all conditions.
  57. * @see BxPmtModule::serviceGetTransactionsInfo
  58. * BxDolService::call('payment', 'get_transactions_info', array($aConditions));
  59. *
  60. * Get total count of items in Shopping Cart.
  61. * @see BxPmtModule::serviceGetCartItemsCount
  62. * BxDolService::call('payment', 'get_cart_items_count', array($iUserId, $iOldCount));
  63. * @note is needed for internal usage(integration with member tool bar).
  64. *
  65. * Get Shopping cart content.
  66. * @see BxPmtModule::serviceGetCartItems
  67. * BxDolService::call('payment', 'get_cart_items');
  68. * @note is needed for internal usage(integration with member tool bar).
  69. *
  70. *
  71. * Alerts:
  72. * no alerts available
  73. *
  74. */
  75. class BxPaymentModule extends BxBaseModPaymentModule
  76. {
  77. protected $_iUserId;
  78. protected $_aOrderTypes;
  79. function __construct($aModule)
  80. {
  81. parent::__construct($aModule);
  82. $this->_iUserId = $this->getProfileId();
  83. $this->_aOrderTypes = array(
  84. BX_PAYMENT_ORDERS_TYPE_PENDING,
  85. BX_PAYMENT_ORDERS_TYPE_PROCESSED,
  86. BX_PAYMENT_ORDERS_TYPE_SUBSCRIPTION,
  87. BX_PAYMENT_ORDERS_TYPE_HISTORY
  88. );
  89. }
  90. /**
  91. * Manage Orders Methods
  92. */
  93. public function actionGetClients()
  94. {
  95. $sTerm = bx_get('term');
  96. $aResult = BxDolService::call('system', 'profiles_search', array($sTerm), 'TemplServiceProfiles');
  97. echoJson($aResult);
  98. }
  99. public function actionGetItems($sType, $iModuleId)
  100. {
  101. $iSellerId = $this->getProfileId();
  102. $aItems = $this->callGetCartItems((int)$iModuleId, array($iSellerId));
  103. $aResult = array('code' => 0);
  104. if(is_array($aItems) && !empty($aItems))
  105. $aResult['data'] = $this->_oTemplate->displayItems($sType, $aItems);
  106. echoJson($aResult);
  107. }
  108. /**
  109. * Payment Details Methods
  110. */
  111. public function serviceIsAcceptingPayments($iVendorId, $sPaymentType = '')
  112. {
  113. $bResult = false;
  114. switch($sPaymentType) {
  115. case BX_PAYMENT_TYPE_SINGLE:
  116. $aProvidersCart = $this->_oDb->getVendorInfoProvidersSingle($iVendorId);
  117. $bResult = !empty($aProvidersCart);
  118. break;
  119. case BX_PAYMENT_TYPE_RECURRING:
  120. $aProvidersSubscription = $this->_oDb->getVendorInfoProvidersRecurring($iVendorId);
  121. $bResult = !empty($aProvidersSubscription);
  122. break;
  123. default:
  124. $aProviders = $this->_oDb->getVendorInfoProviders($iVendorId);
  125. $bResult = !empty($aProviders);
  126. }
  127. return $bResult;
  128. }
  129. public function serviceIsPaymentProvider($iVendorId, $sVendorProvider, $sPaymentType = '')
  130. {
  131. $aProvider = $this->serviceGetPaymentProvider($iVendorId, $sVendorProvider, $sPaymentType);
  132. return $aProvider !== false;
  133. }
  134. public function serviceGetPaymentProvider($iVendorId, $sVendorProvider, $sPaymentType = '')
  135. {
  136. $aProviders = array();
  137. switch($sPaymentType) {
  138. case BX_PAYMENT_TYPE_SINGLE:
  139. $aProviders = $this->_oDb->getVendorInfoProvidersSingle($iVendorId);
  140. break;
  141. case BX_PAYMENT_TYPE_RECURRING:
  142. $aProviders = $this->_oDb->getVendorInfoProvidersRecurring($iVendorId);
  143. break;
  144. default:
  145. $aProviders = $this->_oDb->getVendorInfoProviders($iVendorId);
  146. }
  147. return !empty($aProviders) && !empty($aProviders[$sVendorProvider]) && is_array(($aProviders[$sVendorProvider])) ? $aProviders[$sVendorProvider] : false;
  148. }
  149. public function serviceGetOptionsSiteAdmin()
  150. {
  151. $aResult = array(
  152. array('key' => '', 'value' => _t('_Select_one'))
  153. );
  154. $aIds = $this->_oDb->getAdminsIds();
  155. foreach($aIds as $iId) {
  156. $aUser = $this->getProfileInfo($iId);
  157. $aResult[] = array(
  158. 'key' => $iId,
  159. 'value' => $aUser['name']
  160. );
  161. }
  162. return $aResult;
  163. }
  164. /**
  165. * Check transaction(s) in database which satisty all conditions.
  166. *
  167. * @param array $aConditions an array of pears('key' => 'value'). Available keys are the following:
  168. * a. license - internal license (string)
  169. * b. client_id - client's ID (integer)
  170. * c. seller_id - seller's ID (integer)
  171. * d. module_id - modules's where the purchased product is located. (integer)
  172. * e. item_id - item id in the database. (integer)
  173. * f. date - the date when the payment was processed(UNIXTIME STAMP)
  174. *
  175. * @return array of transactions. Each transaction has full info(client ID, seller ID, external transaction ID, date and so on)
  176. */
  177. public function serviceGetTransactionsInfo($aConditions)
  178. {
  179. return $this->_oDb->getOrderProcessed(array('type' => 'mixed', 'conditions' => $aConditions));
  180. }
  181. /**
  182. * Cart Processing Methods
  183. */
  184. public function actionAddToCart($iSellerId, $iModuleId, $iItemId, $iItemCount)
  185. {
  186. $aResult = $this->getObjectCart()->serviceAddToCart($iSellerId, $iModuleId, $iItemId, $iItemCount);
  187. echoJson($aResult);
  188. }
  189. /**
  190. * Isn't used yet.
  191. */
  192. public function actionDeleteFromCart($iSellerId, $iModuleId, $iItemId)
  193. {
  194. $aResult = $this->getObjectCart()->serviceDeleteFromCart($iSellerId, $iModuleId, $iItemId);
  195. echoJson($aResult);
  196. }
  197. /**
  198. * Isn't used yet.
  199. */
  200. public function actionEmptyCart($iSellerId)
  201. {
  202. $aResult = $this->getObjectCart()->serviceDeleteFromCart($iSellerId);
  203. echoJson($aResult);
  204. }
  205. public function actionSubscribe()
  206. {
  207. $iSellerId = bx_process_input(bx_get('seller_id'), BX_DATA_INT);
  208. $sSellerProvider = bx_process_input(bx_get('seller_provider'));
  209. $iModuleId = bx_process_input(bx_get('module_id'), BX_DATA_INT);
  210. $iItemId = bx_process_input(bx_get('item_id'), BX_DATA_INT);
  211. $iItemCount = bx_process_input(bx_get('item_count'), BX_DATA_INT);
  212. if(empty($iItemCount))
  213. $iItemCount = 1;
  214. $aResult = $this->getObjectCart()->serviceSubscribe($iSellerId, $sSellerProvider, $iModuleId, $iItemId, $iItemCount);
  215. if($aResult['code'] != 0)
  216. return $this->_oTemplate->displayPageCodeError($aResult['message']);
  217. if(empty($aResult['redirect']) && !empty($aResult['message']))
  218. return $this->_oTemplate->displayPageCodeResponse($aResult['message']);
  219. header('Location: ' . $aResult['redirect']);
  220. exit;
  221. }
  222. public function actionSubscribeJson()
  223. {
  224. $iSellerId = bx_process_input(bx_get('seller_id'), BX_DATA_INT);
  225. $sSellerProvider = bx_process_input(bx_get('seller_provider'));
  226. $iModuleId = bx_process_input(bx_get('module_id'), BX_DATA_INT);
  227. $iItemId = bx_process_input(bx_get('item_id'), BX_DATA_INT);
  228. $iItemCount = bx_process_input(bx_get('item_count'), BX_DATA_INT);
  229. if(empty($iItemCount))
  230. $iItemCount = 1;
  231. $aResult = $this->getObjectCart()->serviceSubscribe($iSellerId, $sSellerProvider, $iModuleId, $iItemId, $iItemCount);
  232. echoJson($aResult);
  233. }
  234. /**
  235. * Payment Processing Methods
  236. */
  237. public function actionInitializeCheckout($sType)
  238. {
  239. if(!$this->isLogged())
  240. return $this->_oTemplate->displayPageCodeError($this->_sLangsPrefix . 'err_required_login');
  241. if(bx_get('seller_id') !== false && bx_get('provider') !== false && bx_get('items') !== false) {
  242. $iSellerId = bx_process_input(bx_get('seller_id'), BX_DATA_INT);
  243. $sProvider = bx_process_input(bx_get('provider'));
  244. $aItems = bx_process_input(bx_get('items'));
  245. $mixedResult = $this->serviceInitializeCheckout(BX_PAYMENT_TYPE_SINGLE, $iSellerId, $sProvider, $aItems);
  246. if($mixedResult !== true)
  247. return $this->_oTemplate->displayPageCodeError($mixedResult);
  248. }
  249. header('Location: ' . $this->_oConfig->getUrl('URL_CART'));
  250. exit;
  251. }
  252. public function serviceInitializeCheckout($sType, $iSellerId, $sProvider, $aItems = array())
  253. {
  254. if(!is_array($aItems))
  255. $aItems = array($aItems);
  256. $iSellerId = (int)$iSellerId;
  257. if($iSellerId == BX_PAYMENT_EMPTY_ID)
  258. return $this->_sLangsPrefix . 'err_unknown_vendor';
  259. $oProvider = $this->getObjectProvider($sProvider, $iSellerId);
  260. if($oProvider === false || !$oProvider->isActive())
  261. return $this->_sLangsPrefix . 'err_incorrect_provider';
  262. $aInfo = $this->getObjectCart()->getInfo($sType, $this->_iUserId, $iSellerId, $aItems);
  263. if(empty($aInfo) || $aInfo['vendor_id'] == BX_PAYMENT_EMPTY_ID || empty($aInfo['items']))
  264. return $this->_sLangsPrefix . 'err_empty_order';
  265. /*
  266. * Process FREE (price = 0) items for LOGGED IN members
  267. * WITHOUT processing via payment provider.
  268. */
  269. $bProcessedFree = false;
  270. $sKeyPriceSingle = $this->_oConfig->getKey('KEY_ARRAY_PRICE_SINGLE');
  271. $sKeyPriceRecurring = $this->_oConfig->getKey('KEY_ARRAY_PRICE_RECURRING');
  272. foreach($aInfo['items'] as $iIndex => $aItem)
  273. if((int)$aInfo['client_id'] != 0 && (float)$aItem[$sKeyPriceSingle] == 0 && (float)$aItem[$sKeyPriceRecurring] == 0) {
  274. $aItemInfo = $this->callRegisterCartItem((int)$aItem['module_id'], array($aInfo['client_id'], $aInfo['vendor_id'], $aItem['id'], $aItem['quantity'], $this->_oConfig->getLicense()));
  275. if(is_array($aItemInfo) && !empty($aItemInfo))
  276. $bProcessedFree = true;
  277. $aInfo['items_count'] -= 1;
  278. unset($aInfo['items'][$iIndex]);
  279. $sCartItems = $this->_oDb->getCartItems($aInfo['client_id']);
  280. $sCartItems = trim(preg_replace("'" . $this->_oConfig->descriptorA2S(array($aInfo['vendor_id'], $aItem['module_id'], $aItem['id'], $aItem['quantity'])) . ":?'", "", $sCartItems), ":");
  281. $this->_oDb->setCartItems($aInfo['client_id'], $sCartItems);
  282. }
  283. if(empty($aInfo['items']))
  284. return $this->_sLangsPrefix . ($bProcessedFree ? 'msg_successfully_processed_free' : 'err_empty_order');
  285. $iPendingId = $this->_oDb->insertOrderPending($this->_iUserId, $sType, $sProvider, $aInfo);
  286. if(empty($iPendingId))
  287. return $this->_sLangsPrefix . 'err_access_db';
  288. /*
  289. * Perform Join WITHOUT processing via payment provider
  290. * if a client ISN'T logged in and has only ONE FREE item in the card.
  291. */
  292. if((int)$aInfo['client_id'] == 0 && (int)$aInfo['items_count'] == 1) {
  293. reset($aInfo['items']);
  294. $aItem = current($aInfo['items']);
  295. if(!empty($aItem) && $this->_oConfig->getPrice($sType, $aItem)) {
  296. $this->_oDb->updateOrderPending($iPendingId, array(
  297. 'order' => $this->_oConfig->getLicense(),
  298. 'error_code' => '1',
  299. 'error_msg' => ''
  300. ));
  301. $this->getObjectJoin()->performJoin($iPendingId);
  302. }
  303. }
  304. return $oProvider->initializeCheckout($iPendingId, $aInfo);
  305. }
  306. public function actionFinalizeCheckout($sProvider, $mixedVendorId = "")
  307. {
  308. $aData = &$_REQUEST;
  309. $oProvider = $this->getObjectProvider($sProvider, $mixedVendorId);
  310. if($oProvider === false || !$oProvider->isActive())
  311. return $this->_oTemplate->displayPageCodeError($this->_sLangsPrefix . 'err_incorrect_provider');
  312. $aResult = $oProvider->finalizeCheckout($aData);
  313. if((int)$aResult['code'] != BX_PAYMENT_RESULT_SUCCESS)
  314. return $this->_oTemplate->displayPageCodeError($aResult['message']);
  315. $aPending = $this->_oDb->getOrderPending(array('type' => 'id', 'id' => (int)$aResult['pending_id']));
  316. $this->onPaymentRegisterBefore($aPending);
  317. //--- Check "Pay Before Join" situation
  318. if((int)$aPending['client_id'] == 0)
  319. $this->getObjectJoin()->performJoin((int)$aPending['id'], isset($aResult['client_name']) ? $aResult['client_name'] : '', isset($aResult['client_email']) ? $aResult['client_email'] : '');
  320. //--- Register payment for purchased items in associated modules
  321. if(!empty($aResult['paid']))
  322. $this->registerPayment($aPending);
  323. if($oProvider->needRedirect()) {
  324. header('Location: ' . $oProvider->getReturnUrl());
  325. exit;
  326. }
  327. $this->_oTemplate->displayPageCodeResponse($aResult['message']);
  328. }
  329. public function actionFinalizedCheckout($sProvider, $mixedVendorId = "")
  330. {
  331. $oProvider = $this->getObjectProvider($sProvider, $mixedVendorId);
  332. if($oProvider === false || !$oProvider->isActive())
  333. return $this->_oTemplate->displayPageCodeError($this->_sLangsPrefix . 'err_incorrect_provider');
  334. $aResult = $oProvider->finalizedCheckout();
  335. $this->_oTemplate->displayPageCodeResponse($aResult['message']);
  336. }
  337. public function actionNotify($sProvider, $mixedVendorId = "")
  338. {
  339. $oProvider = $this->getObjectProvider($sProvider, $mixedVendorId);
  340. if($oProvider === false || !$oProvider->isActive())
  341. return $this->_oTemplate->displayPageCodeError($this->_sLangsPrefix . 'err_incorrect_provider');
  342. $oProvider->notify();
  343. }
  344. public function onProfileJoin($iProfileId)
  345. {
  346. $this->getObjectJoin()->onProfileJoin($iProfileId);
  347. }
  348. public function onProfileDelete($iProfileId)
  349. {
  350. $this->_oDb->onProfileDelete($iProfileId);
  351. }
  352. public function isAllowedSell($aItem, $bPerform = false)
  353. {
  354. $iUserId = (int)$this->getProfileId();
  355. if(!$iUserId)
  356. return false;
  357. $aItemInfo = $this->callGetCartItem($aItem['module_id'], array($aItem['item_id']));
  358. if(empty($aItemInfo))
  359. return false;
  360. if(isAdmin())
  361. return true;
  362. $aCheckResult = checkActionModule($iUserId, 'sell', $this->getName(), $bPerform);
  363. if((int)$aItemInfo['author_id'] == $iUserId && $aCheckResult[CHECK_ACTION_RESULT] == CHECK_ACTION_RESULT_ALLOWED)
  364. return true;
  365. return $aCheckResult[CHECK_ACTION_MESSAGE];
  366. }
  367. public function registerPayment($mixedPending)
  368. {
  369. $aPending = is_array($mixedPending) ? $mixedPending : $this->_oDb->getOrderPending(array('type' => 'id', 'id' => (int)$mixedPending));
  370. if(empty($aPending) || !is_array($aPending))
  371. return false;
  372. $sType = $aPending['type'];
  373. $bTypeSingle = $sType == BX_PAYMENT_TYPE_SINGLE;
  374. if($bTypeSingle && (int)$aPending['processed'] == 1)
  375. return true;
  376. $iClientId = (int)$aPending['client_id'];
  377. $sLicense = $this->_oConfig->getLicense();
  378. $sCartItems = '';
  379. if($bTypeSingle)
  380. $sCartItems = $this->_oDb->getCartItems($iClientId);
  381. $bResult = false;
  382. $aItems = $this->_oConfig->descriptorsM2A($aPending['items']);
  383. foreach($aItems as $aItem) {
  384. $sMethod = $bTypeSingle ? 'callRegisterCartItem' : 'callRegisterSubscriptionItem';
  385. $aItemInfo = $this->$sMethod((int)$aItem['module_id'], array($aPending['client_id'], $aPending['seller_id'], $aItem['item_id'], $aItem['item_count'], $aPending['order'], $sLicense));
  386. if(empty($aItemInfo) || !is_array($aItemInfo))
  387. continue;
  388. $this->_oDb->insertOrderProcessed(array(
  389. 'pending_id' => $aPending['id'],
  390. 'client_id' => $aPending['client_id'],
  391. 'seller_id' => $aPending['seller_id'],
  392. 'module_id' => $aItem['module_id'],
  393. 'item_id' => $aItem['item_id'],
  394. 'item_count' => $aItem['item_count'],
  395. 'amount' => $aItem['item_count'] * $this->_oConfig->getPrice($sType, $aItemInfo),
  396. 'license' => $sLicense,
  397. ));
  398. if($bTypeSingle)
  399. $sCartItems = trim(preg_replace("'" . $this->_oConfig->descriptorA2S($aItem) . ":?'", "", $sCartItems), ":");
  400. $bResult = true;
  401. }
  402. if($bTypeSingle)
  403. $this->_oDb->setCartItems($iClientId, $sCartItems);
  404. if($bResult) {
  405. $this->_oDb->updateOrderPending($aPending['id'], array('processed' => 1));
  406. $this->onPaymentRegister($aPending);
  407. }
  408. return $bResult;
  409. }
  410. public function refundPayment($mixedPending)
  411. {
  412. $aPending = is_array($mixedPending) ? $mixedPending : $this->_oDb->getOrderPending(array('type' => 'id', 'id' => (int)$mixedPending));
  413. if(empty($aPending) || !is_array($aPending))
  414. return false;
  415. $bTypeSingle = $aPending['type'] == BX_PAYMENT_TYPE_SINGLE;
  416. $iCanceled = 0;
  417. $aOrders = $this->_oDb->getOrderProcessed(array('type' => 'pending_id', 'pending_id' => (int)$aPending['id']));
  418. foreach($aOrders as $aOrder) {
  419. $sMethod = $bTypeSingle ? 'callUnregisterCartItem' : 'callUnregisterSubscriptionItem';
  420. $bResult = $this->$sMethod((int)$aOrder['module_id'], array($aOrder['client_id'], $aOrder['seller_id'], $aOrder['item_id'], $aOrder['item_count'], $aPending['order'], $aOrder['license']));
  421. if(!$bResult)
  422. continue;
  423. if($this->_oDb->deleteOrderProcessed($aOrder['id']))
  424. $iCanceled++;
  425. }
  426. if($iCanceled != count($aOrders))
  427. return false;
  428. $bResult = $this->_oDb->deleteOrderPending($aPending['id']);
  429. if($bResult)
  430. $this->onPaymentRefund($aPending);
  431. return $bResult;
  432. }
  433. public function cancelSubscription($mixedPending)
  434. {
  435. $aPending = is_array($mixedPending) ? $mixedPending : $this->_oDb->getOrderPending(array('type' => 'id', 'id' => (int)$mixedPending));
  436. if(empty($aPending) || !is_array($aPending) || $aPending['type'] != BX_PAYMENT_TYPE_RECURRING)
  437. return false;
  438. $aItems = $this->_oConfig->descriptorsM2A($aPending['items']);
  439. foreach($aItems as $aItem)
  440. $this->callCancelSubscriptionItem((int)$aItem['module_id'], array($aPending['client_id'], $aPending['seller_id'], $aItem['item_id'], $aItem['item_count'], $aPending['order']));
  441. $this->onSubscriptionCancel($aPending);
  442. }
  443. public function onPaymentRegisterBefore($aPending, $aResult = array())
  444. {
  445. //--- 'System' -> 'Before Register Payment' for Alerts Engine ---//
  446. bx_alert('system', 'before_register_payment', 0, $aPending['client_id'], array('pending' => $aPending));
  447. //--- 'System' -> 'Before Register Payment' for Alerts Engine ---//
  448. }
  449. public function onPaymentRegister($aPending, $aResult = array())
  450. {
  451. //--- 'System' -> 'Register Payment' for Alerts Engine ---//
  452. bx_alert('system', 'register_payment', 0, $aPending['client_id'], array('pending' => $aPending));
  453. //--- 'System' -> 'Register Payment' for Alerts Engine ---//
  454. }
  455. public function onPaymentRefund($aPending, $aResult = array())
  456. {
  457. //--- 'System' -> 'Refund Payment' for Alerts Engine ---//
  458. bx_alert('system', 'refund_payment', 0, $aPending['client_id'], array('pending' => $aPending));
  459. //--- 'System' -> 'Refund Payment' for Alerts Engine ---//
  460. }
  461. public function onSubscriptionCreate($aPending, $aResult = array())
  462. {
  463. //--- 'System' -> 'Create Subscription' for Alerts Engine ---//
  464. bx_alert('system', 'create_subscription', 0, $aPending['client_id'], array('pending' => $aPending));
  465. //--- 'System' -> 'Create Subscription' for Alerts Engine ---//
  466. }
  467. public function onSubscriptionCancel($aPending, $aResult = array())
  468. {
  469. //--- 'System' -> 'Cancel Subscription' for Alerts Engine ---//
  470. bx_alert('system', 'cancel_subscription', 0, $aPending['client_id'], array('pending' => $aPending));
  471. //--- 'System' -> 'Cancel Subscription' for Alerts Engine ---//
  472. }
  473. }
  474. /** @} */