UNPKG

@blocklet/payment-react

Version:

Reusable react components for payment kit v2

139 lines (138 loc) 8.03 kB
import type { PaymentDetails, PriceCurrency, PriceRecurring, TCoupon, TInvoiceExpanded, TLineItemExpanded, TPaymentCurrency, TPaymentCurrencyExpanded, TPaymentMethod, TPaymentMethodExpanded, TPrice, TProductExpanded, TSubscriptionExpanded, TSubscriptionItemExpanded } from '@blocklet/payment-types'; import type { ActionProps, PricingRenderProps } from '../types'; export declare const PAYMENT_KIT_DID = "z2qaCNvKMv5GjouKdcDWexv6WqtHbpNPQDnAk"; /** * Format coupon discount terms for display */ export declare const formatCouponTerms: (coupon: TCoupon, currency: TPaymentCurrency, locale?: string) => string; export declare const isPaymentKitMounted: () => any; export declare const getPrefix: () => string; export declare function isCrossOrigin(): boolean; export declare function formatToDate(date: Date | string | number, locale?: string, format?: string): any; export declare function formatToDatetime(date: Date | string | number, locale?: string): any; export declare function formatTime(date: Date | string | number, format?: string, locale?: string): any; export declare function formatDateTime(date: Date | string | number, locale?: string): any; export declare const formatLocale: (locale?: string) => string; export declare const formatPrettyMsLocale: (locale: string) => "zh_CN" | "en_US"; export declare const formatError: (err: any) => any; export declare function formatBNStr(str?: string, decimals?: number, precision?: number, trim?: boolean, thousandSeparated?: boolean): string; export declare function formatNumber(n: number | string, precision?: number, trim?: boolean, thousandSeparated?: boolean): string; export declare const formatPrice: (price: TPrice, currency: TPaymentCurrency, unit_label?: string, quantity?: number, bn?: boolean, locale?: string) => string; export declare const formatPriceAmount: (price: TPrice, currency: TPaymentCurrency, unit_label?: string, quantity?: number, bn?: boolean) => string; export declare function getStatementDescriptor(items: any[]): any; export declare function formatRecurring(recurring: PriceRecurring, translate?: boolean, separator?: string, locale?: string): string; export declare function getPriceUintAmountByCurrency(price: TPrice, currency: TPaymentCurrency): string; export declare function getPriceCurrencyOptions(price: TPrice): PriceCurrency[]; export declare function formatLineItemPricing(item: TLineItemExpanded, currency: TPaymentCurrency, { trialEnd, trialInDays }: { trialEnd: number; trialInDays: number; }, locale?: string): { primary: string; secondary?: string; quantity: string; }; export declare function getSubscriptionStatusColor(status: string): "default" | "success" | "primary" | "warning" | "error"; export declare function getPaymentIntentStatusColor(status: string): "default" | "success" | "warning"; export declare function getRefundStatusColor(status: string): "default" | "success" | "warning"; export declare function getPayoutStatusColor(status: string): "default" | "success" | "warning"; export declare function getInvoiceStatusColor(status: string): "default" | "success" | "warning" | "secondary"; export declare function getWebhookStatusColor(status: string): "default" | "success"; export declare function getCheckoutAmount(items: TLineItemExpanded[], currency: TPaymentCurrency, trialing?: boolean, upsell?: boolean): { subtotal: any; total: any; renew: string; discount: string; shipping: string; tax: string; }; export declare function getRecurringPeriod(recurring: PriceRecurring): number; export declare function formatUpsellSaving(items: TLineItemExpanded[], currency: TPaymentCurrency): string; export declare function formatMeteredThen(subscription: string, recurring: string, hasMetered: boolean, locale?: string): string; export declare function formatPriceDisplay({ amount, then, actualAmount, showThen }: { amount: string; then?: string; actualAmount: string; showThen?: boolean; }, recurring: string, hasMetered: boolean, locale?: string): string; export declare function hasMultipleRecurringIntervals(items: TLineItemExpanded[]): boolean; export declare function getFreeTrialTime({ trialInDays, trialEnd }: { trialInDays: number; trialEnd: number; }, locale?: string): { count: number; interval: string; }; export declare function formatCheckoutHeadlines(items: TLineItemExpanded[], currency: TPaymentCurrency, { trialInDays, trialEnd }: { trialInDays: number; trialEnd: number; }, locale?: string): { action: string; amount: string; then?: string; secondary?: string; showThen?: boolean; actualAmount: string; priceDisplay: string; }; export declare function formatAmount(amount: string, decimals: number): string; export declare function findCurrency(methods: TPaymentMethodExpanded[], currencyId: string): TPaymentCurrencyExpanded | null; export declare function isValidCountry(code: string): boolean; export declare function stopEvent(e: React.SyntheticEvent<any>): void; export declare function sleep(ms: number): Promise<unknown>; export declare function formatSubscriptionProduct(items: TSubscriptionItemExpanded[], maxLength?: number): string; export declare const getLineTimeInfo: (time: number, locale?: string) => { time: any; isToday: any; }; export declare const getSubscriptionTimeSummary: (subscription: TSubscriptionExpanded, locale?: string) => { action: string; time: any; isToday: any; } | null; export declare const getSubscriptionAction: (subscription: TSubscriptionExpanded, actionProps: ActionProps) => { action: string; variant: string; color: string; canRenew: boolean; text?: string; sx?: any; } | null; export declare const mergeExtraParams: (extra?: Record<string, any>) => string; export declare const flattenPaymentMethods: (methods?: TPaymentMethodExpanded[]) => TPaymentCurrency[]; export declare const getTxLink: (method: TPaymentMethod, details: PaymentDetails) => { link: string; text: string; gas: any; }; export declare function getQueryParams(url: string): Record<string, string>; export declare function lazyLoad(lazyRun: () => void): void; export declare function formatTotalPrice({ product, quantity, priceId, locale, }: { product: TProductExpanded; quantity: number; priceId?: string; locale: string; }): PricingRenderProps; export declare function formatQuantityInventory(price: TPrice, quantity: string | number, locale?: string): string; export declare function formatSubscriptionStatus(status: string): string; export declare function formatAmountPrecisionLimit(amount: string, locale?: string, precision?: number): string; export declare function getWordBreakStyle(value: any): 'break-word' | 'break-all'; export declare function isMobileSafari(): boolean; export declare function truncateText(text: string, maxLength: number, useWidth?: boolean): string; export declare function getCustomerAvatar(did: string | undefined, updated_at: string | number | undefined, imageSize?: number): string; export declare function hasDelegateTxHash(details: PaymentDetails, paymentMethod: TPaymentMethod): any; export declare function getInvoiceDescriptionAndReason(invoice: TInvoiceExpanded, locale?: string): { description: string | undefined; reason: string; type: string; }; export declare function getPaymentKitComponent(): any; export declare function openDonationSettings(openInNewTab?: boolean): void; export declare function getUserProfileLink(userDid: string, locale?: string): string; export declare function parseMarkedText(text: string): Array<{ type: 'text' | 'marked'; content: string; }>; export declare function getTokenBalanceLink(method: TPaymentMethod, address: string): string; export declare function isCreditMetered(price: TPrice): boolean; export declare function showStaking(method: TPaymentMethod, currency: TPaymentCurrency, noStake: boolean): boolean; export declare function formatLinkWithLocale(url: string, locale?: string): string;