Donation Thermometer

Usage

Donation Thermometer

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

export default function Page() {
  const config = {
    publishableKey: process.env.NEXT_PUBLIC_ICPAY_PK,
    goalUsd: 100,
    defaultAmountUsd: 10,
    amountsUsd: [5,10,25,50],
    progressBar: { enabled: true, mode: 'modal' },
  }
  return (
    <IcpayDonationThermometer
      config={config}
      onSuccess={(detail: IcpaySuccess) => console.log('Donated', detail)}
    />
  )
}

Configuration

  • goalUsd: number
  • defaultAmountUsd?: number
  • amountsUsd?: number[]
  • cryptoOptions?: { symbol: string; label: string; canisterId?: string }[]
  • defaultSymbol?: string
  • buttonLabel?: string (supports {amount} and {symbol} placeholders)
  • onSuccess?: (tx) => void
  • Token selector: use global showLedgerDropdown?: 'buttons' | 'dropdown' | 'none'
  • Common options: progressBar?, theme?, useOwnWallet?, plugNPlay?, debug?, disablePaymentButton?, disableAfterSuccess?

Onramp (Transak)

Accept card donations by enabling Transak onramp. The widget opens Transak and continues automatically on success.

'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,
      goalUsd: 100,
      defaultAmountUsd: 10,
      onramp: {
        environment: 'STAGING',
        apiKey: process.env.NEXT_PUBLIC_TRANSAK_PK,
        creditCardLabel: 'Pay with credit card',
        enabled: true,
      },
      progressBar: { enabled: true, mode: 'modal' },
    }
  }, [])
  return <icpay-donation-thermometer ref={ref as any} />
}

The progress bar’s first step reflects “Transak Started” during the onramp flow.

Was this page helpful?