/**
  * Get the current discount for the given team.
  *
  * @param  Request  $request
  * @param  string  $userId
  * @return Response
  */
 public function current(Request $request, $teamId)
 {
     $team = Spark::team()->where('id', $teamId)->firstOrFail();
     if ($coupon = $this->coupons->forBillable($team)) {
         return response()->json($coupon->toArray());
     }
 }
 /**
  * Handle a cancelled customer from a Stripe subscription.
  *
  * @param  array  $payload
  * @return Response
  */
 protected function teamSubscriptionDeleted(array $payload)
 {
     $team = Spark::team()->where('stripe_id', $payload['data']['object']['customer'])->first();
     if ($team) {
         $team->subscriptions->filter(function ($subscription) use($payload) {
             return $subscription->stripe_id === $payload['data']['object']['id'];
         })->each(function ($subscription) {
             $subscription->markAsCancelled();
         });
     }
     event(new TeamSubscriptionCancelled($team));
     return new Response('Webhook Handled', 200);
 }
Esempio n. 3
0
 /**
  * {@inheritdoc}
  */
 public function create($user, array $data)
 {
     return Spark::team()->forceCreate(['owner_id' => $user->id, 'name' => $data['name'], 'trial_ends_at' => Carbon::now()->addDays(Spark::teamTrialDays())]);
 }