BxPaymentSubscriptions.php 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541
  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, $mixedModuleId, $iItemId, $iItemCount, $sItemAddons = '', $sRedirect = '', $aCustom = array())
  209. {
  210. $CNF = &$this->_oModule->_oConfig->CNF;
  211. $iModuleId = $this->_oModule->_oConfig->getModuleId($mixedModuleId);
  212. $iClientId = $this->_oModule->getProfileId();
  213. $mixedResult = $this->_oModule->checkData($iClientId, $iSellerId, $iModuleId, $iItemId, $iItemCount);
  214. if($mixedResult !== true)
  215. return $mixedResult;
  216. $aSellerProviders = $this->_oModule->_oDb->getVendorInfoProvidersRecurring($iSellerId);
  217. if(empty($aSellerProviders))
  218. return array('code' => 5, 'message' => _t($CNF['T']['ERR_NOT_ACCEPT_PAYMENTS']));
  219. $aCartItem = array($iSellerId, $iModuleId, $iItemId, $iItemCount, $sItemAddons);
  220. if(empty($sSellerProvider)) {
  221. $sId = $this->_oModule->_oConfig->getHtmlIds('cart', 'providers_select') . BX_PAYMENT_TYPE_RECURRING;
  222. $sTitle = _t($CNF['T']['POPUP_PROVIDERS_SELECT']);
  223. return array('popup' => array(
  224. 'html' => BxTemplFunctions::getInstance()->popupBox($sId, $sTitle, $this->_oModule->_oTemplate->displayProvidersSelector($aCartItem, $aSellerProviders, $sRedirect, $aCustom)),
  225. 'options' => array('closeOnOuterClick' => true)
  226. ));
  227. }
  228. $aCustoms = array();
  229. $this->_oModule->_oConfig->putCustom($aCartItem, $aCustom, $aCustoms);
  230. $sCartItem = $this->_oModule->_oConfig->descriptorA2S($aCartItem);
  231. $mixedResult = $this->_oModule->serviceInitializeCheckout(BX_PAYMENT_TYPE_RECURRING, $iSellerId, $aSellerProviders[$sSellerProvider]['name'], array($sCartItem), $sRedirect, $aCustoms);
  232. if(is_string($mixedResult))
  233. return array('code' => 6, 'message' => _t($mixedResult));
  234. return $mixedResult;
  235. }
  236. /**
  237. * @page service Service Calls
  238. * @section bx_payment Payment
  239. * @subsection bx_payment-purchase_processing Purchase Processing
  240. * @subsubsection bx_payment-send_subscription_expiration_letters send_subscription_expiration_letters
  241. *
  242. * @code bx_srv('bx_payment', 'send_subscription_expiration_letters', [...], 'Subscriptions'); @endcode
  243. *
  244. * Send subscription expiration letters.
  245. *
  246. * @param $iPendingId integer value with pending transaction ID.
  247. * @param $sOrderId string value with order ID.
  248. *
  249. * @see BxPaymentSubscriptions::serviceSendSubscriptionExpirationLetters
  250. */
  251. /**
  252. * @ref bx_payment-send_subscription_expiration_letters "send_subscription_expiration_letters"
  253. */
  254. public function serviceSendSubscriptionExpirationLetters($iPendingId, $sOrderId)
  255. {
  256. $CNF = &$this->_oModule->_oConfig->CNF;
  257. $sPrefix = $this->_oModule->_oConfig->getPrefix('general');
  258. $aSubscription = $this->serviceGetSubscriptionsInfo(array('subscription_id' => $sOrderId));
  259. if(empty($aSubscription) || !is_array($aSubscription))
  260. return;
  261. $aSubscription = array_shift($aSubscription);
  262. $oSeller = BxDolProfile::getInstance((int)$aSubscription['seller_id']);
  263. $oClient = BxDolProfile::getInstance((int)$aSubscription['client_id']);
  264. $aEtParams = array(
  265. 'sibscription_id' => $aSubscription['subscription_id'],
  266. 'sibscription_customer' => $aSubscription['customer_id'],
  267. 'sibscription_date' => bx_time_js($aSubscription['date_add'], BX_FORMAT_DATE, true)
  268. );
  269. /**
  270. * Notify seller.
  271. */
  272. if($oSeller !== false) {
  273. $sEmail = '';
  274. $oProvider = $this->_oModule->getObjectProvider($aSubscription['provider'], $aSubscription['seller_id']);
  275. if($oProvider !== false && $oProvider->isActive())
  276. $sEmail = $oProvider->getOption('expiration_email');
  277. if(empty($sEmail))
  278. $sEmail = $oSeller->getAccountObject()->getEmail();
  279. $aTemplate = BxDolEmailTemplates::getInstance()->parseTemplate($sPrefix . 'expiration_notification_seller', $aEtParams, 0, (int)$aSubscription['client_id']);
  280. sendMail($sEmail, $aTemplate['Subject'], $aTemplate['Body'], 0, array(), BX_EMAIL_SYSTEM);
  281. }
  282. /**
  283. * Notify client.
  284. */
  285. if($oClient !== false) {
  286. $sEmail = $oClient->getAccountObject()->getEmail();
  287. $aTemplate = BxDolEmailTemplates::getInstance()->parseTemplate($sPrefix . 'expiration_notification_client', $aEtParams, 0, (int)$aSubscription['seller_id']);
  288. sendMail($sEmail, $aTemplate['Subject'], $aTemplate['Body'], 0, array(), BX_EMAIL_SYSTEM);
  289. }
  290. }
  291. public function register($aPending, $aParams = array())
  292. {
  293. if($this->_oModule->_oDb->isSubscriptionByPending($aPending['id']) || empty($aPending['items']))
  294. return false;
  295. $aInfo = $this->_oModule->getObjectCart()->getInfo(BX_PAYMENT_TYPE_RECURRING, $aPending['client_id'], $aPending['seller_id'], $aPending['items']);
  296. if(empty($aInfo['items']) || !is_array($aInfo['items']))
  297. return false;
  298. $aItem = array_shift($aInfo['items']);
  299. $iPeriod = (int)$aItem['period_recurring'];
  300. $iTrial = (int)$aItem['trial_recurring'];
  301. $oDate = date_create();
  302. $iNow = $iNext = date_format($oDate, 'U');
  303. if((!empty($aParams['status']) && $aParams['status'] == BX_PAYMENT_SBS_STATUS_ACTIVE) || $iTrial > 0) {
  304. $sInterval = $this->_getInterval($iPeriod, $aItem['period_unit_recurring'], $iTrial);
  305. date_add($oDate, new DateInterval($sInterval));
  306. $iNext = date_format($oDate, 'U');
  307. }
  308. $sUnique = genRndPwd(9, false);
  309. $aSubscription = array(
  310. 'pending_id' => $aPending['id'],
  311. 'customer_id' => !empty($aParams['customer_id']) ? $aParams['customer_id'] : 'bx_cus_' . $sUnique,
  312. 'subscription_id' => !empty($aParams['subscription_id']) ? $aParams['subscription_id'] : 'bx_sub_' . $sUnique,
  313. 'period' => $iPeriod,
  314. 'period_unit' => $aItem['period_unit_recurring'],
  315. 'trial' => $iTrial,
  316. 'date_add' => $iNow,
  317. 'date_next' => $iNext,
  318. 'status' => !empty($aParams['status']) ? $aParams['status'] : ($iTrial > 0 ? BX_PAYMENT_SBS_STATUS_TRIAL : BX_PAYMENT_SBS_STATUS_UNPAID)
  319. );
  320. if(!$this->_oModule->_oDb->insertSubscription($aSubscription))
  321. return false;
  322. $this->_oModule->onSubscriptionCreate($aPending, $aSubscription);
  323. return true;
  324. }
  325. public function prolong($aPending, $aParams = array())
  326. {
  327. if(empty($aPending['items']))
  328. return false;
  329. $aSubscription = $this->_oModule->_oDb->getSubscription(array('type' => 'pending_id', 'pending_id' => $aPending['id']));
  330. if(empty($aSubscription) || !is_array($aSubscription))
  331. return false;
  332. $aInfo = $this->_oModule->getObjectCart()->getInfo(BX_PAYMENT_TYPE_RECURRING, $aPending['client_id'], $aPending['seller_id'], $aPending['items']);
  333. if(empty($aInfo['items']) || !is_array($aInfo['items']))
  334. return false;
  335. $aItem = array_shift($aInfo['items']);
  336. $sInterval = $this->_getInterval((int)$aItem['period_recurring'], $aItem['period_unit_recurring']);
  337. $oDate = date_create('@' . $aSubscription['date_next']);
  338. date_add($oDate, new DateInterval($sInterval));
  339. $this->_oModule->_oDb->updateSubscription(array_merge(array(
  340. 'date_next' => date_format($oDate, 'U'),
  341. 'pay_attempts' => 0,
  342. 'status' => BX_PAYMENT_SBS_STATUS_ACTIVE
  343. ), $aParams), array(
  344. 'id' => $aSubscription['id']
  345. ));
  346. $this->_oModule->onSubscriptionProlong($aPending, $aSubscription);
  347. return true;
  348. }
  349. public function overdue($aPending, $aParams = array())
  350. {
  351. $aSubscription = $this->_oModule->_oDb->getSubscription(array('type' => 'pending_id', 'pending_id' => $aPending['id']));
  352. if(empty($aSubscription) || !is_array($aSubscription))
  353. return false;
  354. $this->_oModule->_oDb->updateSubscription(array_merge(array(
  355. 'status' => BX_PAYMENT_SBS_STATUS_UNPAID
  356. ), $aParams), array(
  357. 'id' => $aSubscription['id']
  358. ));
  359. $this->_oModule->onSubscriptionOverdue($aPending, $aSubscription);
  360. return true;
  361. }
  362. public function cancel($iPendingId)
  363. {
  364. if(!$this->cancelRemote($iPendingId))
  365. return false;
  366. if(!$this->cancelLocal($iPendingId))
  367. return false;
  368. return true;
  369. }
  370. public function cancelRemote($mixedPending)
  371. {
  372. $aPending = is_array($mixedPending) ? $mixedPending : $this->_oModule->_oDb->getOrderPending(array('type' => 'id', 'id' => (int)$mixedPending));
  373. if(empty($aPending) || !is_array($aPending) || $aPending['type'] != BX_PAYMENT_TYPE_RECURRING)
  374. return false;
  375. $aSubscription = $this->_oModule->_oDb->getSubscription(array('type' => 'pending_id', 'pending_id' => $aPending['id']));
  376. if(empty($aSubscription) || !is_array($aSubscription))
  377. return false;
  378. $iSellerId = (int)$aPending['seller_id'];
  379. $oProvider = $this->_oModule->getObjectProvider($aPending['provider'], $iSellerId);
  380. if($oProvider === false || !$oProvider->isActive())
  381. return false;
  382. if(!$oProvider->cancelRecurring($aPending['id'], $aSubscription['customer_id'], $aSubscription['subscription_id']))
  383. return false;
  384. return true;
  385. }
  386. public function cancelLocal($mixedPending)
  387. {
  388. $aPending = is_array($mixedPending) ? $mixedPending : $this->_oModule->_oDb->getOrderPending(array('type' => 'id', 'id' => (int)$mixedPending));
  389. if(empty($aPending) || !is_array($aPending) || $aPending['type'] != BX_PAYMENT_TYPE_RECURRING)
  390. return false;
  391. $aSubscription = $this->_oModule->_oDb->getSubscription(array('type' => 'pending_id', 'pending_id' => $aPending['id']));
  392. if(empty($aSubscription) || !is_array($aSubscription))
  393. return false;
  394. $aItems = $this->_oModule->_oConfig->descriptorsM2A($aPending['items']);
  395. foreach($aItems as $aItem)
  396. $this->_oModule->callCancelSubscriptionItem((int)$aItem['module_id'], array($aPending['client_id'], $aPending['seller_id'], $aItem['item_id'], $aItem['item_count'], $aPending['order']));
  397. if(!$this->_oModule->_oDb->deleteSubscription($aSubscription['id'], 'cancel'))
  398. return false;
  399. $this->_oModule->onSubscriptionCancel($aPending, $aSubscription);
  400. return true;
  401. }
  402. protected function _getBlock($sType)
  403. {
  404. $CNF = &$this->_oModule->_oConfig->CNF;
  405. $sMethod = 'displayBlockSbs' . bx_gen_method_name($sType);
  406. if(!$this->_oModule->_oTemplate->isMethodExists($sMethod))
  407. return array(
  408. 'content' => MsgBox(_t('_Empty'))
  409. );
  410. $iUserId = $this->_oModule->getProfileId();
  411. if(empty($iUserId))
  412. return array(
  413. 'content' => MsgBox(_t($CNF['T']['ERR_REQUIRED_LOGIN']))
  414. );
  415. $this->_oModule->setSiteSubmenu('menu_dashboard', 'system', 'dashboard-subscriptions');
  416. $sBlockSubmenu = $this->_oModule->_oConfig->getObject('menu_sbs_submenu');
  417. $oBlockSubmenu = BxDolMenu::getObjectInstance($sBlockSubmenu);
  418. if($oBlockSubmenu)
  419. $oBlockSubmenu->setSelected($this->MODULE, 'sbs-' . str_replace('_', '-', $sType));
  420. return array(
  421. 'content' => $this->_oModule->_oTemplate->$sMethod($iUserId),
  422. 'menu' => $this->_oModule->_oConfig->getObject('menu_sbs_submenu')
  423. );
  424. }
  425. private function _getInterval($iPeriod, $sPeriodUnit, $iTrial = 0)
  426. {
  427. if((int)$iTrial > 0)
  428. return 'P' . $iTrial . 'D';
  429. $sInterval = '';
  430. switch($sPeriodUnit) {
  431. case BX_PAYMENT_SBS_PU_YEAR:
  432. $sInterval = 'P' . $iPeriod . 'Y';
  433. break;
  434. case BX_PAYMENT_SBS_PU_MONTH:
  435. $sInterval = 'P' . $iPeriod . 'M';
  436. break;
  437. case BX_PAYMENT_SBS_PU_WEEK:
  438. $sInterval = 'P' . (7 * $iPeriod) . 'D';
  439. break;
  440. case BX_PAYMENT_SBS_PU_DAY:
  441. $sInterval = 'P' . $iPeriod . 'D';
  442. break;
  443. case BX_PAYMENT_SBS_PU_HOUR:
  444. $sInterval = 'PT' . $iPeriod . 'H';
  445. break;
  446. case BX_PAYMENT_SBS_PU_MINUTE:
  447. $sInterval = 'PT' . $iPeriod . 'I';
  448. break;
  449. }
  450. return $sInterval;
  451. }
  452. }
  453. /** @} */