Pay Button

The Pay Button component renders a compact, single-action checkout button for a fixed USD amount. Optionally filter available tokens via tokenShortcodes.

Usage

Pay Button

'use client'
import { IcpayPayButton, IcpaySuccess } from '@ic-pay/icpay-widget/react'

export default function Page() {
  const config = {
    publishableKey: process.env.NEXT_PUBLIC_ICPAY_PK,
    amountUsd: 49.99,
    // Optional: constrain wallets/tokens shown
    // chainTypes: ['ic','evm'],
    // chainShortcodes: ['ic','base'],
    // tokenShortcodes: ['ic_icp','ic_ckusdc','base_eth'],
    // progressBar: { enabled: true },
  }
  return (
    <IcpayPayButton
      config={config}
      onSuccess={(detail: IcpaySuccess) => console.log('Paid', detail)}
    />
  )
}

Configuration

  • amountUsd?: number
  • buttonLabel?: string (used if amountUsd not set)
  • progressBar?: { enabled?: boolean }
  • Common options: tokenShortcodes?: string[], chainShortcodes?: string[], chainTypes?: Array<'ic' | 'evm'>, theme?, useOwnWallet?, plugNPlay?, debug?, disablePaymentButton?, disableAfterSuccess?

Onramp (Transak)

Enable card onramp from the wallet selector by configuring onramp and handle the success event. The component will:

  • Create an onramp intent via the SDK (createPaymentUsd with onrampPayment: true).
  • Open Transak using the returned sessionId.
  • Close the Transak modal on TRANSAK_ORDER_SUCCESSFUL and start notifying ICPay until completion.
'use client'
import { useEffect, useRef } from 'react'
import '@ic-pay/icpay-widget'

export default function Page() {
  const ref = useRef<any>(null)
  useEffect(() => {
    if (!ref.current) return
    ref.current.config = {
      publishableKey: process.env.NEXT_PUBLIC_ICPAY_PK,
      amountUsd: 49.99,
      onramp: {
        environment: 'STAGING',
        apiKey: process.env.NEXT_PUBLIC_TRANSAK_PK,
        creditCardLabel: 'Pay with credit card',
        enabled: true,
      },
      progressBar: { enabled: true },
    }
  }, [])
  return <icpay-pay-button ref={ref as any} />
}

The progress bar updates “wallet” to “Transak Started – Awaiting Transak information” during onramp.

Was this page helpful?