@blocklet/payment-react
Version:
Reusable react components for payment kit v2
60 lines (59 loc) • 2.32 kB
TypeScript
import type { TPaymentCurrency } from '@blocklet/payment-types';
export { primaryContrastColor } from '../../libs/util';
export declare const INTERVAL_LOCALE_KEY: Record<string, string>;
export declare function countryCodeToFlag(code: string): string;
export declare function formatTokenAmount(unitAmount: string | number | bigint, currency: TPaymentCurrency | null): string;
interface CurrencyOption {
currency_id: string;
unit_amount: string;
custom_unit_amount?: {
preset?: string;
presets?: string[];
} | null;
}
interface PriceWithDynamic {
pricing_type?: string;
base_amount?: string;
unit_amount?: string;
base_currency?: string;
currency_id?: string;
currency_options?: CurrencyOption[];
price_currency_options?: CurrencyOption[];
}
export declare function getUnitAmountForCurrency(price: PriceWithDynamic | null | undefined, currency: TPaymentCurrency | null): string;
export declare function formatDynamicUnitPrice(price: PriceWithDynamic | null | undefined, currency: TPaymentCurrency | null, exchangeRate: string | null): string | null;
export declare function tSafe(t: (key: string, params?: any) => string, key: string, fallback: string): string;
export declare const whiteTooltipSx: {
'& .MuiTooltip-tooltip': {
bgcolor: string;
color: string;
border: string;
borderColor: string;
borderRadius: string;
boxShadow: string;
p: number;
maxWidth: number;
fontSize: number;
};
'& .MuiTooltip-arrow': {
color: string;
'&::before': {
border: string;
borderColor: string;
};
};
};
export declare function formatTrialText(t: (key: string, params?: Record<string, any>) => string, days: number, interval: string): string;
type TFn = (key: string, params?: Record<string, any>) => string;
export type ItemTypeBadge = 'subscription' | 'topup' | 'oneTime';
interface ItemMeta {
badge: ItemTypeBadge;
badgeLabel: string;
title: string;
subtitle: string;
}
/**
* Derive structured badge / title / subtitle for a checkout session header.
* Works for the "primary product" header above the item list.
*/
export declare function getSessionHeaderMeta(t: TFn, session: any, product: any, items: any[]): ItemMeta;