Promos API Integration Overview

Use the Affirm Promos API to add dynamic monthly pricing and educational modals to your site. Customize promotional messaging, integrate prequalification, and enhance customer engagement with flexible financing options. Includes setup, API requests, and implementation details.

Overview

The Prequalification Callback API provides a way to register a callback function to be invoked when customers reach a decision outcome on the prequalification application. Whether the customer was approved or denied for prequalification, the API provides a way for your web application to respond to events on a real‑time basis. The guide provides the necessary steps to start receiving prequalification events.

1. Embed Affirm.js and enable Prequalification

📘

See our Embed Affirm and Prequalification Overview documentation page for more details.

Include the following script in the head section on every page on your site.

<script>
 _affirm_config = {
   public_api_key:  "YOUR_PUBLIC_KEY",
   script:          "https://cdn1-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");
</script>

2. Register a callback function

Affirm currently provides two implementation options for registering a callback function. We recommended registering the callback function directly with Affirm.js, although this requires having access to the global scope of the parent document. If you're a third‑party provider with an embedded <iframe> tag within the parent document, listening to messages dispatched by the postMessage API will be necessary to receive events. The following table outlines the compatibility between the two methods given how the client application is embedded within the parent document:

Integration method

Embedded