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

@chainpay/component

v0.8.34

Published

A React-based payment component library that supports multiple payment channels and internationalization.

Readme

ChainPay Component

A React-based payment component library that supports multiple payment channels and internationalization.

Features

  • 🚀 Support for React 18 and React 19
  • 🌍 Multi-language support (Chinese, English, Japanese, Korean, and 8 languages in total)
  • 🎨 Support for dark/light themes
  • 📱 Responsive design
  • ⚡ TypeScript support
  • 🔄 Automatic polling of payment status
  • 💫 Elegant loading and error handling

Installation

npm install @chainpay/component
# or
yarn add @chainpay/component
# or
pnpm add @chainpay/component

Dependencies

Ensure your project has the following dependencies installed:

npm install react react-dom antd i18next react-i18next tailwindcss

Quick Start

1. Import Component and Styles

import { useChainPay, ChainPayLng } from "@chainpay/component";
import "@chainpay/component/dist/style.css";

2. Basic Usage

import React from 'react';
import { useChainPay, ChainPayLng } from "@chainpay/component";
import "@chainpay/component/dist/style.css";

function PaymentExample() {

  const { showPayModal } = useChainPay({
    // dark: true,
    language: "en",
    currency: '¥',
    appId: "app-77cccd53-b091-4dee-98f9-a44d641ac128",
    getSignInfoFn: async (params) => {
      return await getSign(params)  // Return signature information
    },
    onError(error) {
      console.log("error", error);
    },
    onSuccess() {
      console.log("success");
    },
    onClose() {
      console.log("close");
    },
    onCountDownTimeout() {
      console.log("countDownTimeout");
    }
  });

  return (
    <div>
      <button onClick={() => {
        showPayModal({
          amount: 100,
        })
      }}>
        Initiate Payment
      </button>
    </div>
  );
}

export default PaymentExample;

API Documentation

useChainPay(options)

Returns an object containing the showPayModal and closePayModal methods.

Parameters (ChainPayProps)

| Parameter | Type | Default | Required | Description | |------|------|--------|------|------| | appId | string | - | ✅ | Application ID | | amount | number | - | ❌ | Payment amount | | currency | string | - | ❌ | Currency symbol | | language | LngType | 'zh-CN' | ❌ | Interface language | | dark | boolean | false | ❌ | Enable dark theme | | getSignInfoFn | function | - | ❌ | Function to get signature information | | onSuccess | function | - | ❌ | Payment success callback | | onError | function | - | ❌ | Payment error callback | | onClose | function | - | ❌ | Modal close callback | | onBack | function | - | ❌ | Back button callback | | onCountDownTimeout | function | - | ❌ | Countdown timeout callback |

Supported Languages

enum ChainPayLng {
  "en" = "en",        // English
  "zh-CN" = "zh-CN",  // Simplified Chinese
  "zh-TW" = "zh-TW",  // Traditional Chinese
  "ko" = "ko",        // Korean
  "ja" = "ja",        // Japanese
  "ms" = "ms",        // Malay
  "vi" = "vi",        // Vietnamese
  "th" = "th"         // Thai
}

Function Signatures

// Function to get order information
getSignInfoFn?: (data: object) => Promise<any>;

showPayModal(props)

Displays the payment modal. Parameters are the same as useChainPay, but parameters in showPayModal have higher priority.

closePayModal()

Manually closes the payment modal.

Advanced Usage

Custom Theme

const { showPayModal } = useChainPay({
  dark: true, // Enable dark theme
  // Other configurations...
});

Dynamic Language Switching

const { showPayModal } = useChainPay({
  language: ChainPayLng['zh-CN'], // Use Chinese
  // Other configurations...
});

// Switch language when displaying the modal
showPayModal({
  language: ChainPayLng.en, // Switch to English
  amount: 100
});

Error Handling

const { showPayModal } = useChainPay({
  onError: (error) => {
    // Handle payment errors
    console.error('Payment failed:', error);
    // Can display error message to the user
  }
});

Important Notes

⚠️ React 19 Compatibility: If you encounter ReactCurrentDispatcher errors in React 19 projects, please refer to the React 19 Compatibility Guide.

Quick Solutions for React 19 Errors

If you encounter the error TypeError: Cannot read properties of undefined (reading 'ReactCurrentDispatcher'):

  1. Temporary Solution: Install a compatible version in your project

    npm install @chainpay/component@latest
    # If problems persist, clear cache
    rm -rf node_modules package-lock.json
    npm install
  2. Ensure JSX Transform is Configured Correctly (Vite projects):

    // vite.config.js
    import { defineConfig } from 'vite'
    import react from '@vitejs/plugin-react'
       
    export default defineConfig({
      plugins: [react()]
    })
  3. Additional Configuration for Next.js Projects:

    // next.config.js
    module.exports = {
      transpilePackages: ['@chainpay/component']
    }

React 19 Compatibility

This component library fully supports React 19. If you encounter ReactCurrentDispatcher related errors during use, please refer to the React 19 Compatibility Guide.

Notes

  1. Must Import Style File: Ensure you import the CSS file before using the component
  2. peerDependencies: Make sure all required dependencies are installed
  3. API Functions: getSignInfoFn should return a Promise
  4. Error Handling: It is recommended to implement complete error handling logic in production environments

License

MIT License

Support

If you encounter any issues or have feature suggestions, please submit an issue on GitHub.