Is the subscription actually created in the Stripe dashboard when you do it as above?
Are you running the code inside a try/catch block by any chance?
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I'm playing around abit with Stripe, and hit something i dont totally understand, I'm currently saveing the users card information, so i can charge it later, and sign it up for subscriptions, and im doing that like this:
public function store(Request $request)
{
$input = $request->all();
$user = User::findorFail(5);
$customer = $user->createAsStripeCustomer(Input::get('stripeToken'));
}
And when i want to charge the person it looks like this:
public function pay(Request $request)
{
$user = User::findorFail(5);
$user->charge(100000, [
"currency" => 'dkk',
"customer" => $user->stripe_id
]);
}
Theese two work just as i want it too, even though i dont pass a token to the charge, as in the docs. But when i use the newSubscription I'm doing it like this:
public function weekly(Request $request)
{
$user = User::findorFail(3);
$token = "";
$user->newSubscription('weekly','weekly')->create($token, [
"currency" => 'dkk'
]);
}
Here is my problem i dont understand which token it needs, currently i just use $token = ""; And that makes it work, if i dont have a variable it gives me an error. But what exactly happends here
$user->newSubscription('weekly','weekly')->create($token, [
"currency" => 'dkk'
]);
since it works with an empty variable?
Please or to participate in this conversation.