@daimo/pay
Version:
Seamless crypto payments. Onboard users from any chain, any coin into your app with one click.
95 lines (92 loc) • 3.28 kB
TypeScript
import * as React from 'react';
import { ReactElement } from 'react';
import * as react_jsx_runtime from 'react/jsx-runtime';
import { PaymentStartedEvent, PaymentCompletedEvent, PaymentBouncedEvent, DaimoPayUserMetadata } from '@daimo/pay-common';
import { Address, Hex } from 'viem';
import { M as Mode, T as Theme, C as CustomTheme } from './types-1473bcf4.js';
type WorldPayButtonPaymentProps = {
/**
* Your public app ID. Specify either (payId) or (appId + parameters).
*/
appId: string;
/**
* Destination chain ID.
*/
toChain: number;
/**
* The destination token to send, completing payment. Must be an ERC-20
* token or the zero address, indicating the native token / ETH.
*/
toToken: Address;
/**
* The amount of destination token to send (transfer or approve).
*/
toUnits: string;
/**
* The destination address to transfer to, or contract to call.
*/
toAddress: Address;
/**
* Optional calldata to call an arbitrary function on `toAddress`.
*/
toCallData?: Hex;
/**
* The intent verb, such as "Pay", "Deposit", or "Purchase".
*/
intent?: string;
/**
* External ID. E.g. a correlation ID.
*/
externalId?: string;
/**
* Developer metadata. E.g. correlation ID.
* */
metadata?: DaimoPayUserMetadata;
/**
* The address to refund to if the payment bounces.
*/
refundAddress?: Address;
} | {
/** The payment ID, generated via the Daimo Pay API. Replaces params above. */
payId: string;
};
type WorldPayButtonCommonProps = WorldPayButtonPaymentProps & {
/** Called when user sends payment and transaction is seen on chain */
onPaymentStarted?: (event: PaymentStartedEvent) => void;
/** Called when destination transfer or call completes successfully */
onPaymentCompleted?: (event: PaymentCompletedEvent) => void;
/** Called when destination call reverts and funds are refunded */
onPaymentBounced?: (event: PaymentBouncedEvent) => void;
/** Open the modal by default. */
defaultOpen?: boolean;
/** Automatically close the modal after a successful payment. */
closeOnSuccess?: boolean;
/** Reset the payment after a successful payment. */
resetOnSuccess?: boolean;
};
type WorldPayButtonProps = WorldPayButtonCommonProps & {
/** Light mode, dark mode, or auto. */
mode?: Mode;
/** Named theme. See docs for options. */
theme?: Theme;
/** Custom theme. See docs for options. */
customTheme?: CustomTheme;
/** Disable interaction. */
disabled?: boolean;
};
type WorldPayButtonCustomProps = WorldPayButtonCommonProps & {
children: (renderProps: {
show: () => void;
isMiniKitReady: boolean;
}) => ReactElement;
};
declare function WorldPayButton(props: WorldPayButtonProps): react_jsx_runtime.JSX.Element;
declare namespace WorldPayButton {
var Custom: typeof WorldPayButtonCustom;
}
declare function WorldPayButtonCustom(props: WorldPayButtonCustomProps): ReactElement<any, string | React.JSXElementConstructor<any>>;
declare namespace WorldPayButtonCustom {
var displayName: string;
}
export { WorldPayButton };
export type { WorldPayButtonCustomProps, WorldPayButtonProps };