npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

creem-datafast-integration

v2.1.1

Published

Premium wrapper for Creem SDK to capture DataFast attribution and handle webhooks with idempotency and hydration.

Readme

creem-datafast-integration

Connect CREEM payments to DataFast analytics without writing any glue code. The Premium Engine handles checkout attribution, webhook forwarding, and transaction hydration with zero configuration.

CI npm version License: MIT

💎 The Premium Difference

  • Premium Engine Architecture — A domain-driven structure (Foundation, Engine, Gateways) designed for maximum maintainability and scale.
  • Zero-Config Tracking — One-liner browser script automatically finds and attributes all checkout links on your page.
  • Transaction Hydration — Automatically fetches missing transaction details from Creem to ensure 100% data accuracy in DataFast, including taxes and discounts.
  • Framework Native — First-class support for Next.js App Router and Express with drop-in adapters.
  • Production Idempotency — Atomic deduplication with built-in Memory and Upstash Redis adapters to prevent duplicate revenue reporting.
  • Edge-Ready — Uses Web Crypto API (SubtleCrypto); fully compatible with Cloudflare Workers, Vercel Edge, Bun, and Deno.

🏗️ Project Structure

The package follows an enterprise-grade domain-driven architecture:

src/
├── foundation/     # Base types, custom errors, and Zod schemas
├── infrastructure/ # Low-level utilities (HTTP, Finance, Context)
├── services/       # External Proxy clients (Creem SDK, DataFast API)
├── engine/         # Core business logic (Checkout flow, Webhook pipe)
├── gateways/       # Official framework adapters (Next.js, Express)
├── storage/        # Persistence layers (In-memory, Upstash Redis)
└── browser/        # Client-side auto-initialization scripts

🚀 How It Works

sequenceDiagram
    participant B as Browser
    participant S as Your Server
    participant C as Creem
    participant D as DataFast

    B->>S: POST /api/checkout (cookies)
    Note right of S: Premium Engine captures attribution
    S->>C: createCheckout()
    C-->>B: hosted checkout URL
    B->>C: Completes Payment
    C->>S: Webhook (checkout.completed)
    Note right of S: Verifies, Hydrates & Forwards
    S->>D: POST /api/v1/payments

📦 Installation

npm install creem-datafast-integration

🏁 Quickstart

1. Initialize the Client

import { createCreemDataFast } from 'creem-datafast-integration';

export const creemDataFast = createCreemDataFast({
  creemApiKey: process.env.CREEM_API_KEY!,
  creemWebhookSecret: process.env.CREEM_WEBHOOK_SECRET!,
  datafastApiKey: process.env.DATAFAST_API_KEY!,
  testMode: process.env.NODE_ENV !== 'production'
});

2. Next.js Integration

// app/api/checkout/route.ts
import { creemDataFast } from '@/lib/creem';

export async function POST(request: Request) {
  const { checkoutUrl } = await creemDataFast.createCheckout(
    { productId: 'prod_123', successUrl: '/success' },
    { request }
  );
  return Response.redirect(checkoutUrl, 303);
}

// app/api/webhooks/creem/route.ts
import { createNextWebhookHandler } from 'creem-datafast-integration/next';
import { creemDataFast } from '@/lib/creem';

export const POST = createNextWebhookHandler(creemDataFast);

3. Express Integration

import express from 'express';
import { createExpressWebhookHandler } from 'creem-datafast-integration/express';

const app = express();

app.post('/api/checkout', async (req, res) => {
  const { checkoutUrl } = await creemDataFast.createCheckout(
    { productId: 'prod_123', successUrl: '/success' },
    { request: { headers: req.headers, url: req.url } }
  );
  res.redirect(303, checkoutUrl);
});

app.post(
  '/webhooks/creem',
  express.raw({ type: 'application/json' }),
  createExpressWebhookHandler(creemDataFast)
);

⚙️ Configuration

| Option | Type | Default | Description | |---|---|---|---| | creemApiKey | string | Required | Your Creem Secret API Key | | creemWebhookSecret | string | Required | Your Creem Webhook Secret (for sig verification) | | datafastApiKey | string | Required | Your DataFast API Key | | testMode | boolean | false | Enable test mode for transactions | | idempotencyStore| Store | MemoryStore | Custom storage for deduplication | | logger | Logger | Console | Custom logger implementation |


🚨 Error Handling

The package provides custom error classes for granular control:

import { 
  InvalidCreemSignatureError, 
  MissingTrackingError,
  CreemDataFastError 
} from 'creem-datafast-integration';

try {
  await creemDataFast.handleWebhook(payload, signature);
} catch (err) {
  if (err instanceof InvalidCreemSignatureError) {
    // Handle unauthorized webhook attempts
  }
}

🌐 Zero-Config Browser Script

Automatically attributes all Creem links to DataFast without manual implementation.

<script 
  async 
  defer 
  src="https://cdn.jsdelivr.net/npm/creem-datafast-integration/dist/client.js" 
  data-auto-init="true">
</script>

📜 Supported Events

| Event | Action | Result in DataFast | |---|---|---| | checkout.completed | Simple Attribution | One-time Payment | | subscription.paid | Auto-Hydration | Monthly/Annual Revenue | | refund.created | Revenue Reversal | Negative Balance Adjustment |


⚖️ License

Distributed under the MIT License. See LICENSE for more information. refund.created | Negative Revenue Adjustment |

⚖️ License

MIT