Au clic sur le bouton. Oyst appel la méthode window.OYST.getOneClickURL dans votre contexte javascript.

Vous devrez implémenter méthode pour qu'elle interroge votre backend. Pour récupérer le contenu de la modale d'achat en 1click.

Le champ url de la variable settings de la méthode getOneClickURL correspond à l'url de votre backend qui retournera le contenu de la modale d'achat en 1click.

<div id="oyst-1click-button" data-smart="true"></div>
<script>
	window.__OYST__ = window.__OYST__ || {}
  window.__OYST__.getOneClickURL = function (cb) {
  	$(function () {
    	var form = new FormData();
      form.append("product_reference", "ID_DU_PRODUIT");
      var settings = {
      	"async": true,
        "crossDomain": true,
        "url": "/GET_1_CLICK_URL",
        "method": "POST",
        "headers": {
        	"cache-control": "no-cache"
        },
        "processData": false,
        "contentType": false,
        "mimeType": "multipart/form-data",
        "data": form
   		}
      $.ajax(settings).done(function (data) {
      	data = JSON.parse(data)
        cb(null, data.url)
        console.log(data.url);
      })
 		})
  }
</script>
<script src="https://cdn.sandbox.oyst.eu/1click/script/script.min.js"> </script>

📘

product_reference

Le front doit passer à votre backend, l'ensemble des informations nécessaire pour retrouver le produit.

Dans l'exemple ci desssus, on passe l'id du produit dans le champs "product_reference".