Laravel Cashier: should I add a trial period in St

2019-08-20 08:37发布

问题:

Quoting Laravel Cashier documentation:

If you would like to offer trial periods to your customers while still collecting payment method information up front, You should use the trialDays method when creating your subscriptions.

Assuming I want to add a 30 days trial period to my subscriptions, I can create a subscription with this code:

$user->newSubscription('main', 'monthly')
        ->trialDays(30)
        ->create($stripeToken);

As a Stripe user, should I add a trial period in Stripe plan too?

I'm not sure to understand the logic of Laravel Cashier here. It seems redundant to declare something at two different places.

回答1:

I would say its not necessary. If you're adding trial days at the time of subscription creation (trial_end parameter when using the API directly), that will take precedence over the trial days defined on a plan anyway!



回答2:

I'm not 100% satisfied with these answers, since the question was specifically asking about using Cashier.

Creating a subscription using Cashier will always set a trial_end

protected function buildPayload()
{
    return array_filter([
        'billing_cycle_anchor' => $this->billingCycleAnchor,
        'coupon' => $this->coupon,
        'metadata' => $this->metadata,
        'plan' => $this->plan,
        'quantity' => $this->quantity,
        'tax_percent' => $this->getTaxPercentageForPayload(),
        'trial_end' => $this->getTrialEndForPayload(),
    ]);
}

This trial_end will either be "now" (no trial) by default or whatever you pass optionally in ->trialDays(XXX).

The trial period that is defined within Stripe seems to be ignored.

I agree, the expected behaviour should be that what you pass via cashier will take precedence over the trial days defined on a plan. However this doesn't seem to be the case. (cashier v8.0.1)



回答3:

If you define a trial period in stripe then there is no need to do it in code. If you you don't want trial every time someone subscribes you might want to have it in code.