Learn how to configure plans for your Spark Stripe application.
config/spark.php
configuration file contains a trial_days
option with a value of 5
. This configuration option determines the amount of time the user is allowed to use your application during their free trial period. You are free to modify this configuration value based on your application’s needs; however, if a trial period is configured, Stripe Checkout requires it to be at least two days.
In practical terms, this configuration option simply determines when the onTrial
method of the billable model will begin returning false
instead of true
:
trial_days
configuration option to the individual plan configuration array and remove the trial_days
configuration option that is within the billable configuration array:
trialDays
method provided by the model instance will return false
. You may examine the results of the subscribed
method to conditionally show an alert to your user that they should select a subscription plan before beginning to use your application. For example, if you are using the Blade templating language:
checkPlanEligibility
callback registered within your application’s App\Providers\SparkServiceProvider
class. This callback will be invoked when a billable model attempts to subscribe to or switch to a new subscription plan:
config/spark.php
configuration file. In addition, you will need to instruct Spark how to calculate the current number of “seats” a billable model is currently using.
You may instruct Spark how to calculate the current number of “seats” a billable model is currently using via the chargePerSeat
method when configuring a billable model. Typically, this method should be called within the boot
method of your application’s App\Providers\SparkServiceProvider
class:
chargePerSeat
method is the term that your application uses to refer to a “seat”. In the case of a project management application, this would be a “project”. The second argument given to the chargePerSeat
method should be a closure that accepts the billable model and returns the current number of “seats” occupied by that model.
After configuring per-seat billing, Spark will automatically update the wording within your application’s billing portal to inform users that billing is calculated on a per-seat basis.
chargePerSeat
callback that was explained above will inform Spark of the current seat count that should be used when a customer initiates a subscription. However, you still need to inform Spark when to add or remove a seat when a user is using your application. For example, if building a project management application that bills per project, you would need to inform Spark when a user creates or deletes a project. You can accomplish this by calling the addSeat
and removeSeat
method:
IncompletePayment
exception that occurs and handle it by redirecting to Cashier’s payment page, while providing a redirect
location back to the page that triggered the addSeat
call:
monthly_incentive
and / or yearly_incentive
configuration options to your plan definition:
archived
configuration option to the plan’s configuration array. You should not completely remove the plan’s configuration if existing users of your application that have already subscribed to the plan will be allowed to continue their subscription: