You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would like to implement the checkout option only with email, currently in my web app people can buy documents and enter their email, they press "Buy" and the idea is to send them to the checkout:
Route::get('/buy', function () {
return auth()->user()->checkout('variant-id');
});
But, since they are not users and I dont want to add that step since it isnt necessary on my website. I'm trying to implement this.
What occurred to me at the moment was to do this in my controller:
$email = $validated['email'];
$user = User::where('email', $email)->first();
if (!$user) {
$user = new User();
$user->email = $email;
// You can add more fields here if necessary
$user->save();
}
Auth::login($user);
// Get the checkout URL
$url = ('buy');
return Inertia::location($url);
And I made the name and password nullable, but I don't know how correct it is to follow this path. I saw that this way of handling checkout is common in today's web apps to skip the registration step when it is not necessary.
What could be a more optimal way to do this?
I upload it here because maybe it can be useful to people too!
The text was updated successfully, but these errors were encountered:
Also, if you want to still store the information about the user who purchased with webhooks, you need to overwrite the LemonSqueezy webhook, which will save user info into the table, otherwise when there is no "customer" data provided order will not be created in db.
I'll mark this as a feature request for now and will have a think on how to cater better for guest checkouts later one. Thanks for suggesting and thanks @karakhanyans for that example!
Hi guys!
I would like to implement the checkout option only with email, currently in my web app people can buy documents and enter their email, they press "Buy" and the idea is to send them to the checkout:
But, since they are not users and I dont want to add that step since it isnt necessary on my website. I'm trying to implement this.
What occurred to me at the moment was to do this in my controller:
And I made the name and password nullable, but I don't know how correct it is to follow this path. I saw that this way of handling checkout is common in today's web apps to skip the registration step when it is not necessary.
What could be a more optimal way to do this?
I upload it here because maybe it can be useful to people too!
The text was updated successfully, but these errors were encountered: