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


PHP Model::subscriptions方法代码示例

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


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

示例1: subscription

 /**
  * Return the subscription helper object associated with this invoice item.
  *
  * @return \DorellJames\Billing\SubscriptionBillableTrait\Subscription
  */
 public function subscription()
 {
     if (empty($this->subscription_id)) {
         return null;
     }
     if (null !== $this->subscription) {
         return $this->subscription ? $this->subscription : null;
     }
     $this->subscription = false;
     if ($subscription = $this->model->subscriptions()->find($this->subscription_id)) {
         $this->subscription = $subscription;
     }
     return $this->subscription ? $this->subscription : null;
 }
开发者ID:dorelljames,项目名称:laravel-billing,代码行数:19,代码来源:InvoiceItem.php

示例2: create

 /**
  * Create a new Stripe subscription.
  *
  * @param  string|null  $token
  * @param  array  $options
  * @return \Laravel\Cashier\Subscription
  */
 public function create($token = null, array $options = [])
 {
     $customer = $this->getStripeCustomer($token, $options);
     $subscription = $customer->subscriptions->create($this->buildPayload());
     if ($this->skipTrial) {
         $trialEndsAt = null;
     } else {
         $trialEndsAt = $this->trialDays ? Carbon::now()->addDays($this->trialDays) : null;
     }
     return $this->owner->subscriptions()->create(['name' => $this->name, 'stripe_id' => $subscription->id, 'stripe_plan' => $this->plan, 'quantity' => $this->quantity, 'trial_ends_at' => $trialEndsAt, 'ends_at' => null]);
 }
开发者ID:GovTribe,项目名称:cashier,代码行数:18,代码来源:SubscriptionBuilder.php

示例3: create

 /**
  * Create a new Braintree subscription.
  *
  * @param  string|null  $token
  * @param  array  $customerOptions
  * @param  array  $subscriptionOptions
  * @return \Laravel\Cashier\Subscription
  */
 public function create($token = null, array $customerOptions = [], array $subscriptionOptions = [])
 {
     $payload = $this->getSubscriptionPayload($this->getBraintreeCustomer($token, $customerOptions), $subscriptionOptions);
     if ($this->coupon) {
         $payload = $this->addCouponToPayload($payload);
     }
     $response = BraintreeSubscription::create($payload);
     if (!$response->success) {
         throw new Exception('Braintree failed to create subscription: ' . $response->message);
     }
     if ($this->skipTrial) {
         $trialEndsAt = null;
     } else {
         $trialEndsAt = $this->trialDays ? Carbon::now()->addDays($this->trialDays) : null;
     }
     return $this->user->subscriptions()->create(['name' => $this->name, 'braintree_id' => $response->subscription->id, 'braintree_plan' => $this->plan, 'quantity' => 1, 'trial_ends_at' => $trialEndsAt, 'ends_at' => null]);
 }
开发者ID:laravel,项目名称:cashier-braintree,代码行数:25,代码来源:SubscriptionBuilder.php

示例4: create

 /**
  * Create a new Braintree subscription.
  *
  * @param string|null $nonce
  * @param array       $customerOptions
  * @param array       $subscriptionOptions
  *
  * @return \LimeDeck\CashierBraintree\Subscription
  * @throws \Exception
  */
 public function create($nonce = null, array $customerOptions = [], array $subscriptionOptions = [])
 {
     $customer = $this->getBraintreeCustomer($nonce, $customerOptions);
     $plan = $this->findPlanById($this->plan);
     $planPriceWithTax = $this->planPriceWithTax($plan, $this->getTaxPercentageForPayload());
     $subscriptionOptions = array_merge($subscriptionOptions, ['price' => $planPriceWithTax, 'paymentMethodToken' => $customer->paymentMethods[0]->token, 'planId' => $this->plan, 'trialDuration' => $this->trialDays ?: 0, 'trialDurationUnit' => 'day', 'trialPeriod' => $this->trialDays ? true : false]);
     if ($this->coupon) {
         $coupon = $this->findCouponById($this->coupon);
         $amount = $this->couponPercentage ? $coupon->amount / 100 * $planPriceWithTax : $coupon->amount;
         $subscriptionOptions['discounts'] = ['add' => [['inheritedFromId' => $this->coupon, 'amount' => $this->formatAmount($amount)]]];
     }
     $result = BraintreeSubscription::create($subscriptionOptions);
     if (!$result->success) {
         throw new Exception('Subscription was not created');
     }
     return $this->user->subscriptions()->create(['name' => $this->name, 'braintree_id' => $result->subscription->id, 'braintree_plan' => $this->plan, 'quantity' => 1, 'trial_ends_at' => $this->trialDays ? Carbon::now()->addDays($this->trialDays) : null, 'ends_at' => null]);
 }
开发者ID:LimeDeck,项目名称:cashier-braintree,代码行数:27,代码来源:SubscriptionBuilder.php

示例5: registerFromHostedPage

 /**
  * Retrieve a hosted page and register a user based on the result of the payment.
  *
  * @param $id
  * @return null
  * @throws UserMismatchException
  */
 public function registerFromHostedPage($id)
 {
     $result = ChargeBee_HostedPage::retrieve($id);
     // TODO: Check if subscription was successful or failed.
     // Check if the ID of the model is the same as the ID of the model that performed the payment
     if (!(int) base64_decode($result->hostedPage()->passThruContent) === $this->model->id) {
         throw new UserMismatchException('The user who performed the payment is not the user you are trying to attach the subscription to');
     }
     $subscriptionId = $result->hostedPage()->content['subscription']['id'];
     $result = ChargeBee_Subscription::retrieve($subscriptionId);
     $subscription = $result->subscription();
     $addons = $subscription->addons;
     $card = $result->card();
     $subscription = $this->model->subscriptions()->create(['subscription_id' => $subscription->id, 'plan_id' => $subscription->planId, 'next_billing_at' => $subscription->currentTermEnd, 'trial_ends_at' => $subscription->trialEnd, 'quantity' => $subscription->planQuantity, 'last_four' => $card->last4]);
     if ($addons) {
         foreach ($addons as $addon) {
             $subscription->addons()->create(['quantity' => $addon->quantity, 'addon_id' => $addon->id]);
         }
     }
     return $subscription;
 }
开发者ID:TijmenWierenga,项目名称:LaravelChargebee,代码行数:28,代码来源:Subscriber.php


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