PHP code example of 22digital / laravel-cashier-fastspring
1. Go to this page and download the library: Download 22digital/laravel-cashier-fastspring library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
22digital / laravel-cashier-fastspring example snippets
// we create session and return it to frontend to care
$builder = Auth::user()->newSubscription('default', $selectedPlan);
$session = $builder->create();
// we create session and return it to frontend to care
$builder = Auth::user()->newSubscription('default', $selectedPlan);
$session = $builder->create();
$builder = Auth::user()->newSubscription('default', $selectedPlan)
->withCoupon('free-ticket-to-Mars')
->quantity(1); // yeap no ticket for returning
$session = $builder->create();
$subscription = $user->subscription('default');
// check if you should serve or not
$subscription->valid();
// check if its state is active
$subscription->active();
// check if its state is deactived
$subscription->deactivated();
// check if its state is overdue
$subscription->overdue();
// alias: onTrial(). check if its state is trial
$subscription->trial();
// alias: canceled(), onGracePeriod(). check if its state is canceled
$subscription->cancelled();
if ($user->subscribedToPlan('monthly', 'default')) {
//
}
$activePeriod = $user->subscription('default')->activePeriodOrCreate();
// if you don't want to create an active subscription period immediately when no exist
// you can use activePeriod method as below
// you can set a cron job for creation of new periods
// or do it in your way
$activePeriod = $user->subscription('default')->activePeriod();