Closed devhoussam1998 closed 8 months ago
Not just from the button, even I am getting the same error in command too.
- Here is the log
[2024-03-18 10:02:56] local.ERROR: HTTP request returned status code 404:
{"jsonapi":{"version":"1.0"},"errors":[{"detail":"The related resource does not exist.","source":{"pointer":"\/data\/rel (truncated...)
{"exception":"[object] (Illuminate\\Http\\Client\\RequestException(code: 404): HTTP request returned status code 404:
{\"jsonapi\":{\"version\":\"1.0\"},\"errors\":[{\"detail\":\"The related resource does not exist.\",\"source\":{\"pointer\":\"\\/data\\/rel (truncated...)
Not just from the button, even I am getting the same error in command too.
Here is the log
[2024-03-18 10:02:56] local.ERROR: HTTP request returned status code 404: {"jsonapi":{"version":"1.0"},"errors":[{"detail":"The related resource does not exist.","source":{"pointer":"\/data\/rel (truncated...) {"exception":"[object] (Illuminate\\Http\\Client\\RequestException(code: 404): HTTP request returned status code 404: {\"jsonapi\":{\"version\":\"1.0\"},\"errors\":[{\"detail\":\"The related resource does not exist.\",\"source\":{\"pointer\":\"\\/data\\/rel (truncated...)
I hope the core team will fix this soon as possible
Did you set the Store Identifier correctly by using the LEMON_SQUEEZY_STORE env variable? Example: LEMON_SQUEEZY_STORE=your-lemon-squeezy-store-id
https://github.com/lmsqueezy/laravel/tree/main?tab=readme-ov-file#store-identifier
your-lemon-squeezy-store-id
of course i setup everything
I was almost sure that the response you are getting comes from the related resources on the lemonsqueezy api, to be more specific here: https://github.com/lmsqueezy/laravel/blob/main/src/Checkout.php#L243
Let's try to debug it together, do you have more details on the exception that you could share?
Also can you double check that the value of the LEMON_SQUEEZY_STORE env variable is the ID of your store, the id is a number and can be found here: https://app.lemonsqueezy.com/settings/stores
I was almost sure that the response you are getting comes from the related resources on the lemonsqueezy api, to be more specific here: https://github.com/lmsqueezy/laravel/blob/main/src/Checkout.php#L243
Let's try to debug it together, do you have more details on the exception that you could share?
Also can you double check that the value of the LEMON_SQUEEZY_STORE env variable is the ID of your store, the id is a number and can be found here: https://app.lemonsqueezy.com/settings/stores
@heyjorgedev I follow the docs and this video https://www.youtube.com/watch?v=Zx6VhRzOMkQ&ab_channel=CodeWithTony
I share the code and also here is the error: https://flareapp.io/share/w5BZdwX5
my .env contains:
LEMON_SQUEEZY_API_KEY=xxxxxxxxxxxxxx
LEMON_SQUEEZY_STORE=628xxx
LEMON_SQUEEZY_SIGNING_SECRET=xxx123
Sorry I couldn't get back to you sooner, thank you for the stack trace on flare! I still think one of those ids is wrong, so let's try to abstract from the package and dig into curl requests:
With curl we can at least check if the store and the variant are correct and exclude that from debug:
Pay attention to the values in {}, you need to replace them with your env variables or variant id.
To retrieve a store you can execute this:
curl "https://api.lemonsqueezy.com/v1/stores/{LEMON_SQUEEZY_STORE}" \
-H 'Accept: application/vnd.api+json' \
-H 'Content-Type: application/vnd.api+json' \
-H 'Authorization: Bearer {LEMON_SQUEEZY_API_KEY}'
To retrieve a variant you can execute this:
curl "https://api.lemonsqueezy.com/v1/variants/{variant-id}" \
-H 'Accept: application/vnd.api+json' \
-H 'Content-Type: application/vnd.api+json' \
-H 'Authorization: Bearer {LEMON_SQUEEZY_API_KEY}'
What I want to see is if you are not getting an answer like this on both of the requests:
{"jsonapi":{"version":"1.0"},"errors":[{"detail":"The route v1\/stores\/dasdasd could not be found.","status":"404","title":"Not Found"}]}%
Thank for replay @heyjorgedev
Here is what I get:
Route/Web.php
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;
Route::get('/buy', function (Request $request) {
$checkout = $request->user()->checkout('220882');
return view('billing', ['checkout' => $checkout]);
});
For:
curl "https://api.lemonsqueezy.com/v1/stores/{LEMON_SQUEEZY_STORE}" \
-H 'Accept: application/vnd.api+json' \
-H 'Content-Type: application/vnd.api+json' \
-H 'Authorization: Bearer {LEMON_SQUEEZY_API_KEY}'
Here is what I get:
{"jsonapi":{"version":"1.0"},"links":{"self":"https:\/\/api.lemonsqueezy.com\/v1\/stores\/62843"},"data":{"type":"stores","id":"62843","attributes":{"name":"Test","slug":"test956555","domain":"test956555.lemonsqueezy.com","url":"https:\/\/test956555.lemonsqueezy.com","avatar_url":"https:\/\/eu.ui-avatars.com\/api\/?name=Test&length=1&background=2DD272&color=fff&size=64&rounded=true","plan":"free","country":"US","country_nicename":"United States","currency":"USD","total_sales":0,"total_revenue":0,"thirty_day_sales":0,"thirty_day_revenue":0,"created_at":"2024-01-04T18:11:34.000000Z","updated_at":"2024-01-04T18:11:34.000000Z"},"relationships":{"products":{"links":{"related":"https:\/\/api.lemonsqueezy.com\/v1\/stores\/62843\/products","self":"https:\/\/api.lemonsqueezy.com\/v1\/stores\/62843\/relationships\/products"}},"orders":{"links":{"related":"https:\/\/api.lemonsqueezy.com\/v1\/stores\/62843\/orders","self":"https:\/\/api.lemonsqueezy.com\/v1\/stores\/62843\/relationships\/orders"}},"subscriptions":{"links":{"related":"https:\/\/api.lemonsqueezy.com\/v1\/stores\/62843\/subscriptions","self":"https:\/\/api.lemonsqueezy.com\/v1\/stores\/62843\/relationships\/subscriptions"}},"discounts":{"links":{"related":"https:\/\/api.lemonsqueezy.com\/v1\/stores\/62843\/discounts","self":"https:\/\/api.lemonsqueezy.com\/v1\/stores\/62843\/relationships\/discounts"}},"license-keys":{"links":{"related":"https:\/\/api.lemonsqueezy.com\/v1\/stores\/62843\/license-keys","self":"https:\/\/api.lemonsqueezy.com\/v1\/stores\/62843\/relationships\/license-keys"}},"webhooks":{"links":{"related":"https:\/\/api.lemonsqueezy.com\/v1\/stores\/62843\/webhooks","self":"https:\/\/api.lemonsqueezy.com\/v1\/stores\/62843\/relationships\/webhooks"}}},"links":{"self":"https:\/\/api.lemonsqueezy.com\/v1\/stores\/62843"}}}%
For:
curl "https://api.lemonsqueezy.com/v1/variants/220882" \
-H 'Accept: application/vnd.api+json' \
-H 'Content-Type: application/vnd.api+json' \
-H 'Authorization: Bearer {LEMON_SQUEEZY_API_KEY}'
Here is what I get:
{"jsonapi":{"version":"1.0"},"errors":[{"detail":"Unauthenticated.","status":"401","title":"Unauthorized"}]}%
@devhoussam1998 there you go, that product you are showing me in the screenshot is a product that has variants, from the curl request you made to the variants endpoint I can see that the id you have for the variant is wrong, probably you have the product id there instead.
I'm not on the computer so I can't provide you with nice step by step screenshots on how to get the variant id from the lemonsqueezy dashboard but I'll try to give you a text step by step guide for the time being to see if you get there:
When I get to the computer I can help more but I hope this is enough to get you going, now I am sure that what you have wrong is the variant id, and that's easy to fix
@devhoussam1998 there you go, that product you are showing me in the screenshot is a product that has variants, from the curl request you made to the variants endpoint I can see that the id you have for the variant is wrong, probably you have the product id there instead.
I'm not on the computer so I can't provide you with nice step by step screenshots on how to get the variant id from the lemonsqueezy dashboard but I'll try to give you a text step by step guide for the time being to see if you get there:
- Click on the product on the lemon Squeezy dashboard
- A slide hover should appear
- Scroll the slide over until you see "Variants"
- You should have a "..." icon on the right side of each variant
- Click on it and you should have an option "Copy Id" or "Copy Variant ID"
- Click on it, that's the id you should use to call the checkout method
When I get to the computer I can help more but I hope this is enough to get you going, now I am sure that what you have wrong is the variant id, and that's easy to fix
thank you so mush @heyjorgedev now I understand the problem is wrong variant id
it works thank you @heyjorgedev
Lemon Squeezy for Laravel Version
1.5
Laravel Version
11.0
PHP Version
8.2
Description
Steps To Reproduce
Web.php
billing.blade.php