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

@vindhq/sloud-payment-sdk

v1.0.8

Published

A custom payment SDK for seamless payment processing integration

Downloads

322

Readme

Sloud Payment SDK

A secure, embeddable payment widget for straightforward customer payments, built in React and usable in any JavaScript application (React, Angular, Vue, or vanilla JS). Ships with ESM, CJS, and UMD builds for easy integration in any environment.


Features

  • Developer-friendly: authored in React for easy maintenance and composability.
  • Framework-agnostic: works in any JavaScript environment.
  • Multiple build formats: ESM and CJS for npm/React apps, UMD for browser usage.
  • Bundled CSS via PostCSS.
  • Asset support (SVG icons) included in the build.
  • Built-in validation using Formik and Yup.
  • Toast notifications via react-hot-toast.

Installation

For npm/React Projects

# Using npm
npm install @vindhq/sloud-payment-sdk

# Using yarn
yarn add @vindhq/sloud-payment-sdk

Note: For npm projects, this widget has peer dependencies on React 18+. Make sure you have React and ReactDOM installed:

npm install react react-dom

For Browser Usage (No Bundler)

For direct browser usage without a bundler, use the UMD build which includes React bundled:

<!DOCTYPE html>
<html>
  <head>
    <title>Payment Widget</title>
  </head>
  <body>
    <!-- Load the UMD bundle (includes React) -->
    <script src="https://unpkg.com/@vindhq/sloud-payment-sdk@latest/dist/index.umd.js"></script>

    <script>
      // Access via PaymentWidget.default for UMD builds
      const widget = new PaymentWidget.default({
        type: "external",
        public_key: "your-public-api-key",
        amount: 10000,
        customer: {
          first_name: "John",
          last_name: "Doe",
          phone_number: "+2348012345678",
          email: "[email protected]",
        },
      });

      widget.showPopup();
    </script>
  </body>
</html>

Usage

The payment widget is designed for straightforward payments with customer details.

Note: When using the UMD build in the browser (via script tag), access the widget via PaymentWidget.default. For npm/ES module imports, use the standard import PaymentWidget from "sloud-payment-sdk".

import PaymentWidget from "@vindhq/sloud-payment-sdk";

const widget = new PaymentWidget({
  type: "external",
  public_key: "your-public-api-key",
  amount: 10000, // Amount in smallest currency unit (e.g., kobo for NGN)
  customer: {
    first_name: "John",
    last_name: "Doe",
    phone_number: "+2348012345678",
    email: "[email protected]",
  },
  isLocalEnv: false, // Optional: set to true for local development
  onSuccess: () => {
    console.log("Payment successful!");
    // Navigate to a confirmation page, update your UI, etc.
  },
});

widget.showPopup();

Handling Payment Success

Use the onSuccess callback to be notified when a payment completes successfully:

import PaymentWidget from "@vindhq/sloud-payment-sdk";

const widget = new PaymentWidget({
  type: "external",
  public_key: "your-public-api-key",
  amount: 10000,
  customer: {
    first_name: "John",
    last_name: "Doe",
    phone_number: "+2348012345678",
    email: "[email protected]",
  },
  onSuccess: () => {
    console.log("Payment successful!");
    // Navigate to a confirmation page, update your UI, etc.
  },
});

widget.showPopup();

API

new PaymentWidget(options: PaymentWidgetOptions)

Creates a new payment widget instance.

Payment Widget Options

| Parameter | Type | Required | Description | | ------------ | ------------------------------------ | -------- | ----------------------------------------------- | | type | "external" | Yes | Payment type (must be "external") | | public_key | string | Yes | Your public API key for secure payments | | amount | number | Yes | Payment amount in smallest currency unit | | customer | Customer | Yes | Customer information object | | isLocalEnv | boolean | No | Set to true for local development environment | | onSuccess | (data: PaymentSuccessData) => void | No | Callback invoked after a successful payment |

Type Definitions

Customer

interface Customer {
  first_name: string;
  last_name: string;
  phone_number: string;
  email: string;
}

PaymentSuccessData

interface PaymentSuccessData {
  reference: string;
  amount: number;
  currency: string;
}

Methods

showPopup()

Displays the payment widget popup modal.

widget.showPopup();
hidePopup()

Hides and unmounts the payment widget popup.

widget.hidePopup();

Validation and Error Handling

The SDK includes built-in validation:

import {
  PaymentWidget,
  validatePaymentWidgetOptions,
  PaymentWidgetValidationError,
} from "@vindhq/sloud-payment-sdk";

try {
  const options = {
    type: "external",
    public_key: "pk_test_123",
    amount: 10000,
    customer: {
      first_name: "John",
      last_name: "Doe",
      phone_number: "+2348012345678",
      email: "invalid-email", // Invalid email format
    },
  };

  // Validate before creating widget
  validatePaymentWidgetOptions(options);

  const widget = new PaymentWidget(options);
  widget.showPopup();
} catch (error) {
  if (error instanceof PaymentWidgetValidationError) {
    console.error("Validation error:", error.message);
  }
}

Advanced Usage

Payload Builders

The SDK uses a builder pattern for payment payloads:

import { buildPaymentInstrumentPayload } from "@vindhq/sloud-payment-sdk";

// Build payload from options
const payload = buildPaymentInstrumentPayload({
  type: "external",
  public_key: "pk_test_123",
  amount: 10000,
  customer: {
    first_name: "John",
    last_name: "Doe",
    phone_number: "+2348012345678",
    email: "[email protected]",
  },
});

TypeScript Support

The SDK is written in TypeScript and provides full type definitions:

import type {
  PaymentWidgetOptions,
  PaymentSuccessData,
  Customer,
} from "@vindhq/sloud-payment-sdk";

// TypeScript will enforce correct fields
const options: PaymentWidgetOptions = {
  type: "external",
  public_key: "pk_test_123",
  amount: 10000,
  customer: {
    first_name: "John",
    last_name: "Doe",
    phone_number: "+2348012345678",
    email: "[email protected]",
  },
};

Development

# Install dependencies
yarn install

# Run dev server with live reload (UMD build for browser testing)
yarn dev

# Run dev server for library development (ESM/CJS builds)
yarn dev:lib

# Build all production bundles (ESM, CJS, UMD, and type definitions)
yarn build

Development Server

  • yarn dev: Starts development server with UMD build at http://localhost:3000

    • Bundles React for standalone browser testing
    • Live reload enabled
    • Serves dist and public folders
    • Use public/index.html to test the widget
  • yarn dev:lib: Starts development server with ESM/CJS builds

    • Externalizes React (for library development)
    • Watch mode for rapid iteration

Folder Structure

Payment-Widget/
├─ src/
│  ├─ index.ts              # Entry point
│  ├─ widget.tsx            # Widget class
│  ├─ components/           # React components
│  └─ styles/               # SCSS/CSS files
├─ dist/                    # Bundled output
│  ├─ index.esm.js          # ES Module build
│  ├─ index.cjs.js          # CommonJS build
│  ├─ index.umd.js          # UMD browser build
│  └─ index.d.ts            # Type definitions
├─ public/                  # Dev server HTML for testing
├─ rollup.config.ts         # ESM/CJS build config
├─ rollup.config.umd.ts     # UMD build config
├─ rollup.config.dts.ts     # Type definitions config
└─ package.json

Build Details

Output Files

  • dist/index.esm.js - ES Module build (externalizes React)
  • dist/index.cjs.js - CommonJS build (externalizes React)
  • dist/index.umd.js - UMD build for browsers (bundles React, ~2MB)
  • dist/index.d.ts - TypeScript type definitions

Build Configuration

  • ESM/CJS → Externalizes React as peer dependency for React apps
  • UMD → Bundles React for standalone browser usage
  • PostCSS → Injects and minifies CSS into JS bundle
  • Assets → SVG/PNG files handled automatically
  • TypeScript → Full type definitions included

License

Specify your license here (e.g., MIT).