BxPaymentSubscriptions.php 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540
  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. class BxPaymentSubscriptions extends BxBaseModPaymentSubscriptions
  12. {
  13. function __construct()
  14. {
  15. $this->MODULE = 'bx_payment';
  16. parent::__construct();
  17. }
  18. /*
  19. * Service methods
  20. */
  21. /**
  22. * @page service Service Calls
  23. * @section bx_payment Payment
  24. * @subsection bx_payment-page_blocks Page Blocks
  25. * @subsubsection bx_payment-get_block_list_my get_block_list_my
  26. *
  27. * @code bx_srv('bx_payment', 'get_block_list_my', [...], 'Subscriptions'); @endcode
  28. *
  29. * Get page block with a list of currently logged in member's subscriptions.
  30. *
  31. * @return an array describing a block to display on the site. All necessary CSS and JS files are automatically added to the HEAD section of the site HTML.
  32. *
  33. * @see BxPaymentSubscriptions::serviceGetBlockListMy
  34. */
  35. /**
  36. * @ref bx_payment-get_block_list_my "get_block_list_my"
  37. */
  38. public function serviceGetBlockListMy()
  39. {
  40. return $this->_getBlock('list_my');
  41. }
  42. /**
  43. * @page service Service Calls
  44. * @section bx_payment Payment
  45. * @subsection bx_payment-page_blocks Page Blocks
  46. * @subsubsection bx_payment-get_block_list_all get_block_list_all
  47. *
  48. * @code bx_srv('bx_payment', 'get_block_list_all', [...], 'Subscriptions'); @endcode
  49. *
  50. * Get page block with a list of all subscriptions. It's available for authorized members only.
  51. *
  52. * @return an array describing a block to display on the site. All necessary CSS and JS files are automatically added to the HEAD section of the site HTML.
  53. *
  54. * @see BxPaymentSubscriptions::serviceGetBlockListAll
  55. */
  56. /**
  57. * @ref bx_payment-get_block_list_all "get_block_list_all"
  58. */
  59. public function serviceGetBlockListAll()
  60. {
  61. return $this->_getBlock('list_all');
  62. }
  63. /**
  64. * @page service Service Calls
  65. * @section bx_payment Payment
  66. * @subsection bx_payment-page_blocks Page Blocks
  67. * @subsubsection bx_payment-get_block_history get_block_history
  68. *
  69. * @code bx_srv('bx_payment', 'get_block_history', [...], 'Subscriptions'); @endcode
  70. *
  71. * Get page block with a list of payments related to subscriptions of currently logged in member.
  72. *
  73. * @return an array describing a block to display on the site. All necessary CSS and JS files are automatically added to the HEAD section of the site HTML.
  74. *
  75. * @see BxPaymentSubscriptions::serviceGetBlockHistory
  76. */
  77. /**
  78. * @ref bx_payment-get_block_history "get_block_history"
  79. */
  80. public function serviceGetBlockHistory()
  81. {
  82. return $this->_getBlock('history');
  83. }
  84. /**
  85. * @page service Service Calls
  86. * @section bx_payment Payment
  87. * @subsection bx_payment-other Other
  88. * @subsubsection bx_payment-get_subscription_orders_info get_subscription_orders_info
  89. *
  90. * @code bx_srv('bx_payment', 'get_subscription_orders_info', [...], 'Subscriptions'); @endcode
  91. *
  92. * Get subscription transaction(s) which meets all requirements.
  93. *
  94. * @param $aConditions an array of pears('key' => 'value'). The most useful keys are the following:
  95. * a. client_id - client's ID (integer)
  96. * b. seller_id - seller's ID (integer)
  97. * c. type - transaction type: single or recurring (string)
  98. * d. amount - transaction amount (float)
  99. * e. order - order ID received from payment provider (string)
  100. * f. provider - payment provider name (string)
  101. * g. date - the date when the payment was established(UNIXTIME STAMP)
  102. * h. processed - whether the payment was processed or not (integer, 0 or 1)
  103. * @return an array of transactions. Each transaction has full info(client ID, seller ID, external transaction ID, date and so on)
  104. *
  105. * @see BxPaymentSubscriptions::serviceGetSubscriptionOrdersInfo
  106. */
  107. /**
  108. * @ref bx_payment-get_subscription_orders_info "get_subscription_orders_info"
  109. */
  110. public function serviceGetSubscriptionOrdersInfo($aConditions)
  111. {
  112. if(empty($aConditions) || !is_array($aConditions))
  113. return array();
  114. return $this->_oModule->_oDb->getOrderSubscription(array('type' => 'mixed', 'conditions' => $aConditions));
  115. }
  116. /**
  117. * @page service Service Calls
  118. * @section bx_payment Payment
  119. * @subsection bx_payment-other Other
  120. * @subsubsection bx_payment-get_subscriptions_info get_subscriptions_info
  121. *
  122. * @code bx_srv('bx_payment', 'get_subscriptions_info', [...], 'Subscriptions'); @endcode
  123. *
  124. * Get subscription(s) which meets all requirements.
  125. *
  126. * @param $aConditions an array of pears('key' => 'value'). The most useful keys are the following:
  127. * a. pending_id - pending transaction ID (integer)
  128. * b. customer_id - customer ID from payment provider (string)
  129. * c. subscription_id - subscription ID from payment provider (string)
  130. * d. paid - flag determining whether the subscription paid or not (integer)
  131. * e. date - the date when the subscription was established(UNIXTIME STAMP)
  132. * @param $bCheckInProvider boolean value determining whether the subscription should be checked in associated payment provider.
  133. * @return an array of subscriptions. Each subscription has full info(pending ID, customer ID, subscription ID and so on)
  134. *
  135. * @see BxPaymentSubscriptions::serviceGetSubscriptionsInfo
  136. */
  137. /**
  138. * @ref bx_payment-get_subscriptions_info "get_subscriptions_info"
  139. */
  140. public function serviceGetSubscriptionsInfo($aConditions, $bCheckInProvider = false)
  141. {
  142. if(empty($aConditions) || !is_array($aConditions))
  143. return array();
  144. $aSubscriptions = $this->_oModule->_oDb->getSubscription(array('type' => 'mixed_ext', 'conditions' => $aConditions));
  145. if(empty($aSubscriptions) || !is_array($aSubscriptions) || !$bCheckInProvider)
  146. return $aSubscriptions;
  147. foreach($aSubscriptions as $iKey => $aSubscription) {
  148. if(empty($aSubscription['provider']) || $aSubscription['provider'] == 'manual')
  149. continue;
  150. $oProvider = $this->_oModule->getObjectProvider($aSubscription['provider'], $aSubscription['seller_id']);
  151. if(!$oProvider)
  152. continue;
  153. $aSubscriptions[$iKey]['data'] = $oProvider->getSubscription($aSubscription['pending_id'], $aSubscription['customer_id'], $aSubscription['subscription_id']);
  154. }
  155. return $aSubscriptions;
  156. }
  157. /**
  158. * @page service Service Calls
  159. * @section bx_payment Payment
  160. * @subsection bx_payment-purchase_processing Purchase Processing
  161. * @subsubsection bx_payment-subscribe subscribe
  162. *
  163. * @code bx_srv('bx_payment', 'subscribe', [...], 'Subscriptions'); @endcode
  164. *
  165. * Initialize subscription for specified item.
  166. *
  167. * @param $iSellerId integer value with seller ID.
  168. * @param $sSellerProvider string value with a name of payment provider to be used for processing. Empty value means that payment provider selector should be shown.
  169. * @param $iModuleId integer value with module ID.
  170. * @param $iItemId integer value with item ID.
  171. * @param $iItemCount integer value with a number of items for purchasing. It's equal to 1 in case of subscription.
  172. * @param $sRedirect (optional) string value with redirect URL, if it's needed.
  173. * @return an array with special format which describes the result of operation.
  174. *
  175. * @see BxPaymentSubscriptions::serviceSubscribe
  176. */
  177. /**
  178. * @ref bx_payment-subscribe "subscribe"
  179. */
  180. public function serviceSubscribe($iSellerId, $sSellerProvider, $iModuleId, $iItemId, $iItemCount, $sRedirect = '', $aCustom = array())
  181. {
  182. return $this->serviceSubscribeWithAddons($iSellerId, $sSellerProvider, $iModuleId, $iItemId, $iItemCount, '', $sRedirect, $aCustom);
  183. }
  184. /**
  185. * @page service Service Calls
  186. * @section bx_payment Payment
  187. * @subsection bx_payment-purchase_processing Purchase Processing
  188. * @subsubsection bx_payment-subscribe_with_addons subscribe_with_addons
  189. *
  190. * @code bx_srv('bx_payment', 'subscribe_with_addons', [...], 'Subscriptions'); @endcode
  191. *
  192. * Initialize subscription for specified item.
  193. *
  194. * @param $iSellerId integer value with seller ID.
  195. * @param $sSellerProvider string value with a name of payment provider to be used for processing. Empty value means that payment provider selector should be shown.
  196. * @param $iModuleId integer value with module ID.
  197. * @param $iItemId integer value with item ID.
  198. * @param $iItemCount integer value with a number of items for purchasing. It's equal to 1 in case of subscription.
  199. * @param $sItemAddons (optional) string with attached addons.
  200. * @param $sRedirect (optional) string value with redirect URL, if it's needed.
  201. * @return an array with special format which describes the result of operation.
  202. *
  203. * @see BxPaymentSubscriptions::serviceSubscribeWithAddons
  204. */
  205. /**
  206. * @ref bx_payment-subscribe_with_addons "subscribe_with_addons"
  207. */
  208. public function serviceSubscribeWithAddons($iSellerId, $sSellerProvider, $iModuleId, $iItemId, $iItemCount, $sItemAddons = '', $sRedirect = '', $aCustom = array())
  209. {
  210. $CNF = &$this->_oModule->_oConfig->CNF;
  211. $iClientId = $this->_oModule->getProfileId();
  212. $mixedResult = $this->_oModule->checkData($iClientId, $iSellerId, $iModuleId, $iItemId, $iItemCount);
  213. if($mixedResult !== true)
  214. return $mixedResult;
  215. $aSellerProviders = $this->_oModule->_oDb->getVendorInfoProvidersRecurring($iSellerId);
  216. if(empty($aSellerProviders))
  217. return array('code' => 5, 'message' => _t($CNF['T']['ERR_NOT_ACCEPT_PAYMENTS']));
  218. $aCartItem = array($iSellerId, $iModuleId, $iItemId, $iItemCount, $sItemAddons);
  219. if(empty($sSellerProvider)) {
  220. $sId = $this->_oModule->_oConfig->getHtmlIds('cart', 'providers_select') . BX_PAYMENT_TYPE_RECURRING;
  221. $sTitle = _t($CNF['T']['POPUP_PROVIDERS_SELECT']);
  222. return array('popup' => array(
  223. 'html' => BxTemplStudioFunctions::getInstance()->popupBox($sId, $sTitle, $this->_oModule->_oTemplate->displayProvidersSelector($aCartItem, $aSellerProviders, $sRedirect, $aCustom)),
  224. 'options' => array('closeOnOuterClick' => true)
  225. ));
  226. }
  227. $aCustoms = array();
  228. $this->_oModule->_oConfig->putCustom($aCartItem, $aCustom, $aCustoms);
  229. $sCartItem = $this->_oModule->_oConfig->descriptorA2S($aCartItem);
  230. $mixedResult = $this->_oModule->serviceInitializeCheckout(BX_PAYMENT_TYPE_RECURRING, $iSellerId, $aSellerProviders[$sSellerProvider]['name'], array($sCartItem), $sRedirect, $aCustoms);
  231. if(is_string($mixedResult))
  232. return array('code' => 6, 'message' => _t($mixedResult));
  233. return $mixedResult;
  234. }
  235. /**
  236. * @page service Service Calls
  237. * @section bx_payment Payment
  238. * @subsection bx_payment-purchase_processing Purchase Processing
  239. * @subsubsection bx_payment-send_subscription_expiration_letters send_subscription_expiration_letters
  240. *
  241. * @code bx_srv('bx_payment', 'send_subscription_expiration_letters', [...], 'Subscriptions'); @endcode
  242. *
  243. * Send subscription expiration letters.
  244. *
  245. * @param $iPendingId integer value with pending transaction ID.
  246. * @param $sOrderId string value with order ID.
  247. *
  248. * @see BxPaymentSubscriptions::serviceSendSubscriptionExpirationLetters
  249. */
  250. /**
  251. * @ref bx_payment-send_subscription_expiration_letters "send_subscription_expiration_letters"
  252. */
  253. public function serviceSendSubscriptionExpirationLetters($iPendingId, $sOrderId)
  254. {
  255. $CNF = &$this->_oModule->_oConfig->CNF;
  256. $sPrefix = $this->_oModule->_oConfig->getPrefix('general');
  257. $aSubscription = $this->serviceGetSubscriptionsInfo(array('subscription_id' => $sOrderId));
  258. if(empty($aSubscription) || !is_array($aSubscription))
  259. return;
  260. $aSubscription = array_shift($aSubscription);
  261. $oSeller = BxDolProfile::getInstance((int)$aSubscription['seller_id']);
  262. $oClient = BxDolProfile::getInstance((int)$aSubscription['client_id']);
  263. $aEtParams = array(
  264. 'sibscription_id' => $aSubscription['subscription_id'],
  265. 'sibscription_customer' => $aSubscription['customer_id'],
  266. 'sibscription_date' => bx_time_js($aSubscription['date'], BX_FORMAT_DATE, true)
  267. );
  268. /**
  269. * Notify seller.
  270. */
  271. if($oSeller !== false) {
  272. $sEmail = '';
  273. $oProvider = $this->_oModule->getObjectProvider($aSubscription['provider'], $aSubscription['seller_id']);
  274. if($oProvider !== false && $oProvider->isActive())
  275. $sEmail = $oProvider->getOption('expiration_email');
  276. if(empty($sEmail))
  277. $sEmail = $oSeller->getAccountObject()->getEmail();
  278. $aTemplate = BxDolEmailTemplates::getInstance()->parseTemplate($sPrefix . 'expiration_notification_seller', $aEtParams, 0, (int)$aSubscription['client_id']);
  279. sendMail($sEmail, $aTemplate['Subject'], $aTemplate['Body'], 0, array(), BX_EMAIL_SYSTEM);
  280. }
  281. /**
  282. * Notify client.
  283. */
  284. if($oClient !== false) {
  285. $sEmail = $oClient->getAccountObject()->getEmail();
  286. $aTemplate = BxDolEmailTemplates::getInstance()->parseTemplate($sPrefix . 'expiration_notification_client', $aEtParams, 0, (int)$aSubscription['seller_id']);
  287. sendMail($sEmail, $aTemplate['Subject'], $aTemplate['Body'], 0, array(), BX_EMAIL_SYSTEM);
  288. }
  289. }
  290. public function register($aPending, $aParams = array())
  291. {
  292. if($this->_oModule->_oDb->isSubscriptionByPending($aPending['id']) || empty($aPending['items']))
  293. return false;
  294. $aInfo = $this->_oModule->getObjectCart()->getInfo(BX_PAYMENT_TYPE_RECURRING, $aPending['client_id'], $aPending['seller_id'], $aPending['items']);
  295. if(empty($aInfo['items']) || !is_array($aInfo['items']))
  296. return false;
  297. $aItem = array_shift($aInfo['items']);
  298. $iPeriod = (int)$aItem['period_recurring'];
  299. $iTrial = (int)$aItem['trial_recurring'];
  300. $oDate = date_create();
  301. $iNow = $iNext = date_format($oDate, 'U');
  302. if((!empty($aParams['status']) && $aParams['status'] == BX_PAYMENT_SBS_STATUS_ACTIVE) || $iTrial > 0) {
  303. $sInterval = $this->_getInterval($iPeriod, $aItem['period_unit_recurring'], $iTrial);
  304. date_add($oDate, new DateInterval($sInterval));
  305. $iNext = date_format($oDate, 'U');
  306. }
  307. $sUnique = genRndPwd(9, false);
  308. $aSubscription = array(
  309. 'pending_id' => $aPending['id'],
  310. 'customer_id' => !empty($aParams['customer_id']) ? $aParams['customer_id'] : 'bx_cus_' . $sUnique,
  311. 'subscription_id' => !empty($aParams['subscription_id']) ? $aParams['subscription_id'] : 'bx_sub_' . $sUnique,
  312. 'period' => $iPeriod,
  313. 'period_unit' => $aItem['period_unit_recurring'],
  314. 'trial' => $iTrial,
  315. 'date_add' => $iNow,
  316. 'date_next' => $iNext,
  317. 'status' => !empty($aParams['status']) ? $aParams['status'] : ($iTrial > 0 ? BX_PAYMENT_SBS_STATUS_TRIAL : BX_PAYMENT_SBS_STATUS_UNPAID)
  318. );
  319. if(!$this->_oModule->_oDb->insertSubscription($aSubscription))
  320. return false;
  321. $this->_oModule->onSubscriptionCreate($aPending, $aSubscription);
  322. return true;
  323. }
  324. public function prolong($aPending, $aParams = array())
  325. {
  326. if(empty($aPending['items']))
  327. return false;
  328. $aSubscription = $this->_oModule->_oDb->getSubscription(array('type' => 'pending_id', 'pending_id' => $aPending['id']));
  329. if(empty($aSubscription) || !is_array($aSubscription))
  330. return false;
  331. $aInfo = $this->_oModule->getObjectCart()->getInfo(BX_PAYMENT_TYPE_RECURRING, $aPending['client_id'], $aPending['seller_id'], $aPending['items']);
  332. if(empty($aInfo['items']) || !is_array($aInfo['items']))
  333. return false;
  334. $aItem = array_shift($aInfo['items']);
  335. $sInterval = $this->_getInterval((int)$aItem['period_recurring'], $aItem['period_unit_recurring']);
  336. $oDate = date_create('@' . $aSubscription['date_next']);
  337. date_add($oDate, new DateInterval($sInterval));
  338. $this->_oModule->_oDb->updateSubscription(array_merge(array(
  339. 'date_next' => date_format($oDate, 'U'),
  340. 'pay_attempts' => 0,
  341. 'status' => BX_PAYMENT_SBS_STATUS_ACTIVE
  342. ), $aParams), array(
  343. 'id' => $aSubscription['id']
  344. ));
  345. $this->_oModule->onSubscriptionProlong($aPending, $aSubscription);
  346. return true;
  347. }
  348. public function overdue($aPending, $aParams = array())
  349. {
  350. $aSubscription = $this->_oModule->_oDb->getSubscription(array('type' => 'pending_id', 'pending_id' => $aPending['id']));
  351. if(empty($aSubscription) || !is_array($aSubscription))
  352. return false;
  353. $this->_oModule->_oDb->updateSubscription(array_merge(array(
  354. 'status' => BX_PAYMENT_SBS_STATUS_UNPAID
  355. ), $aParams), array(
  356. 'id' => $aSubscription['id']
  357. ));
  358. $this->_oModule->onSubscriptionOverdue($aPending, $aSubscription);
  359. return true;
  360. }
  361. public function cancel($iPendingId)
  362. {
  363. if(!$this->cancelRemote($iPendingId))
  364. return false;
  365. if(!$this->cancelLocal($iPendingId))
  366. return false;
  367. return true;
  368. }
  369. public function cancelRemote($mixedPending)
  370. {
  371. $aPending = is_array($mixedPending) ? $mixedPending : $this->_oModule->_oDb->getOrderPending(array('type' => 'id', 'id' => (int)$mixedPending));
  372. if(empty($aPending) || !is_array($aPending) || $aPending['type'] != BX_PAYMENT_TYPE_RECURRING)
  373. return false;
  374. $aSubscription = $this->_oModule->_oDb->getSubscription(array('type' => 'pending_id', 'pending_id' => $aPending['id']));
  375. if(empty($aSubscription) || !is_array($aSubscription))
  376. return false;
  377. $iSellerId = (int)$aPending['seller_id'];
  378. $oProvider = $this->_oModule->getObjectProvider($aPending['provider'], $iSellerId);
  379. if($oProvider === false || !$oProvider->isActive())
  380. return false;
  381. if(!$oProvider->cancelRecurring($aPending['id'], $aSubscription['customer_id'], $aSubscription['subscription_id']))
  382. return false;
  383. return true;
  384. }
  385. public function cancelLocal($mixedPending)
  386. {
  387. $aPending = is_array($mixedPending) ? $mixedPending : $this->_oModule->_oDb->getOrderPending(array('type' => 'id', 'id' => (int)$mixedPending));
  388. if(empty($aPending) || !is_array($aPending) || $aPending['type'] != BX_PAYMENT_TYPE_RECURRING)
  389. return false;
  390. $aSubscription = $this->_oModule->_oDb->getSubscription(array('type' => 'pending_id', 'pending_id' => $aPending['id']));
  391. if(empty($aSubscription) || !is_array($aSubscription))
  392. return false;
  393. $aItems = $this->_oModule->_oConfig->descriptorsM2A($aPending['items']);
  394. foreach($aItems as $aItem)
  395. $this->_oModule->callCancelSubscriptionItem((int)$aItem['module_id'], array($aPending['client_id'], $aPending['seller_id'], $aItem['item_id'], $aItem['item_count'], $aPending['order']));
  396. if(!$this->_oModule->_oDb->deleteSubscription($aSubscription['id'], 'cancel'))
  397. return false;
  398. $this->_oModule->onSubscriptionCancel($aPending, $aSubscription);
  399. return true;
  400. }
  401. protected function _getBlock($sType)
  402. {
  403. $CNF = &$this->_oModule->_oConfig->CNF;
  404. $sMethod = 'displayBlockSbs' . bx_gen_method_name($sType);
  405. if(!$this->_oModule->_oTemplate->isMethodExists($sMethod))
  406. return array(
  407. 'content' => MsgBox(_t('_Empty'))
  408. );
  409. $iUserId = $this->_oModule->getProfileId();
  410. if(empty($iUserId))
  411. return array(
  412. 'content' => MsgBox(_t($CNF['T']['ERR_REQUIRED_LOGIN']))
  413. );
  414. $this->_oModule->setSiteSubmenu('menu_dashboard', 'system', 'dashboard-subscriptions');
  415. $sBlockSubmenu = $this->_oModule->_oConfig->getObject('menu_sbs_submenu');
  416. $oBlockSubmenu = BxDolMenu::getObjectInstance($sBlockSubmenu);
  417. if($oBlockSubmenu)
  418. $oBlockSubmenu->setSelected($this->MODULE, 'sbs-' . str_replace('_', '-', $sType));
  419. return array(
  420. 'content' => $this->_oModule->_oTemplate->$sMethod($iUserId),
  421. 'menu' => $this->_oModule->_oConfig->getObject('menu_sbs_submenu')
  422. );
  423. }
  424. private function _getInterval($iPeriod, $sPeriodUnit, $iTrial = 0)
  425. {
  426. if((int)$iTrial > 0)
  427. return 'P' . $iTrial . 'D';
  428. $sInterval = '';
  429. switch($sPeriodUnit) {
  430. case BX_PAYMENT_SBS_PU_YEAR:
  431. $sInterval = 'P' . $iPeriod . 'Y';
  432. break;
  433. case BX_PAYMENT_SBS_PU_MONTH:
  434. $sInterval = 'P' . $iPeriod . 'M';
  435. break;
  436. case BX_PAYMENT_SBS_PU_WEEK:
  437. $sInterval = 'P' . (7 * $iPeriod) . 'D';
  438. break;
  439. case BX_PAYMENT_SBS_PU_DAY:
  440. $sInterval = 'P' . $iPeriod . 'D';
  441. break;
  442. case BX_PAYMENT_SBS_PU_HOUR:
  443. $sInterval = 'PT' . $iPeriod . 'H';
  444. break;
  445. case BX_PAYMENT_SBS_PU_MINUTE:
  446. $sInterval = 'PT' . $iPeriod . 'I';
  447. break;
  448. }
  449. return $sInterval;
  450. }
  451. }
  452. /** @} */