import type { ComponentPropsWithoutRef } from 'react'; import type { CustomerWithNameOnCard } from './customer'; import type { currencyCode } from './currency'; import type { ButtonStyle, CheckoutProfileResponse } from './checkoutProfile'; import type { SupportedCardBrands } from './enums/cardBrands'; import type { PaymentMethodName } from './enums/paymentMethods'; import { ColorStyle, Edges, ThemeMode, Locale, Purpose, Scope, Direction, SourceId, AcceptancePaymentType, UserExperience } from './enums'; import { ExtendableObject, ExtendableString } from './tsUtils'; import { IntentAPI } from './intent'; export interface PayButtonProps extends ComponentPropsWithoutRef<'button'> { shimmerLoader?: boolean; theme?: ThemeMode; colorStyle?: ColorStyle; locale?: Locale; isRounded?: boolean; isFailed?: boolean; isSuccess?: boolean; edges?: Edges; title?: string; font?: string; disabled?: boolean; disabledBgColor?: string; textColor?: string; buttonStyle?: ButtonStyle; } export interface ButtonSDKEvents { onReady?: () => void; onClick?: () => void; onError?: (error: any) => void; onCancel?: () => void; onSuccess?: (data: any) => void; onBinIdentification?: (data: any) => void; onIntentCreated?: (intent: ExtendableObject>) => Promise; onChargeCreated?: (charge: Record) => void; onOrderCreated?: (orderId: string) => void; } export interface ButtonSDKProps extends ButtonSDKEvents { debug?: boolean; scope: Scope; purpose: ExtendableString<`${Purpose}`>; order: Order; invoice?: Invoice; operator: Operator; merchant: Merchant; customer: CustomerWithNameOnCard; features?: Features; acceptance?: Acceptance; transaction?: Transaction; fieldVisibility?: FieldVisibility; interface?: { locale?: Locale; theme?: ThemeMode; edges?: Edges; colorStyle?: ColorStyle; loader?: boolean; userExperience?: UserExperience; powered?: boolean; direction?: Direction; cardDirection?: Direction; }; post?: { url: string; [key: string]: any; }; redirect?: { url: string; [key: string]: any; }; metadata?: ExtendableObject<{ headers?: ExtendableObject<{ authorization: string; mdn: string; application: string; ip?: string; session?: string; }>; profileData?: CheckoutProfileResponse; }>; platform?: { id: string; }; [key: string]: any; } export interface Transaction { intent?: { id: string; [key: string]: any; }; authorize?: { auto: { type: ExtendableString<'VOID' | 'CAPTURE'>; time: string; }; [key: string]: any; }; authenticate?: { id?: string; required?: boolean; [key: string]: any; }; source?: { id: ExtendableString; [key: string]: any; }; destinations?: { destination: { id: string; amount: number; currency: currencyCode; description: string; }[]; [key: string]: any; }; paymentAgreement?: { id: string; contract?: { id: string; }; [key: string]: any; }; reference?: string; metadata?: { udf1?: string; udf2?: string; [key: string]: any; }; topup?: { created: string; amount: number; currency: currencyCode; wallet?: { id: string; [key: string]: any; }; customer?: { id: string; [key: string]: any; }; post?: { url: string; [key: string]: any; }; reference?: { transaction?: string; order?: string; [key: string]: any; }; metdata?: { key: string; [key: string]: any; }; }; [key: string]: any; } export interface OrderItemProduct { id: string; amount?: number; name?: Array<{ text?: string; lang: string; }>; description?: Array<{ text: string; lang?: string; }>; category?: ExtendableString<'PHYSICAL_GOODS'>; metadata?: object; reference?: ExtendableObject<{ sku?: string; gtin?: string; code: string; financial_code: string; }>; } export interface Tax { name?: string; description?: string; type?: ExtendableString<'Percentage' | 'Flat' | 'F'>; amount?: number; value?: number; [key: string]: any; } export interface Discount { type?: ExtendableString<'Percentage' | 'Flat' | 'F'>; amount?: number; value?: number; [key: string]: any; } export interface OrderItem { count: number; list: Array<{ id: string; quantity: number; pickup?: boolean; product?: OrderItemProduct; discount?: Array; tax?: Array; }>; } export type OrderShippingAddress = { type: string; } & Partial<{ line1: string; line2: string; line3: string; line4: string; apartment: string; building: string; street: string; avenue: string; block: string; area: string; city: string; state: string; country: string; zip_code: string; postal_code: string; }>; export type OrderShipping = { amount: number; description?: Array<{ text: string; lang?: string; }>; recipient_name?: Array<{ text: string; lang?: string; }>; address?: OrderShippingAddress; }; export interface Order { id?: string; amount: number; currency: currencyCode; description?: string; reference?: string; metadata?: Record; items?: OrderItem; tax?: Array; discount?: Discount; shipping?: ExtendableObject<{ amount: number; description?: Array<{ text: string; lang?: string; }>; recipient_name?: Array<{ text: string; lang?: string; }>; address?: OrderShippingAddress; provider?: { id: string; }; }>; [key: string]: any; } export interface Acceptance { supportedPaymentMethod?: ExtendableString; supportedSchemes?: SupportedCardBrands; supportedCurrencies?: ExtendableString[]; supportedFundSource?: ExtendableString<'ALL' | 'DEBIT' | 'CREDIT'>[]; supportedPaymentAuthentications?: ExtendableString<'3DS' | 'EMV' | 'PASSKEY'>[]; supportedPaymentFlows?: ExtendableString<'popup' | 'redirection'>[]; supportedPaymentTypes?: ExtendableString<`${AcceptancePaymentType}`>[]; supportedPaymentMethods?: ExtendableString[]; [key: string]: any; } export interface FieldVisibility { card?: { number: boolean; expiry: boolean; cvv: boolean; cardholder: boolean; [key: string]: any; }; contact?: { email: boolean; number: boolean; }; shipping?: { address: boolean; }; name: boolean; } export interface Merchant { id: string; terminal?: { id: string; }; [key: string]: any; } export interface Operator { publicKey: string; hashString?: string; [key: string]: any; } export interface Invoice { id: string; [key: string]: any; } export interface Features { acceptanceBadge?: boolean; order?: boolean; multipleCurrencies?: boolean; alternativeCardInputs?: AlternativeCardInputs; payments?: Payments; customerCards?: CustomerCards; currencyConversions?: CurrencyConversions; [key: string]: any; } interface AlternativeCardInputs { cardScanner?: boolean; cardNfc?: boolean; [key: string]: any; } interface CurrencyConversions { dynamic?: boolean; location?: boolean; payment?: boolean; cobadge?: boolean; } interface CustomerCards { saveCard?: boolean; autoSaveCard?: boolean; displaySavedCards?: boolean; } interface Payments { card?: boolean; device?: boolean; wallet?: boolean; bnpl?: boolean; mobile?: boolean; cash?: boolean; redirect?: boolean; [key: string]: any; } export {};