An example Node.js app that integrates Keygen with FastSpring for accepting payments.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
views
.gitignore
LICENSE
README.md
index.js
package.json
yarn.lock

README.md

Example Keygen + FastSpring integration

The following web app is written in Node.js and shows how to integrate Keygen and FastSpring together using a Popup Storefront embed.

This example application may not be 100% production-ready, but it should get you 90% of the way there. You may need to add additional logging, error handling, validation, features, etc.

Running the app locally

First up, configure a few environment variables:

# Your FastSpring API credentials (available under Integrations->API Credentials)
export FASTSPRING_API_USERNAME="YOUR_FASTSPRING_API_USERNAME"
export FASTSPRING_API_PASSWORD="YOUR_FASTSPRING_API_PASSWORD"

# Keygen product token (don't share this!)
export KEYGEN_PRODUCT_TOKEN="YOUR_KEYGEN_PRODUCT_TOKEN"

# Your Keygen account ID
export KEYGEN_ACCOUNT_ID="YOUR_KEYGEN_ACCOUNT_ID"

# The Keygen policy to use when creating licenses for new customers
# after they successfully purchase your product
export KEYGEN_POLICY_ID="YOUR_KEYGEN_POLICY_ID"

You can either run each line above within your terminal session before starting the app, or you can add the above contents to your ~/.bashrc file and then run source ~/.bashrc after saving the file.

Next, install dependencies with yarn:

yarn

Then start the app:

yarn start

Testing the integration locally

For local development, create an ngrok tunnel:

ngrok http 8080

Creating a FastSpring Popup Storefront

In order to utilize this integration, you'll need to create a FastSpring Popup Storefront. Then you'll need to edit the /views/index.ejs file and update the FastSpring embed code with your own embed code provided by FastSpring.

Be sure to add data-popup-closed="onFSPopupClosed" attribute to your embed script tag or else your integration will not work. You will also need to update the data-fsc-item-path-value attribute for the "Buy Now" button.

Testing the integration

Visit the following url: http://localhost:8080 and fill out the purchase form.

Questions?

Reach out at support@keygen.sh if you have any questions or concerns!