Affirm-developers

Overview

This reference documents every object and method available in Affirm's browser-side JavaScript library, Affirm.js.

Including and initializing Affirm.js

Include the Affirm.js script on each page of your site.

In order to create an instance of Affirm, you will need to pass your public key and the environment you are pointing too. The Affirm object is your entry point to the rest of the Affirm.js SDK.

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

When you’re ready to accept live transactions, replace the sandbox key with your live key in production as well as the environment URL.

Learn more about how API keys work in sandbox mode and production mode.

var affirm_config = {
  public_api_key: "{PUBLIC_API_KEY}",  /* replace with public api key */
  script:         "https://sandbox.affirm.com/js/v2/affirm.js"
};

(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");

Method arguments

public_api_key
required
stringYour public API key.
script
required
stringSee environment URL available.

Updated 2 months ago


Overview


This reference documents every object and method available in Affirm's browser-side JavaScript library, Affirm.js.

Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.