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

@timmbr/payments

v1.0.0

Published

Razorpay checkout for the Timmbr storefront: loads the checkout script, runs the create-order, pay, verify flow through the shell's same-origin /api/core BFF, and exposes it as a single usePayment hook

Readme

@timmbr/payments

The Razorpay checkout flow for the Timmbr storefront, behind one hook.

It runs in the browser and talks only to the shell's same-origin /api/core routes, never to Razorpay's API or to timmbr-core directly. timmbr-core stays the authority on prices, stock, the Razorpay key id and the order. The client only sequences the calls, so it can never choose an amount or a key.

Use in a zone

"use client";
import { usePayment } from "@timmbr/payments";

const payment = usePayment({
  onSuccess: ({ orderId }) => router.push(`/success?orderId=${orderId}`),
});

<Button
  loading={payment.busy}
  onClick={() =>
    payment.pay({ items, shippingAddressId, method: "upi", prefill: { name, contact } })
  }
/>;
{payment.error && <Alert>{payment.error}</Alert>}

Add @timmbr/payments to transpilePackages.

What usePayment does

  1. Creates the order (POST /orders) or, on retry(), resumes it (POST /orders/:id/payment-session). Creating is idempotent in core, so a double click cannot make two orders.
  2. Loads Razorpay's checkout.js on demand and opens the modal with core's key id, order id and amount.
  3. On payment, confirms it with core (POST /payments/razorpay/verify). If that call cannot be completed (network error, 5xx, an expired session), it polls the order, because core's webhook may already have confirmed it.

phase is one of idle | creating | awaiting | verifying | success | failed | dismissed | error. After failed or dismissed the order is still open: call retry(). error is user-facing copy; override any of it with messages.

The success callback always runs once a payment completes, even if the page was left in the meantime. A call to pay() while one is in flight is ignored.

Other exports

  • paymentsApi: quote, createOrder, getPaymentSession, verifyPayment, getOrder.
  • loadRazorpay(), buildCheckoutOptions(), toPaise().
  • paymentErrorMessage(), resolvePaymentMessages(), DEFAULT_PAYMENT_MESSAGES.

Server code

Import wire types and constants from @timmbr/payments/contract (CheckoutQuote, PaymentMethod, PAYMENT_ROUTES, ...). It has no React and no 'use client'.

Contract

  • Envelope: every response is { success, data }; paymentsApi unwraps it.
  • Amounts: rupees everywhere, converted to paise (toPaise) only for Razorpay.
  • Methods: upi | card | netbanking | emi preselect that tab in the Razorpay window, which still offers the others. Wallets, pay later and cardless EMI are hidden.
  • Quote limit: CheckoutQuote.paymentLimit is the largest total payable online; core refuses larger orders (PAYMENT_AMOUNT_TOO_HIGH).