Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

gatsby-plugin-affirm

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gatsby-plugin-affirm

Plugin to add the Affirm JavaScript SDK

latest
Source
npmnpm
Version
3.0.0
Version published
Weekly downloads
76
68.89%
Maintainers
1
Weekly downloads
 
Created
Source

gatsby-plugin-affirm

Adds the (Affirm JavaScript SDK)[https://docs.affirm.com/developers/docs/afjs-reference] to your Gatsby project.

Installation

  • Install gatsby-plugin-affirm .
npm install gatsby-plugin-affirm

# or

yarn add gatsby-plugin-affirm
  • Add the plugins to your gatsby-config.js:
module.exports = {
  plugins: [
    {
      resolve: `gatsby-plugin-affirm`,
      options: {
        // REQUIRED VALUES
        //
        // Affirm API write key for the running environment
        publicAPIKey: YOUR_AFFIRM_KEY,
        // Affirm SDK url for the running environment (i.e. https://cdn1.affirm.com/js/v2/affirm.js)
        environmentScript: AFFIRM_SDK_URL

        // OPTIONAL VALUES
        //
        // Loads the Affirm script after the document has been parsed
        experimental_shouldDeferAffirmScript: false,
        // Loads the initial script asynchronously
        isAsync: true,
      },
    },
  ],
};

How to use

In the client, the Affirm SDK will now be available in the window / global context.

if (affirm && affirm.ui.ready()) {
  affirm.checkout(affirmCheckoutPayload);
  affirm.checkout.open();
}

// or

window.affirm;

Keywords

gatsby

FAQs

Package last updated on 07 Jan 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts