When test ordering something on my site, it shows the error URL of some products could not be reached
after clicking order after filling out the test credit card details.
I am using the hargo-hugo
theme with hugo for setting up snipcart.
How do I debug this issue?
There are different possibilities:
Check that you are using the correct API key corresponding to the test version the correct snipcart account you want to use, not some old default value. In the hargo-hugo
theme, that is set as the snipcartApiKey
in the [params]
section of the hugo.toml
or older config.toml
. The API key can be looked up in your snipcart account.
Check that the domain in that snipcart account is properly set up, note www.something.com
is different from something.com
. You might need to add mutliple then. not only the default domain.
Make sure your website sets the data-item-url
correctly in the HTML or in the JSON respones (if you set up a custom JSON response for the validation. For hargo-hugo
, you can just check the HTML in the developer tools of the browser on the button that says "add to cart" if you are on the page for an individual product. This URL should either be relative and the current domain should be on a allow-listed domain of the snipcart account or it should be absolute and the domain part of that absolute domain should be allow-listed in the snipcart account.
If the URL in the data-item-url
is absolute, this exact URL will be used for validation and not the site you are currently on. If the contents differ from the ones on the site you are testing it on, the validation will fail.
Check that the protocol/scheme is set to http
or https
correctly for each allowed domain in the snipcart account.
All the allowed domains in the account that are expected to be potentially used need to be accessible from the public internet, e.g. some local hostname like myserver.local
or even localhost
won't work. See the stackoverflow question Snipcart "data-item-url not working on localhost" for good suggestions to fix this for testing setups.
See the snipcart documentation on order validation for how it works (really understanding how and why the flow works against hackers trying to modify prices can solve some more problems) and more suggestions what you need to do to make it work.
When understanding this, you can follow up with more nuanced debugging steps like checking in the server logs of your webserver if a request is made from snipcart to validate and if the URL on which that request is made and the answer your server gives match what you expected and want.
You can also check the debug logs of the snipcart server/service when clicking on the profile logo on the top right and then scroll down to Developer Logs
on the list appearing on the right.