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
Snipcartneeds to validate the product price, and to do that it will try to access thedata-item-urland try to validate the product price there.But, the Snipcart can not access your
localhost. You have to put the validator data somewhere where theSnipcartcan 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 onejsonfile and put all the productsidsandpricesinside. Now you can set the value ofdata-item-urlto point on thatjson. Sincecodesandbox.ioproject is on the cloud,Snipcartwill be able to access it and validate the product price. Downside of this solution is that you will need to modify manually thisjsonwhenever you have the new product or you change the price of existing product.NOTE: Remember to add
codesandox.iodomain toSnipcart'sDomains and Subdomains inSnipcartDashboard.Example of
jsonfile incodesandboxproject:SOLUTION 2
You can use the
ngroknpm package to tunnel the data to yourlocalhost. That waySnipcartwill be able to validate the products even in yourlocalhost. Downside of this solution is that you need to createngrokaccount to be able to use the package.ngrokpackage: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
jsondocument. When you do that, you can setdata-item-urlto point on thatendpointon your server. Whenever theSnipcartneeds 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 soSnipcartcan access that endpoint.NOTE: Remember to add your server domain to
Snipcart'sDomains and Subdomains inSnipcartDashboard.