Nexus and FastSpring embedded checkout integration

Connect Nexus creator codes to FastSpring's embedded checkout for automatic discount and attribution handling.

Use FastSpring with Nexus to support creator-code attribution at checkout. Buyers enter a creator's code during purchase, FastSpring optionally applies a discount, and your server records the attribution in Nexus so the creator gets credit. FastSpring acts as the merchant of record for all transactions.

This page covers a working reference implementation from the FSBuilds GitHub repository, found in the fsbuilds-nexus-integration folder of the FastSpring fsBuilds examples repo. You can download it, configure your credentials, and have a functioning integration running locally in minutes.

ℹ️

This is a reference example, not an actively maintained SDK or library. It reflects the FastSpring and Nexus APIs as of its publish date and may not account for later changes to either platform. Check the linked documentation on this page for current behavior before building on it.

How it works

Your server acts as the bridge between FastSpring and Nexus — the two platforms never communicate directly. This keeps your Nexus private key off the browser and gives you full control over the flow.

sequenceDiagram
    participant B as Buyer
    participant F as Frontend
    participant S as Your Server
    participant N as Nexus API
    participant FS as FastSpring

    rect rgb(240, 253, 244)
        note over B,N: 1 — Code validation
        B->>F: Enters creator code
        F->>S: POST /validate-code
        S->>N: Validate (public key)
        N-->>S: Creator name or error
        S-->>F: Validation result
        F-->>B: Creator message or error
    end

    rect rgb(255, 251, 235)
        note over F,FS: 2 — Discount application (optional)
        F->>FS: Apply coupon code
        FS-->>F: Discount applied
    end

    rect rgb(245, 243, 255)
        note over B,FS: 3 — Purchase & attribution
        B->>FS: Completes purchase
        FS-->>B: Order confirmation
        FS->>S: Webhook: order.completed
        S->>N: POST attribution (private key)
        N-->>S: Creator credited ✓
    end

The three phases in plain language: validate the code before purchase using your public key, apply a discount if the code matches a FastSpring coupon, and record the attribution after purchase using your private key.

Creator code states

A code entered at checkout can match Nexus, FastSpring, both, or neither. The following table shows what happens in each case.

Code typeResult
Valid Nexus creator code + matching FastSpring couponDiscount applied + "Thanks for supporting [Creator]!" message
Valid Nexus creator code only (no coupon)Creator message shown, no discount
Valid FastSpring coupon only (not a Nexus creator)Discount applied, no creator message
Matches neither Nexus nor FastSpringError message shown to buyer

Prerequisites

Before you begin, make sure you have the following.

FastSpring account

An account with an embedded checkout configured and at least one product in your catalog. Create an embedded checkout →

Nexus publisher account

A publisher account with a creator program and at least one active creator code. You will need your Public Key, Private Key, and Group ID from the Developer section of your program — the Group ID also appears in Nexus API responses.

Node.js v18+

The reference server runs on Node.js. Download Node.js → or check your version with node --version.

Public webhook endpoint

FastSpring needs a reachable URL to send order events. Use ngrok for local testing — note your URL changes on each restart with the free plan.

Set up the integration

Project structure

The reference implementation has a minimal footprint — a frontend file, a backend file, and configuration.

fsbuilds-nexus-integration/
├── index.html       # Frontend — embedded checkout, creator code input, product display
├── server.js        # Backend — webhook handler, Nexus API calls
├── style.css        # Styles
├── .env             # Your credentials (never committed to Git)
├── .env.example     # Template showing which environment variables are required
└── package.json     # Node dependencies

The two files you will spend time in:

index.html

Everything the buyer sees. Uses the FastSpring SBL to render the embedded checkout and display product info. Calls your server to validate creator codes.

server.js

Everything that stays private. Receives FastSpring webhooks, validates creator codes against Nexus, and posts attributions after purchase. Your private key never leaves this file.

Test the integration

Before going live, verify your setup using FastSpring's sandbox environment.

Run a test transaction using FastSpring's sandbox environment.

  1. Open your checkout at http://localhost:3000.

  2. Enter a creator code and proceed to payment.

  3. Complete the purchase using the following test card:

    FieldValue
    Card number4242 4242 4242 4242
    ExpiryAny future date
    CVVFound on your product page in the FastSpring dashboard
  4. Confirm the attribution appears in your Nexus dashboard.

Security

Public vs. private key usage

Your Nexus public key is used at code validation time (before purchase). Your private key is used at attribution time (after purchase). Both live in .env and are only ever called from your server — never from the browser.

Webhook signature verification

In production, you should verify that incoming webhooks are genuinely from FastSpring by validating the HMAC signature on each request. The reference implementation does not include this by default. See FastSpring webhook security for implementation details.

Environment variable hygiene

Never commit your .env file. The .gitignore in this repo already excludes it, but if you fork or copy this project, confirm the exclusion is in place before your first push.

Related resources


Did this page help you?