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


PHP Subscription::create方法代码示例

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


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

示例1: testCreateUpdateListCancel

 public function testCreateUpdateListCancel()
 {
     $planID = 'gold-' . self::generateRandomString(20);
     self::retrieveOrCreatePlan($planID);
     $customer = self::createTestCustomer();
     $sub = Subscription::create(array('plan' => $planID, 'customer' => $customer->id));
     $this->assertSame($sub->status, 'active');
     $this->assertSame($sub->plan->id, $planID);
     $sub->quantity = 2;
     $sub->save();
     $sub = Subscription::retrieve($sub->id);
     $this->assertSame($sub->status, 'active');
     $this->assertSame($sub->plan->id, $planID);
     $this->assertSame($sub->quantity, 2);
     // Update the quantity parameter one more time
     $sub = Subscription::update($sub->id, array("quantity" => 3));
     $this->assertSame($sub->status, 'active');
     $this->assertSame($sub->plan->id, $planID);
     $this->assertSame($sub->quantity, 3);
     $subs = Subscription::all(array('customer' => $customer->id, 'plan' => $planID, 'limit' => 3));
     $this->assertSame(get_class($subs->data[0]), 'Stripe\\Subscription');
     $sub->cancel(array('at_period_end' => true));
     $sub = Subscription::retrieve($sub->id);
     $this->assertSame($sub->status, 'active');
     $this->assertTrue($sub->cancel_at_period_end);
 }
开发者ID:wp-premium,项目名称:gravityformsstripe,代码行数:26,代码来源:SubscriptionTest.php

示例2: create

 function create()
 {
     if ($_POST) {
         unset($_POST['send']);
         unset($_POST['_wysihtml5_mode']);
         /*$next_payment = human_to_unix($_POST['issue_date'].' 00:00');
         		$next_payment = strtotime($_POST['frequency'], $next_payment);
         		
         		$_POST['next_payment'] = date("Y-m-d", $next_payment);*/
         $_POST['next_payment'] = $_POST['issue_date'];
         $subscription = Subscription::create($_POST);
         $new_subscription_reference = $_POST['reference'] + 1;
         $subscription_reference = Setting::first();
         $subscription_reference->update_attributes(array('subscription_reference' => $new_subscription_reference));
         if (!$subscription) {
             $this->session->set_flashdata('message', 'error:' . $this->lang->line('messages_create_subscription_error'));
         } else {
             $this->session->set_flashdata('message', 'success:' . $this->lang->line('messages_create_subscription_success'));
         }
         redirect('subscriptions');
     } else {
         $this->view_data['next_reference'] = Subscription::last();
         $this->view_data['companies'] = Company::find('all', array('conditions' => array('inactive=?', '0')));
         $this->theme_view = 'modal';
         $this->view_data['title'] = $this->lang->line('application_create_subscription');
         $this->view_data['form_action'] = 'subscriptions/create';
         $this->content_view = 'subscriptions/_subscription';
     }
 }
开发者ID:timclifford,项目名称:freelance-manager,代码行数:29,代码来源:subscriptions.php

示例3: run

 public function run()
 {
     $faker = Faker\Factory::create();
     DB::table('subscriptions')->truncate();
     for ($i = 0; $i < 60; $i++) {
         Subscription::create(array('user_id' => $faker->randomNumber(1, 20), 'service_id' => $faker->randomNumber(1, 1), 'option_id' => $faker->randomNumber(1, 4), 'billing_cycle_id' => $faker->randomNumber(1, 4), 'expire_date' => $faker->dateTimeThisYear, 'status' => $faker->randomElement(array('Active', 'Stopped', 'Inactive', 'Cancelled'))));
     }
 }
开发者ID:carriercomm,项目名称:saaspanel,代码行数:8,代码来源:SubscriptionsTableSeeder.php

示例4: testAll

 public function testAll()
 {
     $planID = 'gold-' . self::randomString();
     self::retrieveOrCreatePlan($planID);
     $customer = self::createTestCustomer();
     $sub = Subscription::create(array('customer' => $customer->id, 'plan' => $planID));
     $planID_2 = 'gold-2-' . self::randomString();
     self::retrieveOrCreatePlan($planID_2);
     $sub_2 = Subscription::create(array('customer' => $customer->id, 'plan' => $planID_2));
     $subs = Subscription::all(array('limit' => 2, 'offset' => 0));
     $this->assertSame(2, count($subs['data']));
 }
开发者ID:payjp,项目名称:payjp-php,代码行数:12,代码来源:SubscriptionTest.php

示例5: takeAction

 /**
  * Performs the action; returns true on success, false on error.
  *
  * @param $p_context - the current context object
  * @return bool
  */
 public function takeAction(CampContext &$p_context)
 {
     $p_context->default_url->reset_parameter('f_' . $this->m_name);
     $p_context->url->reset_parameter('f_' . $this->m_name);
     if (PEAR::isError($this->m_error)) {
         return false;
     }
     $auth = Zend_Auth::getInstance();
     $user = new User($p_context->user->identifier);
     if ($user->getUserId() != $auth->getIdentity() || $user->getUserId() == 0) {
         $this->m_error = new PEAR_Error('You must be logged in to create or edit your subscription.', ACTION_EDIT_SUBSCRIPTION_ERR_NO_USER);
         return false;
     }
     $subscriptions = Subscription::GetSubscriptions($p_context->publication->identifier, $user->getUserId());
     if (count($subscriptions) == 0) {
         $subscription = new Subscription();
         $created = $subscription->create(array('IdUser' => $user->getUserId(), 'IdPublication' => $p_context->publication->identifier, 'Active' => 'Y', 'Type' => $this->m_subscriptionType == 'trial' ? 'T' : 'P'));
         if (!$created) {
             $this->m_error = new PEAR_Error('Internal error (code 1)', ACTION_EDIT_SUBSCRIPTION_ERR_INTERNAL);
             exit(1);
         }
     } else {
         $subscription = $subscriptions[0];
     }
     $publication = new Publication($p_context->publication->identifier);
     $subscriptionDays = $this->computeSubscriptionDays($publication, $p_context->publication->subscription_time);
     $startDate = new Date();
     $columns = array('StartDate' => $startDate->getDate(), 'Days' => $subscriptionDays, 'PaidDays' => $this->m_subscriptionType == 'trial' ? $subscriptionDays : 0, 'NoticeSent' => 'N');
     if ($this->m_properties['subs_by_type'] == 'publication') {
         $sectionsList = Section::GetUniqueSections($p_context->publication->identifier);
         foreach ($sectionsList as $section) {
             $this->m_sections[] = $section['id'];
         }
     }
     foreach ($this->m_languages as $languageId) {
         foreach ($this->m_sections as $sectionNumber) {
             $subsSection = new SubscriptionSection($subscription->getSubscriptionId(), $sectionNumber, $languageId);
             $subsSection->create($columns);
         }
     }
     $fields = array('SubsType', 'tx_subs', 'nos', 'unitcost', 'unitcostalllang', 'f_substype', 'cb_subs', 'subs_all_languages', 'suma', 'tpl', 'subscription_language');
     foreach (CampRequest::GetInput() as $field => $value) {
         if (strncmp('tx_subs', $field, strlen('tx_subs')) == 0) {
             $fields[] = $field;
         }
     }
     foreach ($fields as $fieldName) {
         $p_context->default_url->reset_parameter($fieldName);
         $p_context->url->reset_parameter($fieldName);
     }
     $this->m_error = ACTION_OK;
     return true;
 }
开发者ID:nidzix,项目名称:Newscoop,代码行数:59,代码来源:MetaActionEdit_Subscription.php

示例6: handleEndpointRequest

 public static function handleEndpointRequest(Endpoint $Endpoint)
 {
     $Subscription = $Endpoint->getSubscription($GLOBALS['Session']->Person);
     if (!$Subscription && ($_SERVER['REQUEST_METHOD'] == 'POST' || $_SERVER['REQUEST_METHOD'] == 'PUT')) {
         $Subscription = Subscription::create(['EndpointID' => $Endpoint->ID, 'PersonID' => $GLOBALS['Session']->PersonID], true);
         return static::respond('subscriptionCreated', ['data' => $Subscription, 'success' => true]);
     } elseif ($Subscription && $_SERVER['REQUEST_METHOD'] == 'DELETE') {
         $Subscription->destroy();
         $Subscription = null;
         return static::respond('subscriptionDeleted', ['data' => $Subscription, 'success' => true]);
     }
     return static::respond('subscription', ['data' => $Subscription]);
 }
开发者ID:jmealo,项目名称:Gatekeeper,代码行数:13,代码来源:SubscriptionsRequestHandler.php

示例7: testCreateUpdateListCancelWithItems

 public function testCreateUpdateListCancelWithItems()
 {
     $planID = 'gold-' . self::generateRandomString(20);
     self::retrieveOrCreatePlan($planID);
     $customer = self::createTestCustomer();
     $sub = Subscription::create(array('customer' => $customer->id, 'items' => array(array('plan' => $planID))));
     $this->assertSame(count($sub->items->data), 1);
     $this->assertSame($sub->items->data[0]->plan->id, $planID);
     $sub = Subscription::update($sub->id, array('items' => array(array('plan' => $planID))));
     $this->assertSame(count($sub->items->data), 2);
     $this->assertSame($sub->items->data[0]->plan->id, $planID);
     $this->assertSame($sub->items->data[1]->plan->id, $planID);
 }
开发者ID:stripe,项目名称:stripe-php,代码行数:13,代码来源:SubscriptionTest.php

示例8: testCreateUpdateRetrieveListCancel

 public function testCreateUpdateRetrieveListCancel()
 {
     $planID = 'gold-' . self::generateRandomString(20);
     self::retrieveOrCreatePlan($planID);
     $customer = self::createTestCustomer();
     $sub = Subscription::create(array('plan' => $planID, 'customer' => $customer->id));
     $subItem = SubscriptionItem::create(array('plan' => $planID, 'subscription' => $sub->id));
     $this->assertSame($subItem->plan->id, $planID);
     $subItem->quantity = 2;
     $subItem->save();
     $subItem = SubscriptionItem::retrieve($subItem->id);
     $this->assertSame($subItem->quantity, 2);
     // Update the quantity parameter one more time
     $subItem = SubscriptionItem::update($subItem->id, array('quantity' => 3));
     $this->assertSame($subItem->quantity, 3);
     $subItems = SubscriptionItem::all(array('subscription' => $sub->id, 'limit' => 3));
     $this->assertSame(get_class($subItems->data[0]), 'Stripe\\SubscriptionItem');
     $this->assertSame(2, count($subItems->data));
     $subItem->delete();
     $this->assertTrue($subItem->deleted);
 }
开发者ID:stripe,项目名称:stripe-php,代码行数:21,代码来源:SubscriptionItemTest.php

示例9: Subscription

 try {
     new Subscription($email);
     $created = true;
 } catch (Exception $e) {
     $created = false;
 }
 /**
  * Checks if the e-mail already exists.
  */
 if ($created) {
     $tpl->showError($lang['already_exists']);
 }
 /**
  * Adds the subscription to the database.
  */
 $subscription = Subscription::create($email);
 /**
  * Checks if the subscription was created correctly.
  */
 if ($subscription) {
     /**
      * Sets the template's variables.
      */
     $tpl->assign('page_title', $lang['subscription_added']);
     $tpl->assign('email', $email);
     /**
      * Shows the success message.
      */
     $tpl->display('subscription_added.html');
 } else {
     /**
开发者ID:jackass0528,项目名称:shauku,代码行数:31,代码来源:main.php

示例10: Subscription

 function do_main()
 {
     $iSubscriptionType = SubscriptionEvent::subTypes('Folder');
     if (Subscription::exists($this->oUser->getId(), $this->oFolder->getId(), $iSubscriptionType)) {
         $_SESSION['KTErrorMessage'][] = _kt("You are already subscribed to this folder");
     } else {
         $oSubscription = new Subscription($this->oUser->getId(), $this->oFolder->getId(), $iSubscriptionType);
         $res = $oSubscription->create();
         if ($res) {
             $_SESSION['KTInfoMessage'][] = _kt("You have been subscribed to this folder");
         } else {
             $_SESSION['KTErrorMessage'][] = _kt("There was a problem subscribing you to this folder");
         }
     }
     controllerRedirect('browse', 'fFolderId=' . $this->oFolder->getId());
     exit(0);
 }
开发者ID:sfsergey,项目名称:knowledgetree,代码行数:17,代码来源:KTSubscriptions.php

示例11: subscribe

 public function subscribe($user_id)
 {
     $validator = Validator::make(array('id' => $user_id), array('id' => 'numeric'));
     if ($validator->fails()) {
         return $this->respondInsufficientPrivileges($validator->messages()->all());
     }
     $category_id = Input::get('category_id');
     if (Subscription::where('category_id', '=', $category_id)->first()) {
         return $this->respondInsufficientPrivileges('Already subscribed');
     }
     if ($category_id) {
         $subscription = Subscription::create(array('user_id' => $user_id, 'category_id' => $category_id));
         return $this->respond(array('user_id' => $user_id, 'category_id' => $category_id, 'id' => $subscription['id']));
     }
     return $this->respondNotFound();
 }
开发者ID:SenhorBardell,项目名称:wordotheday,代码行数:16,代码来源:UsersController.php

示例12: subscribe

 /**
  * Subscribes the user to the document
  *
  * @author KnowledgeTree Team
  * @access public
  * @return boolean|object $result SUCCESS Boolean result of operation | FAILURE - a pear error object
  */
 public function subscribe()
 {
     if ($this->isSubscribed()) {
         return TRUE;
     }
     $subscriptionType = SubscriptionEvent::subTypes('Document');
     $user = $this->ktapi->get_user();
     $document = $this->document;
     $subscription = new Subscription($user->getId(), $document->getId(), $subscriptionType);
     $result = $subscription->create();
     if (PEAR::isError($result)) {
         return $result->getMessage();
     }
     if ($result) {
         return $result;
     }
     return $_SESSION['errorMessage'];
 }
开发者ID:sfsergey,项目名称:knowledgetree,代码行数:25,代码来源:KTAPIDocument.inc.php

示例13: Subscription

}
$subsType = 'T';
if ($f_subscription_type != "T") {
	$subsType = 'P';
}

if ($f_publication_id <= 0) {
	camp_html_display_error("Unable to create the subscription: please select a publication.",
		"/$ADMIN/users/subscriptions/add.php?f_user_id=$f_user_id");
	exit;
}

$subscription = new Subscription();
$created = $subscription->create(array(
	'IdUser' => $f_user_id,
	'IdPublication' => $f_publication_id,
	'Active' => $f_subscription_active,
	'Type' => $subsType));

if (!$created) {
	$errorMsgs[] = getGS('The subscription could not be added.')
				.' '.getGS("Please check if there isn't another subscription to the same publication.");
} else {
        $logtext = getGS('Subscription added for user #$1 (Publication: $2, Active: $3, Type: $4)',
			 $f_user_id, $f_publication_id, $f_subscription_active, $subsType);
        Log::Message($logtext, null, 181);
}

if ($created && ($f_add_sections_now == 'Y')) {
	$columns = array('StartDate' => $f_subscription_start_date,
			  'Days' => $f_subscription_days,
开发者ID:nistormihai,项目名称:Newscoop,代码行数:31,代码来源:do_add.php

示例14: testCustomerSubscriptionAllRetrieve

 public function testCustomerSubscriptionAllRetrieve()
 {
     $planID = 'gold-' . self::randomString();
     self::retrieveOrCreatePlan($planID);
     $customer = self::createTestCustomer();
     $subscription = Subscription::create(array('customer' => $customer->id, 'plan' => $planID));
     $planID_2 = 'gold-2-' . self::randomString();
     self::retrieveOrCreatePlan($planID_2);
     $subscription_2 = Subscription::create(array('customer' => $customer->id, 'plan' => $planID_2));
     $customerRetrive = Customer::retrieve($customer->id);
     $subscriptions = $customerRetrive->subscriptions->all();
     $this->assertSame($subscription_2->id, $subscriptions['data'][0]->id);
     $this->assertSame($subscription->id, $subscriptions['data'][1]->id);
     $this->assertSame(2, count($subscriptions['data']));
     $this->assertSame($customer->id, $subscriptions['data'][0]->customer);
     $this->assertSame($planID_2, $subscriptions['data'][0]->plan->id);
     $subscriptionRetrieve = $customerRetrive->subscriptions->retrieve($subscription->id);
     $this->assertSame($subscription->id, $subscriptionRetrieve->id);
     $this->assertSame($planID, $subscriptionRetrieve->plan->id);
 }
开发者ID:payjp,项目名称:payjp-php,代码行数:20,代码来源:CustomerTest.php


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