Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

bigblueboss's avatar

Stripe and Cashier (help!)

$user = User::find(1);

$user->newSubscription('main', 'monthly')->create($creditCardToken);

This is what laravel tells me to use for creating a new subscription. But I'm not sure about how the flow works. When a person makes a payment, do i do a Route::post and just put this information in there, expecting laravel to take care of everything? I know that laravel will make changes to the database, but where is the validation happening (credit card going through validation)?

0 likes
1 reply
jekinney's avatar
Level 47

Stripes JavaScript snip it takes care of validation whether in their js form or your html form and getting the token (charge approved). Cashier assigns the user your subscription etc on your site and sends stripe the data also for stripe to assign the user (using the users email) the required subscription for future billing.

Read the code in the vender file the comments explain a lot.

Please or to participate in this conversation.