I'm currently testing product payment on local (Wampserver) but I always have a 'domain-crawling-failed' error I can't solve when it comes to confirm payment.
https://i.stack.imgur.com/HVxjd.png
https://i.stack.imgur.com/iU0zJ.png
I've set 'localhost' as default domain on snipcart and also put sub-domains :
https://i.stack.imgur.com/AhouQ.png
My products with the buy-button are in the page:"http://localhost/Site/boutique". Here is the code :
<ul id="Product-List">
<li class="product-item shown">
<img src="assets/word.png">
<div class="product-description">
<h1>Word Guide Complet</h1>
</div>
<div class="product-pay">
<h2>39,99 €</h2>
<button class="buy-button snipcart-add-item"
data-item-id="word"
data-item-price="39.99"
data-item-url="http://localhost/Site/boutique"
data-item-description="Le guide complet de Word"
data-item-image="assets/word.png"
data-item-name="Word Guide Complet">
Ajouter au panier
</button>
</div>
</li>
<li class="product-item shown">
<img src="assets/excel.png">
<div class="product-description">
<h1>Excel Guide Complet</h1>
</div>
<div class="product-pay">
<h2>39,99 €</h2>
<button class="buy-button snipcart-add-item"
data-item-id="excel"
data-item-price="39.99"
data-item-url="http://localhost/Site/boutique"
data-item-description="Le guide complet de Excel"
data-item-image="assets/excel.png"
data-item-name="Excel Guide Complet">
Ajouter au panier
</button>
</div>
</li>
<li class="product-item shown">
<img src="assets/powerpoint.png">
<div class="product-description">
<h1>Powerpoint Guide Complet</h1>
</div>
<div class="product-pay">
<h2>39,99 €</h2>
<button class="buy-button snipcart-add-item"
data-item-id="powerpoint"
data-item-price="39.99"
data-item-url="http://localhost/Site/boutique"
data-item-description="Le guide complet de Powerpoint"
data-item-image="assets/powerpoint.png"
data-item-name="Powerpoint Guide Complet">
Ajouter au panier
</button>
</div>
</li>
</ul>
The
Snipcart
needs to validate the product price, and to do that it will try to access thedata-item-url
and try to validate the product price there.But, the Snipcart can not access your
localhost
. You have to put the validator data somewhere where theSnipcart
can access it. You can do this in several ways:SOLUTION 1
For example, you can create an project on
codesandbox.io
(or any other online editor). In that project, create onejson
file and put all the productsids
andprices
inside. Now you can set the value ofdata-item-url
to point on thatjson
. Sincecodesandbox.io
project is on the cloud,Snipcart
will be able to access it and validate the product price. Downside of this solution is that you will need to modify manually thisjson
whenever you have the new product or you change the price of existing product.NOTE: Remember to add
codesandox.io
domain toSnipcart's
Domains and Subdomains inSnipcart
Dashboard.Example of
json
file incodesandbox
project:SOLUTION 2
You can use the
ngrok
npm package to tunnel the data to yourlocalhost
. That waySnipcart
will be able to validate the products even in yourlocalhost
. Downside of this solution is that you need to createngrok
account to be able to use the package.ngrok
package:SOLUTION 3
This is the best solution if you ask me. Create an endpoint on your server that will return all the products from your database in a
json
document. When you do that, you can setdata-item-url
to point on thatendpoint
on your server. Whenever theSnipcart
needs to validate something it will call your server, and your server will always return up-to-date data. All you need to do now is to host your server somewhere in the cloud soSnipcart
can access that endpoint.NOTE: Remember to add your server domain to
Snipcart's
Domains and Subdomains inSnipcart
Dashboard.