Guide d'intégration Affirm Lite

Grâce à l'intégration d'Affirm Lite, il est plus facile que jamais d'offrir à vos clients un moyen de paiement pratique.

🚧

Affirm Lite 1.0 → Mise à jour d'Affirm Landing Page

Si vous recherchez l'original « Affirm Lite », le produit a été renommé « Affirm Landing Page ». Ce produit continuera à fonctionner exactement comme avant et aucune modification n'est nécessaire pour les intégrations existantes. Pour consulter cette documentation, veuillez cliquer ici.

Aperçu

Ce guide vous explique les étapes d'intégration d'Affirm Lite, un produit conçu pour simplifier le processus de mise en œuvre et stimuler la conversion des clients. En seulement trois étapes clés, ce processus simple équipera votre site Web d'une expérience de paiement Affirm transparente, améliorant ainsi le parcours d'achat de vos clients.

Watch the video below for a detailed overview of the Affirm Lite customer checkout flow and the integration process:



Fonctionnalité

Affirm Lite keeps customers on your checkout page while they use Affirm to complete their purchase, functioning similarly to a widget. When a customer clicks the Affirm Lite checkout button, we display a pop-up window on the existing screen to guide them through the checkout process, resulting in the creation of an Affirm Virtual Card.

After the Affirm Virtual Card is created, card information can be transferred to the respective payment fields in these two ways:

  1. If you are using the query selectors for the Affirm Lite attributes, Affirm can autofill the card number, expiration date, and CVV fields with the Virtual Card’s information. See the Integration Steps section for details.
  2. Si le remplissage automatique n'est pas disponible, le client peut copier l'information directement à partir de la carte virtuelle et coller dans les champs correspondants.

🚧

iframe Autofill Compatibility

If your checkout page uses an iframe, browser security restrictions prevent Affirm Lite from autofilling customer information. As a result, customers must manually input their Affirm Virtual Card details by copying and pasting the information into the respective fields.


Page de secours d'Affirm Landing Page

To ensure a customer can complete their checkout even if Affirm Lite cannot identify a selector, you can use safeguards such as the Affirm Landing Page (previously Affirm Lite) fallback. You can activate this fallback by including the data-fallback-url attribute in your Affirm Lite code.

When you activate the fallback, the customer is redirected to the Affirm Landing Page to continue the checkout process. When the customer completes their purchase, we generate an Affirm Virtual Card. The customer then manually enters their Affirm Virtual Card details on your store's checkout page.


Étapes d'intégration

1. Add AFJS

To activate the Affirm object and use the broader Affirm.js SDK functionalities:

  1. Add the Affirm.js script in the <head> section of your global page.
  2. Initialize Affirm by:
    1. Adding your public API key, which authenticates your website's identity to Affirm, and
    2. Specifying the environment (sandbox or production) that you're targeting.
<script>
var _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>

2. Add the Affirm Lite Code Snippet

Embed the Affirm Lite code snippet into your HTML as a button that triggers the Affirm checkout experience. Affirm Lite requires an additional checkout button on your checkout page. If you prefer not to design your own button, Affirm provides a pre-styled checkout button. For details, see the Affirm Checkout Button section.

To activate Affirm Lite successfully, you must:

  1. Embed the class "affirm-lite-checkout" within the Affirm Lite button's HTML.
  2. Include the data-total-amount-tag attribute to accurately capture and communicate your customer's checkout cart total to Affirm.
  3. Include the data-fallback-url attribute to redirect customers to Affirm Landing Page if Affirm Lite does not activate.

Extrait de code Affirm Lite

<button
  type="button" 
  class="affirm-lite-checkout"
  data-fallback-url="https://affirm.com/shop/<merchant>"      
  data-total-amount-tag="#amount-tag-dollars" 
  data-cc-number-tag="input[name='cc-number']" 
  data-cc-csc-tag="input[name='cvv']" 
  data-cc-exp-month-tag="input[name='exp']" 
  data-cc-exp-year-tag="input[name='exp']">
    Checkout with Affirm
</button>

Attributs d'Affirm Lite

AttributDescription
class= "affirm-lite-checkout"Sert de localisateur pour Affirm.js pour trouver des éléments sur la page à transformer en boutons de caisse Affirm Lite.
data-fallback-urlEnsures that Affirm Landing Page can be activated as a fallback measure if Affirm Lite is unable to render.
data-total-amount-tagCaptures the cart total and sends that information to Affirm.
data-cc-number-tagIdentifies and automatically populates the Virtual Card’s number into the respective field on your website.
data-cc-csc-tag Identifies and automatically populates the Virtual Card's 3-4 digit security code into the respective field on your website.
data-cc-exp-month-tag Identifies and automatically populates the month of the Affirm Virtual Card’s expiration date into the respective field on your website.

If your site only contains a single field for credit card expiration month and year, provide the same query selector for both attributes, i.e. data-cc-exp-month-tag= “cc-exp” and data-cc-exp-year-tag= “cc-exp”.
data-cc-exp-year-tag Identifies and automatically populates the year of the Affirm Virtual Card’s expiration date into the respective field on your website.

If your site only contains a single field for credit card expiration month and year, provide the same query selector for both attributes, i.e. data-cc-exp-month-tag= “cc-exp” and data-cc-exp-year-tag= “cc-exp”.

3. Identify and Add the HTML Selectors

Use Google Chrome’s Inspect Element feature to identify HTML selectors. Then, enable Affirm to read the cart total and accurately obtain the amount required for the customer’s loan.

Identifier leData-Total-Amount-Tag

  1. On your website's checkout page, locate the area that displays the customer’s cart total.
  1. Right-click on the customer’s cart total and select “Inspect.” This displays the Inspect Element panel.
  1. On the “Elements” tab, locate the highlighted cart total element and identify the element's name. For example, in the screenshot below, the cart total element has an id name of total-amount.
    Note: You can also right-click on the element and select “Copy” > “Copy selector” to get the id name.
  1. Input total-amount in the Affirm Lite code for thedata-total-amount-tag attribute.

Exemple:

data-total-amount-tag="#total-amount"

Identifier leData-CC-Number-Tag

  1. On your website's checkout page, locate the area that displays the customer’s credit card number.
  1. Right-click on the credit card number area and select “Inspect.” This displays the Inspect Element panel.
  1. On the “Elements” tab, locate the highlighted credit card number element and identify the element's name. For example, in the screenshot below, the credit card number element has an id name of cc-number.
    Note: You can also right-click on the element and select “Copy” > “Copy selector” from the dropdown to obtain the id name.
  1. Input cc-number in the Affirm Lite code for the data-cc-number-tag attribute.

Exemple:

data-cc-number-tag="#cc-number"

Identifier leData-CC-CSC-Tag

  1. On your website's checkout page, locate the area that displays the credit card’s 3-4 digit security code, Card Security Code (CSC), or Card Verification Code (CVC).
  1. Right-click on the security code area and select “Inspect.” This displays the Inspect Element panel.
  1. On the “Elements” tab, locate the highlighted security code element and identify the element's name. For example, in the screenshot below, the security code element has an id name of cc-csc.
    Note: You can also right-click on the element and select “Copy” > “Copy selector” from the dropdown to obtain the id name.
  1. Input cc-csc in the Affirm Lite code for the data-cc-csc-tag attribute.

Exemple:

data-cc-csc-tag="#cc-csc"

Identifier leData-CC-Exp-Month-Tag

  1. On your website's checkout page, locate the area that displays the credit card’s expiration month.
  1. Right-click on the expiration month area and select “Inspect.” This displays the Inspect Element panel.
  1. On the “Elements” tab, locate the highlighted expiration month element and identify the element's name. For example, in the screenshot below, the expiration month element has an id name of exp-month.
    Note: You can also right-click on the element and select “Copy” > “Copy selector” from the dropdown to obtain the id name.
  1. Input exp-month in the Affirm Lite code for the data-cc-exp-month-tag attribute.

Exemple:

data-exp-month-tag="#exp-month"

Note: If your site only contains a single field for credit card expiration month and year, provide the same query selector for both attributes: data-cc-exp-month-tag= “cc-exp” and data-cc-exp-year-tag= “cc-exp”.


Identifier leData-CC-Exp-Year-Tag

  1. On your website's checkout page, locate the area that displays the credit card’s expiration year.
  1. Right-click on the expiration month area and select “Inspect.” This displays the Inspect Element panel.
  1. On the “Elements” tab, locate the highlighted expiration year element and identify the element's name. For example, in the screenshot below, the expiration year element has an id name of exp-year.
    Note: You can also right-click on the element and select “Copy” > “Copy selector” from the dropdown to obtain the id name.
  1. Input exp-year in the Affirm Lite code for the Data-cc-exp-year-tag attribute.

Exemple:

data-exp-year-tag="#exp-year"

Note: If your site only contains a single field for credit card expiration month and year, provide the same query selector for both attributes: data-cc-exp-month-tag= “cc-exp” and data-cc-exp-year-tag= “cc-exp”.


Complétion des attributs HTML

After you identify your HTML selectors, your final code resembles the example below and your integration steps are complete for Affirm Lite:

<button
  type="button" 
  class="affirm-lite-checkout"
  data-fallback-url="https://affirm.com/shop/<merchant>" 
  data-total-amount-tag="#total-amount" 
  data-cc-number-tag="#cc-number" 
  data-cc-csc-tag="#cc-csc" 
  data-cc-exp-month-tag="#exp-month" 
  data-cc-exp-year-tag="#exp-year">
    Checkout with Affirm
</button>

🚧

Modifications apportées au sélecteur de requête HTML

If any changes are made to your web page, ensure that the query selectors for the Affirm Lite attributes are correct and update them if necessary.

Bouton de paiement Affirm(facultatif)

En option, Affirm a créé un bouton de paiement prédéfini pour faciliter davantage le processus d'intégration.

To enable the pre-styled Affirm checkout button, add affirm-checkout-btn to the class containing the affirm-lite-checkout.

Exemple:

<button
  type="button" 
  class="affirm-lite-checkout affirm-checkout-btn"
  data-fallback-url="https://affirm.com/shop/<merchant>"      
  data-total-amount-tag="#amount-tag-dollars" 
  data-cc-number-tag="input[name='cc-number']" 
  data-cc-csc-tag="input[name='cvv']" 
  data-cc-exp-month-tag="input[name='exp']" 
  data-cc-exp-year-tag="input[name='exp']">
    Checkout with Affirm
</button>

Personnalisation des boutons

Il existe deux options pour le bouton de paiement Affirm pré-stylisé :

  • Par défaut: affirm-checkout-btn qui affiche le bouton sur fond bleu et texte blanc.
  • Clair: affirm-checkout-btn btn-light qui affiche le bouton avec un fond blanc, une bordure bleue et un texte noir.