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

@payjp/react-payments-js

v1.0.0

Published

helper module for PAY.JP payments.js with React

Readme

@payjp/react-payments-js: React Component for PAY.JP v2 API

npm version

@payjp/react-payments-js は React で payments.js を利用するためのラッパーライブラリです。 各種の Form を React Component として提供します。

インストール方法

npm install @payjp/react-payments-js @payjp/payments-js

使い方

import { loadPayments } from '@payjp/payments-js'
import { Widgets, PaymentForm, AddressForm, useWidgets } from '@payjp/react-payments-js';

const CheckoutForm = () => {
  const { widgets, payments } = useWidgets();
  const [isLoading, setIsLoading] = useState(false);

  const onSubmit = async (e: React.FormEvent) => {
    e.preventDefault();
    if (!widgets || !payments) {
      return
    }

    setIsLoading(true);
    const { error } = await widgets.confirmPayment({ return_url: "https://example.com/return_url" });
    setIsLoading(false);

    if (error) {
      console.error(error);
    }
  };

  return (
    <form id="payment-form" onSubmit={onSubmit}>
      <PaymentForm />
      <AddressForm options={{ mode: "shipping" }} />
      <AddressForm options={{ mode: "billing" }} />
      <button type="submit" disabled={isLoading || !widgets || !payments} >
        Pay
      </button>
    </form>
  );
}

const paymentsPromise = loadPayments('pk_test_your-public-key-here')

const App = () => (
  <Widgets
    paymentsPromise={paymentsPromise}
    options={{
      clientSecret: "client-secret-for-flow-here",
    }}
  >
    <CheckoutForm />
  </Widgets>
);

createRoot(document.getElementById("app")!).render(
  <StrictMode>
    <App />
  </StrictMode>
);

イベントハンドラー

PaymentForm および AddressForm コンポーネントは、以下のイベントハンドラーをサポートしています。

PaymentForm

<PaymentForm
  onChange={(event) => {
    console.log('Payment method type:', event.value.type);
    console.log('Is complete:', event.complete);
    console.log('Is empty:', event.empty);
  }}
  onFocus={() => console.log('Payment form focused')}
  onBlur={() => console.log('Payment form blurred')}
  onReady={() => console.log('Payment form ready')}
/>

onChange イベント:

  • elementType: "payment" (固定値)
  • empty: フォームが空の場合 true
  • complete: フォームが完全に入力された場合 true
  • value.type: 選択された支払い方法のタイプ(payjp.PaymentMethodTypes または null

AddressForm

<AddressForm
  options={{ mode: "shipping" }}
  onChange={(event) => {
    console.log('Address mode:', event.elementMode);
    console.log('Name:', event.value.name);
    console.log('Address:', event.value.address);
    console.log('Phone:', event.value.phone);
    console.log('Is complete:', event.complete);
  }}
  onFocus={() => console.log('Address form focused')}
  onBlur={() => console.log('Address form blurred')}
  onReady={() => console.log('Address form ready')}
/>

onChange イベント:

  • elementType: "address" (固定値)
  • elementMode: アドレスフォームのモード("shipping" または "billing"
  • empty: フォームが空の場合 true
  • complete: フォームが完全に入力された場合 true
  • value.name: 入力された名前
  • value.address: 入力された住所情報
  • value.phone: 入力された電話番号

共通イベント

  • onReady: フォームの準備が完了したときに発火
  • onFocus: フォーム内の要素がフォーカスされたときに発火
  • onBlur: フォーム内の要素からフォーカスが外れたときに発火