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

startbutton-payment-gateway

v1.1.0

Published

A polished React + TypeScript payment gateway SDK with a customizable Start Payment button, hook API, normalized responses, and backend-first verification.

Readme

StartButton Payment Gateway

npm version TypeScript React License: MIT Storybook

StartButton Payment Gateway is a React + TypeScript SDK for building a polished, customizable, backend-first payment button experience. It gives developers a ready payment button, hook API, normalized JSON responses, typed callbacks, and flexible checkout modes without bundling any third-party gateway SDK into your runtime package.

Built by Pradeep Kumar Sheoran (Developer) at BSG Technologies.

Official Website: https://bsgtechnologies.com
Visit here to meet, learn, contribute, and discuss new topics with us.

Contact / WhatsApp: +91-8595147850

Why Developers Choose It

  • TypeScript-first API with exported response, callback, config, and payment input types.
  • Advanced callback names for better product feel: onPaymentAuthorized, onPaymentDeclined, onPaymentPendingReview, onPaymentAborted, onPaymentException, and onPaymentSettled.
  • Backward-compatible callbacks: onSuccess, onFailure, onPending, onCancel, and onError still work.
  • Customizable button labels, styles, native button props, render-prop UI, and manual launch control.
  • React 18 and React 19 compatible peer dependency range.
  • Backend-first security flow: secret keys stay on your server.
  • Normalized JSON responses across success, failed, pending, cancelled, and error states.
  • Popup, redirect, iframe, and custom gateway adapter architecture.
  • Storybook-ready component documentation and isolated development workflow.
  • No bundled third-party payment gateway library in the runtime SDK.

Hashtags

#ReactPaymentGateway #TypeScriptSDK #StartPay #PaymentButton #SecureCheckout #BSGTechnologies #IndiaPayments #UPI #ReactSDK

Installation

npm install startbutton-payment-gateway

React is a peer dependency and is not bundled.

Quickstart

import { StartPayButton, StartPayProvider } from "startbutton-payment-gateway";

export const App = () => (
  <StartPayProvider
    config={{
      publicKey: "pk_test_xxxxx",
      environment: "sandbox",
      apiBaseUrl: "https://api.yourdomain.com",
      mode: "popup"
    }}
  >
    <StartPayButton
      amount={1500}
      currency="INR"
      orderId="ORDER_1001"
      customer={{
        name: "Pradeep Kumar",
        email: "[email protected]",
        phone: "9999999999"
      }}
      loadingText="Launching secure checkout..."
      successText="Payment Authorized"
      failureText="Payment Declined"
      className="startpay-button"
      onPaymentAuthorized={(response) => console.log("Authorized", response)}
      onPaymentDeclined={(response) => console.log("Declined", response)}
      onPaymentException={(response) => console.log("Exception", response)}
      onPaymentSettled={(response) => console.log("Final response", response)}
    >
      Start Payment
    </StartPayButton>
  </StartPayProvider>
);

Advanced Button API

<StartPayButton
  amount={2499}
  currency="INR"
  orderId="ORDER_PREMIUM_1002"
  autoStart={false}
  onClick={async (_event, controls) => {
    console.log("Current status", controls.lastStatus);
    await controls.launchPaymentFlow();
  }}
  onPaymentPendingReview={(response) => console.log("Pending", response)}
  onPaymentAborted={(response) => console.log("Cancelled", response)}
>
  Pay Securely
</StartPayButton>

Render your own UI when you want full design control:

<StartPayButton amount={1500} currency="INR" orderId="ORDER_CUSTOM_1003">
  {({ loading, disabled, lastStatus, launchPaymentFlow }) => (
    <button type="button" disabled={disabled} onClick={launchPaymentFlow}>
      {loading ? "Processing..." : lastStatus ? `Status: ${lastStatus}` : "Pay Now"}
    </button>
  )}
</StartPayButton>

Hook Usage

import { useStartPay } from "startbutton-payment-gateway";

const PayNow = () => {
  const { startPayment, loading } = useStartPay();

  const handlePayment = async () => {
    const response = await startPayment({
      amount: 1500,
      currency: "INR",
      orderId: "ORDER_1001"
    });

    if (response.status === "success") {
      console.log(response.transactionId);
    }
  };

  return (
    <button type="button" disabled={loading} onClick={handlePayment}>
      {loading ? "Processing..." : "Pay Now"}
    </button>
  );
};

Backend Connection Flow

Your frontend SDK should call your own backend. Your backend talks to the actual payment gateway and keeps secret credentials private.

  1. React app calls your backend to create a payment session.
  2. Backend creates the gateway order/session using secret credentials.
  3. Backend returns paymentSessionId, clientToken, redirectUrl, or checkoutUrl.
  4. SDK opens popup, redirect, iframe, or custom checkout flow.
  5. SDK receives browser-side result.
  6. React app asks backend to verify the payment.
  7. Backend verifies gateway status/signature.
  8. SDK returns one normalized response object.

See docs/IMPLEMENTATION_GUIDE.md and examples/backend.example.ts.

Response Example

{
  status: "success",
  success: true,
  paymentId: "PAY_123456",
  orderId: "ORDER_1001",
  transactionId: "TXN_987654",
  amount: 1500,
  currency: "INR",
  gateway: "custom",
  message: "Payment completed successfully",
  metadata: {},
  timestamp: "2026-07-01T13:30:00.000Z"
}

Full response reference: docs/RESPONSE_REFERENCE.md.

Storybook

Develop and document the component in isolation:

npm run storybook

Build static Storybook docs:

npm run build:storybook

The Storybook story uses autoStart={false} for safe local documentation, so opening the demo does not call a real payment endpoint until you wire your backend.

Live Demo Pattern

This repository includes copy-ready examples:

For a public live demo, deploy your React app and set apiBaseUrl to your backend payment API. Keep all secret keys on the backend.

TypeScript Developer Experience

import type {
  StartPayButtonCallback,
  StartPayConfig,
  StartPaymentInput,
  StartPayResponse
} from "startbutton-payment-gateway";

const config: StartPayConfig = {
  publicKey: "pk_test_xxxxx",
  environment: "sandbox",
  apiBaseUrl: "https://api.yourdomain.com"
};

const payment: StartPaymentInput = {
  amount: 1500,
  currency: "INR",
  orderId: "ORDER_1001"
};

const onSettled: StartPayButtonCallback = (response: StartPayResponse) => {
  console.log(response.status);
};

Customization Options

  • className, style, id, name, aria-*, and data-* native button props.
  • loadingText, successText, and failureText labels.
  • autoStart={false} for manual control.
  • Render-prop children for fully custom UI.
  • signal for abort-aware payment requests.
  • timeout, paymentMethods, callbackUrl, returnUrl, customer, and metadata.
  • Callback aliases for both practical coding and premium product naming.

Security Notes

  • Never pass a secret key to frontend config.
  • Verify payment status on your backend before fulfilling an order.
  • Use HTTPS in production.
  • Validate webhook signatures on the backend.
  • Log normalized responses, but do not store sensitive card or credential data.

Donation and Support

If this SDK helps your project, you can support development:

UPI / Mobile: +91-8595147850

For business discussion, integration help, contribution, or collaboration:

BSG Technologies: https://bsgtechnologies.com
Developer: Pradeep Kumar Sheoran
Contact / WhatsApp: +91-8595147850

Build

npm run typecheck
npm run build

The package builds ESM, CJS, and TypeScript declarations with sideEffects: false for tree shaking.

License

MIT. See LICENSE.