当前位置: 首页>>代码示例>>PHP>>正文


PHP Subscription::load方法代码示例

本文整理汇总了PHP中Subscription::load方法的典型用法代码示例。如果您正苦于以下问题:PHP Subscription::load方法的具体用法?PHP Subscription::load怎么用?PHP Subscription::load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Subscription的用法示例。


在下文中一共展示了Subscription::load方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: displaySubscriptions

 public function displaySubscriptions($tab, $user, $ui)
 {
     $db = JFactory::getDBO();
     include_once JPATH_SITE . '/components/com_acctexp/acctexp.class.php';
     $dateFormat = $this->params->get('dateFormat', "m/d/Y");
     $meta_user = new metaUser($user->id);
     $html_return = '' . '<table class="aeceventlog_table" style="border-collapse: collapse">' . '<tr class="aeceventlog_row_header">' . '<th width="30%" class="text-center">Plan</th>' . '<th width="10%" class="text-center">Primary</th>' . '<th width="10%" class="text-center">Status</th>' . '<th width="10%" class="text-center">Started</th>' . '<th width="20%" class="text-center">Ends</th>' . '</tr>';
     $subscriptions = $meta_user->getAllSubscriptions();
     $subscr_info = $this->getAllCurrentSubscriptionsInfoComplete($user->id);
     foreach ($subscriptions as $i => $subscriptionid) {
         $subscription = new Subscription();
         $subscription->load($subscriptionid);
         $plan_name = $subscr_info[$i]->name == '' ? "Excluded" : $subscr_info[$i]->name;
         $html_return .= '<tr>' . '<td width="30%" class="text-center">' . $plan_name . '</td>' . '<td width="10%" class="text-center">' . ($subscription->primary ? "Yes" : "No") . '</td>' . '<td width="10%" class="text-center">' . $this->getIconHtml($subscription->status) . ' ' . $subscription->status . '</td>' . '<td width="10%" class="text-center">' . date($dateFormat, strtotime($subscription->signup_date)) . '</td>';
         $html_return .= '<td width="10%" class="text-center">';
         if (!empty($subscription->lifetime)) {
             $html_return .= JText::_('AEC_ISLIFETIME');
         } else {
             if ($subscription->recurring && in_array($subscription->status, array('Active', 'Trial'))) {
                 $html_return .= JText::_('AEC_WILLRENEW') . ': ' . date($dateFormat, strtotime($subscription->expiration));
             } else {
                 $html_return .= date($dateFormat, strtotime($subscription->expiration));
             }
         }
         $html_return .= '</td></tr>';
     }
     $html_return .= '</table>';
     return $html_return;
 }
开发者ID:Ibrahim1,项目名称:aec,代码行数:29,代码来源:cbaecmembershiptab.php

示例2: cancelSubscription

 /**
  * @param $userId
  * @param $serviceProvider
  * @return array|bool
  * @throws Exception
  */
 public function cancelSubscription($userId, $serviceProvider)
 {
     $activeSubscription = Subscription::getActiveSubscriptions($userId, $serviceProvider);
     if (!$activeSubscription) {
         PaypalSubscription::log(['message' => "Error. Can\\'t cancel subscription. User has no active subscriptions", 'level' => PaypalSubscription::LOG_LEVEL_ERROR, 'user_id' => $userId]);
         return false;
     }
     /* free subscription */
     if ((int) $activeSubscription['price'] == 0) {
         $recordId = $activeSubscription['subId'];
         $subscription = new Subscription();
         $subscription->load($recordId);
         $subscription->status = Subscription::STATUS_CANCELED;
         $subscription->save();
         $result = ['error' => 0, 'message' => 'success. Subscription canceled.'];
         return $result;
     } else {
         if (!$activeSubscription['subscription_id']) {
             PaypalSubscription::log(['message' => "Error. Can\\'t cancel subscription. Wrong subscription id", 'level' => PaypalSubscription::LOG_LEVEL_ERROR, 'user_id' => $userId]);
             return false;
         }
         $config = Config::get();
         $paypalService = new PaypalSubscription($config);
         $lastTransaction = $paypalService->getLastActiveTransactionBySubscription($activeSubscription['subId']);
         $transactionId = $lastTransaction['txn_id'];
         $subscriptionId = $activeSubscription['subscription_id'];
         $refundAmount = $paypalService->getTransactionRefundAmount($lastTransaction);
         $cancelSubscriptionResult = $paypalService->changeSubscriptionStatus($subscriptionId, 'Cancel');
         $refundTransactionResult = $paypalService->refundTransaction($lastTransaction, $refundAmount);
         if ($cancelSubscriptionResult['ACK'] == "Success" && $refundTransactionResult['ACK'] == "Success") {
             $subscription = new Subscription();
             $subscription->loadBySubscriptionId($subscriptionId);
             $subscription->status = Subscription::STATUS_CANCELING;
             $subscription->save();
             $result = ['error' => 0, 'message' => 'success. Subscription canceling.'];
             PaypalSubscription::log(['txn_id' => $transactionId, 'subscr_id' => $subscriptionId, 'message' => "Subscription canceling", 'level' => PaypalSubscription::LOG_LEVEL_INFO, 'data' => '', 'user_id' => $userId]);
             return $result;
         } else {
             PaypalSubscription::log(['txn_id' => $transactionId, 'subscr_id' => $subscriptionId, 'message' => "Error. Can\\'t cancel subscription. Rejected by PayPal", 'level' => PaypalSubscription::LOG_LEVEL_ERROR, 'data' => json_encode(['cancelSubscriptionResult' => $cancelSubscriptionResult, 'refundTransactionResult' => $refundTransactionResult]), 'user_id' => $userId]);
             return false;
         }
     }
 }
开发者ID:antonshell,项目名称:paypal_sample,代码行数:49,代码来源:Subscription.php

示例3: cancelSubscription

 public function cancelSubscription($userId, $validateUsersCount = true)
 {
     $result = ['error' => 1, 'message' => "Error canceling subscription. Please contact support about this issue"];
     $ipn = new SubscriptionsIPN();
     $ipn->configureDatabase($userId);
     /* clear subscription plan restrictions */
     unset($_SESSION['subscriptionPlanOptions']);
     /**/
     $gsSubscriptions = Subscription::getActiveSubscriptions();
     if (count($gsSubscriptions) != 1) {
         PayPalIPN::log(['message' => "Error. Can\\'t cancel subscription. User has no active subscriptions", 'level' => PayPalIPN::LOG_LEVEL_ERROR, 'user_id' => $userId]);
     }
     $subscription = $gsSubscriptions[0];
     $subscriptionPlan = new SubscriptionPlan();
     $subscriptionPlan->load($subscription['plan_id']);
     if (!$this->validateUsersCount() && $validateUsersCount) {
         $result = ['error' => 2, 'message' => 'Error, wrong users count'];
     }
     /* free subscription */
     if ($subscriptionPlan->service_provider == 'getscorecard' && $subscriptionPlan->service_name == 'free') {
         $recordId = $subscription['subId'];
         $subscription = new Subscription();
         $subscription->load($recordId);
         $subscription->status = Subscription::STATUS_CANCELED;
         $subscription->save();
         $result = ['error' => 0, 'message' => 'success. Subscription canceling.'];
     } else {
         if (!$subscription['subscription_id']) {
             PayPalIPN::log(['message' => "Error. Can\\'t cancel subscription. Wrong subscription id", 'level' => PayPalIPN::LOG_LEVEL_ERROR, 'user_id' => $userId]);
         }
         $lastTransaction = $ipn->getLastActiveTransactionBySubscription($subscription['subId']);
         $transactionId = $lastTransaction['txn_id'];
         $subscriptionId = $subscription['subscription_id'];
         $refundAmount = $ipn->getTransactionRefundAmount($lastTransaction);
         $cancelSubscriptionResult = $ipn->changeSubscriptionStatus($subscriptionId, 'Cancel');
         $refundTransactionResult = $ipn->refundTransaction($lastTransaction, $refundAmount);
         if ($cancelSubscriptionResult['ACK'] == "Success" && $refundTransactionResult['ACK'] == "Success") {
             $subscription = new Subscription();
             $subscription->loadBySubscriptionId($subscriptionId);
             $subscription->status = Subscription::STATUS_CANCELING;
             $subscription->save();
             $result = ['error' => 0, 'message' => 'success. Subscription canceling.'];
             PayPalIPN::log(['txn_id' => $transactionId, 'subscr_id' => $subscriptionId, 'message' => "Subscription canceling", 'level' => PayPalIPN::LOG_LEVEL_INFO, 'data' => '', 'user_id' => $userId]);
         } else {
             PayPalIPN::log(['txn_id' => $transactionId, 'subscr_id' => $subscriptionId, 'message' => "Error. Can\\'t cancel subscription. Rejected by PayPal", 'level' => PayPalIPN::LOG_LEVEL_ERROR, 'data' => json_encode(['cancelSubscriptionResult' => $cancelSubscriptionResult, 'refundTransactionResult' => $refundTransactionResult]), 'user_id' => $userId]);
         }
     }
     return $result;
 }
开发者ID:antonshell,项目名称:paypal_sample,代码行数:49,代码来源:SubscriptionsManager.php

示例4: delete

 public function delete()
 {
     $subids = $this->getAllSubscriptions();
     foreach ($subids as $id) {
         $subscription = new Subscription();
         $subscription->load($id);
         $subscription->delete();
     }
     $this->meta->delete();
 }
开发者ID:Ibrahim1,项目名称:aec,代码行数:10,代码来源:acctexp.user.class.php

示例5: index

 public function index($subscriptionid, $userid = array())
 {
     $groups = $this->state->filter->status;
     if (is_array($groups) && count($groups) === 1) {
         if ($this->state->filter->status[0] == 'all') {
             $groups = array('active', 'excluded', 'expired', 'pending', 'cancelled', 'hold', 'closed');
         }
     }
     if (is_array($groups)) {
         foreach ($groups as $k => $v) {
             $groups[$k] = strtolower($v);
         }
     }
     if (array_search('notconfig', $this->state->filter->status)) {
         $set_group = 'notconfig';
     } else {
         $set_group = strtolower($this->state->filter->status[0]);
     }
     if (!empty($orderby)) {
         if ($set_group == 'notconfig') {
             $forder = array('name ASC', 'name DESC', 'lastname ASC', 'lastname DESC', 'username ASC', 'username DESC', 'signup_date ASC', 'signup_date DESC', 'lastpay_date ASC', 'lastpay_date DESC');
         } else {
             $forder = array('expiration ASC', 'expiration DESC', 'lastpay_date ASC', 'lastpay_date DESC', 'name ASC', 'name DESC', 'lastname ASC', 'lastname DESC', 'username ASC', 'username DESC', 'signup_date ASC', 'signup_date DESC', 'lastpay_date ASC', 'lastpay_date DESC', 'plan_name ASC', 'plan_name DESC', 'status ASC', 'status DESC', 'type ASC', 'type DESC');
         }
         if (!in_array($orderby, $forder)) {
             $this->state->sort = 'name ASC';
         }
     }
     // define displaying at html
     $action = array();
     switch ($set_group) {
         case 'active':
             $action[0] = 'active';
             $action[1] = JText::_('AEC_HEAD_ACTIVE_SUBS');
             break;
         case 'excluded':
             $action[0] = 'excluded';
             $action[1] = JText::_('AEC_HEAD_EXCLUDED_SUBS');
             break;
         case 'expired':
             $action[0] = 'expired';
             $action[1] = JText::_('AEC_HEAD_EXPIRED_SUBS');
             break;
         case 'pending':
             $action[0] = 'pending';
             $action[1] = JText::_('AEC_HEAD_PENDING_SUBS');
             break;
         case 'cancelled':
             $action[0] = 'cancelled';
             $action[1] = JText::_('AEC_HEAD_CANCELLED_SUBS');
             break;
         case 'hold':
             $action[0] = 'hold';
             $action[1] = JText::_('AEC_HEAD_HOLD_SUBS');
             break;
         case 'closed':
             $action[0] = 'closed';
             $action[1] = JText::_('AEC_HEAD_CLOSED_SUBS');
             break;
         case 'manual':
         case 'notconfig':
             $action[0] = 'manual';
             $action[1] = JText::_('AEC_HEAD_MANUAL_SUBS');
             break;
     }
     $where = array();
     $where_or = array();
     $notconfig = false;
     $planid = trim(aecGetParam('assign_planid', null));
     $users_selected = is_array($subscriptionid) && count($subscriptionid) || is_array($userid) && count($userid);
     if (!empty($planid) && $users_selected) {
         $plan = new SubscriptionPlan();
         $plan->load($planid);
         if (!empty($subscriptionid)) {
             foreach ($subscriptionid as $sid) {
                 $metaUser = new metaUser(false, $sid);
                 $metaUser->establishFocus($plan);
                 $metaUser->focusSubscription->applyUsage($planid, 'none', 1);
             }
         }
         if (!empty($userid)) {
             foreach ($userid as $uid) {
                 $metaUser = new metaUser($uid);
                 $metaUser->establishFocus($plan);
                 $metaUser->focusSubscription->applyUsage($planid, 'none', 1);
                 $subscriptionid[] = $metaUser->focusSubscription->id;
             }
         }
         // Also show active users now
         if (!in_array('active', $groups)) {
             $groups[] = 'active';
         }
     }
     $set_status = trim(aecGetParam('set_status', null));
     $add_or_set_expiration = trim(aecGetParam('add_or_set_expiration', null));
     $set_time = trim(aecGetParam('set_time', null));
     $set_time_unit = trim(aecGetParam('set_time_unit', null));
     if ((!empty($set_status) || !empty($add_or_set_expiration)) && is_array($subscriptionid) && count($subscriptionid) > 0) {
         foreach ($subscriptionid as $k) {
             $subscriptionHandler = new Subscription();
//.........这里部分代码省略.........
开发者ID:Ibrahim1,项目名称:aec,代码行数:101,代码来源:admin.acctexp.php

示例6: beat

 public function beat()
 {
     $this->processors = array();
     $this->proc_prepare = array();
     $this->result = array('fail_expired' => 0, 'fallback' => 0, 'skipped' => 0, 'expired' => 0, 'pre_expired' => 0, 'pre_exp_actions' => 0);
     // Some cleanup
     $this->deleteTempTokens();
     // Receive maximum pre expiration time
     $pre_expiration = microIntegrationHandler::getMaxPreExpirationTime();
     $subscription_list = $this->getSubscribers($pre_expiration);
     // Efficient way to check for expired users without checking on each one
     if (empty($subscription_list)) {
         return $this->endBeat();
     }
     foreach ($subscription_list as $sid => $sub_id) {
         $subscription = new Subscription();
         $subscription->load($sub_id);
         if (!aecUserHelper::UserExists($subscription->userid)) {
             unset($subscription_list[$sid]);
             continue;
         }
         // Check whether this user really is expired
         // If this check fails, the following subscriptions might still be pre-expiration events
         if ($subscription->isExpired()) {
             // If we don't have any validation response, expire
             $validate = $this->processorValidation($subscription, $subscription_list);
             if ($validate === false) {
                 // There was some kind of fatal error, return.
                 return false;
             } elseif ($validate !== true) {
                 $expire = $subscription->expire();
                 if ($expire) {
                     $this->result['expired']++;
                 } elseif ($expire === false) {
                     $this->result['fail_expired']++;
                 } elseif (is_null($expire)) {
                     $this->result['fallback']++;
                 } else {
                     $this->result['skipped']++;
                 }
             }
             unset($subscription_list[$sid]);
         } elseif (!$subscription->recurring) {
             break;
         }
     }
     // Only go for pre expiration action if we have at least one user for it
     if (empty($pre_expiration) || empty($subscription_list)) {
         return $this->endBeat();
     }
     // Get all the MIs which have a pre expiration check
     $mi_pexp = microIntegrationHandler::getPreExpIntegrations();
     // Find plans which have the MIs assigned
     $expmi_plans = microIntegrationHandler::getPlansbyMI($mi_pexp);
     // Filter out the users which dont have the correct plan
     $query = 'SELECT `id`, `userid`' . ' FROM #__acctexp_subscr' . ' WHERE `id` IN (' . implode(',', $subscription_list) . ')' . ' AND `plan` IN (' . implode(',', $expmi_plans) . ')';
     $this->_db->setQuery($query);
     $sub_list = $this->_db->loadObjectList();
     if (!empty($sub_list)) {
         foreach ($sub_list as $sl) {
             $metaUser = new metaUser($sl->userid);
             $metaUser->moveFocus($sl->id);
             $res = $metaUser->focusSubscription->triggerPreExpiration($metaUser, $mi_pexp);
             if ($res) {
                 $this->result['pre_exp_actions'] += $res;
                 $this->result['pre_expired']++;
             }
         }
     }
     return $this->endBeat();
 }
开发者ID:Ibrahim1,项目名称:aec,代码行数:71,代码来源:acctexp.heartbeat.class.php

示例7: validateSubscription

 /**
  * @param Subscription $subscription_id
  */
 public function validateSubscription($subscription_id)
 {
     if (empty($this->settings)) {
         $this->getSettings();
     }
     if (method_exists($this->processor, 'validateSubscription')) {
         $subscription = new Subscription();
         $subscription->load($subscription_id);
         $allowed = array("Trial", "Active");
         if (!in_array($subscription->status, $allowed)) {
             return null;
         }
         $invoice = new Invoice();
         $invoice->loadbySubscriptionId($subscription_id);
         if (empty($invoice->id)) {
             return null;
         }
         $iFactory = new InvoiceFactory(null, null, null, $this->processor_name);
         $iFactory->userid = $subscription->userid;
         $iFactory->usage = $invoice->usage;
         $iFactory->processor = $this->processor_name;
         $iFactory->loadMetaUser();
         $iFactory->touchInvoice($invoice->invoice_number);
         $iFactory->puffer();
         $iFactory->loadItems();
         $iFactory->loadItemTotal();
         foreach ($iFactory->items->itemlist as $item) {
             $this->exchangeSettingsByPlan($item['obj']);
         }
         $result = $this->processor->validateSubscription($iFactory, $subscription);
         $resp = array();
         if (!empty($result['raw'])) {
             if (is_array($result['raw'])) {
                 $resp = $result['raw'];
             } else {
                 $resp['response'] = $result['raw'];
             }
         }
         $iFactory->invoice->processorResponse($iFactory, $result, $resp, true);
         if (!empty($result['valid'])) {
             return true;
         } elseif (empty($result['error'])) {
             return null;
         }
     } else {
         return null;
     }
 }
开发者ID:Ibrahim1,项目名称:aec,代码行数:51,代码来源:acctexp.paymentprocessor.class.php


注:本文中的Subscription::load方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。