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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@newageerp/node-cart

v1.0.24

Published

```bash npm install @newageerp/node-cart ```

Readme

Install

npm install @newageerp/node-cart

ENV variables

  • PAYMENTS_PRIMER_BACKEND - if primer is used
  • PAYMENTS_PAYPAL_BACKEND - if paypal is used
  • PAYMENTS_STRIPE_WALLET_BACKEND - if stripe wallets is used
  • PAYMENTS_STRIPE_ORDER_BACKEND - if stripe credit card form is used
  • AMQP_CART_QUEUE
  • CRM_CART_BACKEND_V3

.env / .env.stg example

CRM_CART_BACKEND_V3=https://cart.crm.apidata.app
AMQP_CART_QUEUE=internal.crm.cart

PAYMENTS_PRIMER_BACKEND=https://primer.crm.apidata.app/app/public/session
PAYMENTS_PAYPAL_BACKEND=https://pp.crm.apidata.app/app/public/rt
PAYMENTS_STRIPE_WALLET_BACKEND=https://stripe.crm.apidata.app/app/public/wallet
PAYMENTS_STRIPE_ORDER_BACKEND=https://stripe.crm.apidata.app/app/public/wallet

.env.prod example

  • PAYMENTS_*** - replace apidata.app with project domain (if this is a test/RnD project, then use the domain of the main project, whose payments are used)

  • CRM_CART_BACKEND_V3 - replace apidata.app with project domain (if this is a test/RnD project, then use the domain of the main project, whose payments are used)

  • AMQP_CART_QUEUE possible production variables

    • biofema.crm.cart
    • cosmic.crm.cart
    • mellow.crm.cart
    • parenting.crm.cart
    • shiftmind.crm.cart
    • today.crm.cart
    • wingman.crm.cart

middleware.ts

import { cartNextSrv } from '@newageerp/node-cart'

export async function middleware(req: NextRequest) {
    
    const cartResp = await cartNextSrv.checkForRoutes(req)
    if (cartResp) {
        return cartResp
    }
    
}

export const config = {
    matcher: '/((?!_next/static|_next/image|favicon.ico).*)',
}

Usage

set data

in examples you can see cartBrowser or cartSrv calls, make sure you are using the correct method depending on the context.

Almost all methods are available in both environments

create remote cart [- IMPORTANT -]

  • call it after PaymentWindow was opened
  • call it after purchase, before first upsell shown, most often it is up/[uuid/ page

it is safe to call multiple times, only one instance will be created


await cartBrowser.create({
    cart: cart.cart.items,
    currency: currency,
    extraData: {
        totals: cart.totals,
    },
    id, // order uuid for main purchase or `${uuid}-up` for upsell
    customerId, // not neccessary if customerId = id (for main purchase)
})

mark cart as paid [- IMPORTANT -]


const cartData = await cartSrv.paid({
    pm, // payment method (query param from paid/[uuid] route)
    id, // order uuid for main purchase or `${uuid}-up` for upsell
})

add item to cart [- IMPORTANT -]

most often used in upsell flow to add item to the cart


await cartBrowser.appendCartItem({
    id, // order uuid for main purchase or `${uuid}-up` for upsell flow 
    cart: [
        {
            product: data,
            quantity: 1,
        },
    ],
})

start upsell payment (initiate charge) [- IMPORTANT -]

call it after upsell flow. most often it is up-paid/[uuid] page. This method also marks cart as paid (on success charge), so you don't need call paid method


// id - cart id (order uuid + suffix)
// customerId - order uuid
const cartData = await cartBrowser.upsellPayment({
    id,
    customerId,
})

get data

in examples you can see cartBrowser or cartSrv calls, make sure you are using the correct method depending on the context.

Almost all methods are available in both environments

get cart items

Returns items in cart ( it doesn't matter if it's paid or not ). Used in upsell flow to check if the user has added something to the cart.


// order uuid for main purchase or `${uuid}-up` for upsell
const cartData = await cartBrowser.get({ id })

get customer paid items

Returns main purchase + upsells. Used in invoice / thank you page.


// customerId - order uuid without suffixes
const cartData = await cartBrowser.getPaid({ customerId })

Utilities

cart total

// just calculate all items total sum
const total = cartUtils.total(items);