$coupon = Input::get('coupon');
$user = User::find(1);
$user->applyCoupon($coupon);
$token = Input::get('stripeToken');
$user = User::find(1);
$user->updateDefaultCard($token);
$user = User::find(1);
if ($user->isSubscribed())
{
//
}
$user = User::find(1);
$subscriptions = $user->subscriptions;
Subscribing a user to a plan
$token = Input::get('stripeToken');
$user = User::find(1);
$user
->subscription()
->onPlan('monthly')
->create($token);
Subscribing a user to a plan and apply a coupon to this new subscription
$token = Input::get('stripeToken');
$coupon = Input::get('coupon');
$user = User::find(1);
$user
->subscription()
->onPlan('monthly')
->withCoupon($coupon)
->create($token);
Create a trial subscription
$token = Input::get('stripeToken');
$user = User::find(1);
$user
->subscription()
->onPlan('monthly')
->trialFor(Carbon::now()->addDays(14))
->create($token);
Cancel a Subscription using its id
$user = User::find(1);
$user
->subscription(3)
->cancel();
Cancelling a subscription by passing a Cartalyst\Stripe\Subscription\IlluminateSubscription
object.
$user = User::find(1);
$subscription = $user->subscriptions()->where('stripe_id', 'sub_48w0VyQzcNWCe3')->first();
$user
->subscription($subscription)
->cancel();
Cancel a subscription at the End of the Period
$user = User::find(1);
$user
->subscription(3)
->cancelAtEndOfPeriod();
Apply a trial period on a subscription
$user = User::find(1);
$user
->subscription(3)
->setTrialPeriod(Carbon::now()->addDays(14))
Removing the trial period from a subscription
$user = User::find(1);
$user
->subscription(3)
->removeTrialPeriod()
Apply a coupon to an existing subscription
$coupon = Input::get('coupon');
$user = User::find(1);
$user
->subscription(3)
->applyCoupon($coupon);
Remove a coupon from an existing subscription
$user = User::find(1);
$user
->subscription(3)
->removeCoupon();
Resume a canceled subscription
$user = User::find(1);
$user
->subscription(3)
->resume();
Resume a canceled subscription and remove its trial period
$user = User::find(1);
$user
->subscription(3)
->skipTrial()
->resume();
Resume a canceled subscription and change its trial period end date
$user = User::find(1);
$user
->subscription(3)
->trialFor(Carbon::now()->addDays(14))
->resume()
First, we need to grab the subscription:
$user = User::find(1);
$subscription = $user->subscriptions->find(3);
To determine if the subscription is on the trial period, you may use the onTrialPeriod()
method:
if ($subscription->onTrialPeriod())
{
//
}
To determine if the subscription is marked as canceled, you may use the canceled
method:
if ($subscription->canceled())
{
//
}
To determine if the subscription has expired, you may use the expired
method:
if ($subscription->expired())
{
//
}
You may also determine if a subscription, is still on their "grace period" until the subscription fully expires. For example, if a user cancels a subscription on March 5th that was scheduled to end on March 10th, the user is on their "grace period" until March 10th.
if ($subscription->onGracePeriod())
{
//
}
Still a work in progress.
$user = User::find(1);
$cards = $user->cards;
$token = Input::get('stripeToken');
$user = User::find(1);
$user
->card()
->create($token);
If you want to make this new credit card the default credit card, you can use the ->setDefault()
:
$user = User::find(1);
$user
->card()
->setDefault()
->create($token);
$user = User::find(1);
//$card = $user->cards->find(3);
$arguments = [
'name' => 'John Doe',
];
$user
->card(3)
->update($arguments);
//$user->updateCard($card, $arguments);
$user = User::find(1);
$user
->card(3)
->delete();
$user = User::find(1);
$charges = $user->charges;
$user = User::find(1);
$user
->charge(3)
->refund(:amount);