Aperçu

Cette référence documente chaque objet et méthode disponible dans la bibliothèque JavaScript côté navigateur d'Affirm, Affirm.js.

Inclure et initialiser Affirm .js

Inclure le affirm.js en tête de votre modèle de page global.

To create an instance of Affirm, you must pass your public API key and the environment you are pointing to. The Affirm object is your entry point into the rest of the Affirm.js SDK.

Your Affirm public API key is required when calling this function because it identifies your website to Affirm.

Lorsque vous êtes prêt à accepter les transactions en direct, remplacez la clé sandbox par votre clé active en production ainsi que l’URL de l’environnement.

<script>
const _affirm_config = {
		public_api_key: "YOUR_PUBLIC_API_KEY", /* replace with public api key */
		script: "https://cdn1-sandbox.affirm.com/js/v2/affirm.js",
		locale: "en_US",
		country_code: "USA",
	};

(function(m,g,n,d,a,e,h,c){var b=m[n]||{},k=document.createElement(e),p=document.getElementsByTagName(e)[0],l=function(a,b,c){return function(){a[b]._.push([c,arguments])}};b[d]=l(b,d,"set");var f=b[d];b[a]={};b[a]._=[];f._=[];b._=[];b[a][h]=l(b,a,h);b[c]=function(){b._.push([h,arguments])};a=0;for(c="set add save post open empty reset on off trigger ready setProduct".split(" ");a<c.length;a++)f[c[a]]=l(b,d,c[a]);a=0;for(c=["get","token","url","items"];a<c.length;a++)f[c[a]]=function(){};k.async=
  !0;k.src=g[e];p.parentNode.insertBefore(k,p);delete g[e];f(g);m[n]=b})(window,_affirm_config,"affirm","checkout","ui","script","ready","jsReady");
</script>

Arguments de méthode

public_api_key
Obligatoire
stringVotre clé API publique.
script
Obligatoire
stringSandbox : https://cdn1-sandbox.affirm.com/js/v2/affirm.js

Production : https://cdn1.affirm.com/js/v2/affirm.js

Ready

A callback can be passed to affirm.ui.ready() that is called when affirm.js finishes loading.

affirm.ui.ready(function() {
  console.log('Affirm JS ready!');
});