I'm new to Stripe PHP Laravel. Are recurring payments in Laravel Stripe possible for billing cycles that are not 1 month but 3 months or 6 months? Can anyone send me to the right documentation because I'm not familiar with the term? I have checked cycles in Stripe but I don't think that's what I need.
Asked
Active
Viewed 593 times
-3
-
Not sure why all the downvotes for a very valid question. I found it very hard to find information about changing the intervals for Cashier/Stripe - thanks for asking, and glad there's an answer here! – benjaminhull Dec 02 '20 at 09:28
1 Answers
2
On stripe dashboard under belling-> products create new product for example prod-1 , add pricing plan for example plan-1(stripe will generate ID for this plan) to that product(prod-1), while adding pricing plan under billing interval select or customize the interval that you want.
Now let work on laravel app side. I will recommend to use Laravel Cashier.
Run Composer composer require laravel/cashier
Update your USER Migration Table:
Schema::table('users', function ($table) {
$table->string('stripe_id')->nullable()->collation('utf8mb4_bin');
$table->string('card_brand')->nullable();
$table->string('card_last_four', 4)->nullable();
$table->timestamp('trial_ends_at')->nullable();
});
Schema::create('subscriptions', function ($table) {
$table->increments('id');
$table->unsignedInteger('user_id');
$table->string('name');
$table->string('stripe_id')->collation('utf8mb4_bin');
$table->string('stripe_plan');
$table->integer('quantity');
$table->timestamp('trial_ends_at')->nullable();
$table->timestamp('ends_at')->nullable();
$table->timestamps();
});
Update Your User Model:
use Laravel\Cashier\Billable;
class User extends Authenticatable
{
use Billable;
}
In your Controller ex. MyController.php:
use Cartalyst\Stripe\Laravel\Facades\Stripe;
use Cartalyst\Stripe\Exception\CardErrorException;
use Session;
use Auth;
public function store(Request $request)
{
$token = $_POST['stripeToken'];
$user = Auth::user();
try {
$user->newSubscription('prod-1', 'ID of plan-1')->create($token);
Session::flash('success', 'You are now a premium member');
return redirect()->back();
} catch (CardErrorException $e) {
return back()->withErrors('Error!'. $e->getMessage());
}
}
In your view:
<form action="{{ route('subscribe')}}" method="POST">
<script
src="https://checkout.stripe.com/checkout.js" class="stripe-button"
data-key="pk_test_0000000000000000000" // Your api key
data-image="/images/marketplace.png" // You can change this image to your image
data-name="My App Name"
data-description="Subscription for 1 weekly box"
data-amount="2000" //the price is in cents 2000 = 20.00
data-label="Sign Me Up!">
</script>
</form>
Create Route:
Route::POST('subscription', 'MyController@store')->name('susbcribe');
Let me know if it works.

livreson ltc
- 733
- 8
- 22
-
thanks. I really wondered why this question got downvoted. turns out, this setting is available in Stripe. thank you very much! – James Arnold Apr 21 '19 at 23:56
-
@James Arnold, it's because you didn't post any code with your question. The rule here is that you have to share codes where you got stuck so people can take a look and help you out instead of starting from scratch. – livreson ltc Apr 22 '19 at 00:10