@tykus Thanks for the reply. So I am not confused about the link mark up necessarily, but moreso how to retrieve that plan id in the route, because right now I just have created 2 routes, 1 for each plan and I've manually inserted the id myself into the route, like this
Route::get('/subscribe', function (Request $request) {
return $request->user()->subscribe('(1523484)');
});
But I would prefer to just be able to just have 1 route with a variable for the plan id that I can pass to the route somehow. I just can't figure out how to get this data to the route. For example:
Route::get('/subscribe', function (Request $request) {
return $request->user()->subscribe('($plan-id)');
});
And then each link will send the proper id to the checkout function.
I also meant to link to the function in the controller, but I was struggling to figure out which was the one I needed. this one is huge, so sorry for the wall of text, but I think this is the function that is being called with that route. If I'm correct, perhaps the id could be passed here?
public function url(): string
{
$response = LemonSqueezy::api('POST', 'checkouts', [
'data' => [
'type' => 'checkouts',
'attributes' => [
'custom_price' => $this->customPrice,
'checkout_data' => array_merge(
array_filter($this->checkoutData, fn ($value) => $value !== ''),
['custom' => $this->custom]
),
'checkout_options' => array_filter([
'embed' => $this->embed,
'logo' => $this->logo,
'media' => $this->media,
'desc' => $this->desc,
'discount' => $this->discount,
'dark' => $this->dark,
'subscription_preview' => $this->subscriptionPreview,
'button_color' => $this->buttonColor ?? null,
], function ($value) {
return ! is_null($value);
}),
'product_options' => [
'redirect_url' => $this->redirectUrl ?? config('lemon-squeezy.redirect_url'),
],
'expires_at' => isset($this->expiresAt) ? $this->expiresAt->format(DateTimeInterface::ATOM) : null,
],
'relationships' => [
'store' => [
'data' => [
'type' => 'stores',
'id' => $this->store,
],
],
'variant' => [
'data' => [
'type' => 'variants',
'id' => $this->variant,
],
],
],
],
]);
Links that might help:
Payment processor docs for this specific checkout function
https://github.com/lmsqueezy/laravel#creating-subscriptions
file that contains that giant function that I'm not 100% positive is the one I need for this:
https://github.com/lmsqueezy/laravel/blob/main/src/Checkout.php