@astropay/payments-lib
Version:
Official AstroPay payments library for web and mobile.
334 lines (333 loc) • 9.64 kB
TypeScript
export type TDeepPartial<T> = {
[P in keyof T]?: T[P] extends object ? TDeepPartial<T[P]> : T[P];
};
export declare const CONFIG_ENVIRONMENT_VALUES: readonly ["production", "sandbox"];
export declare const CONFIG_THEME_VALUES: readonly ["light", "dark"];
export declare const CONFIG_LANGUAGE_VALUES: readonly ["en", "pt", "es"];
export declare const CONFIG_CURRENCY_MODE_VALUES: readonly ["iso", "symbol"];
export declare const CONFIG_FONT_SCALE_VALUES: readonly ["sm", "md", "lg"];
type APEnvironment = (typeof CONFIG_ENVIRONMENT_VALUES)[number];
type APAvailableTheme = (typeof CONFIG_THEME_VALUES)[number];
type APAvailableLanguages = (typeof CONFIG_LANGUAGE_VALUES)[number];
type APAvailableCurrencyMode = (typeof CONFIG_CURRENCY_MODE_VALUES)[number];
type APAvailableFontScale = (typeof CONFIG_FONT_SCALE_VALUES)[number];
type APComponentStyles = {
backgroundColor: string;
fontFamily: string;
textColor: string;
fontScale: APAvailableFontScale | Partial<{
xSmall: number;
small: number;
medium: number;
base: number;
large: number;
xLarge: number;
}>;
primaryColor: string;
textPrimaryColor: string;
secondaryColor: string;
textSecondaryColor: string;
width: string | number;
paddingWrapper: string | number;
borderRadiusWrapper: string | number;
messages: {
success: {
textColor: string;
};
error: {
textColor: string;
};
};
input: {
normal: {
textColor: string;
backgroundColor: string;
hintTextColor: string;
placeholderTextColor: string;
borderColor: string;
borderRadius: number;
borderWidth: number;
};
focus: {
textColor: string;
backgroundColor: string;
hintTextColor: string;
placeholderTextColor: string;
borderColor: string;
borderRadius: number;
borderWidth: number;
};
disabled: {
textColor: string;
backgroundColor: string;
hintTextColor: string;
placeholderTextColor: string;
borderColor: string;
borderRadius: number;
borderWidth: number;
};
error: {
textColor: string;
backgroundColor: string;
hintTextColor: string;
placeholderTextColor: string;
borderColor: string;
borderRadius: number;
borderWidth: number;
};
};
button: {
small: {
borderRadius: number;
};
medium: {
borderRadius: number;
};
large: {
borderRadius: number;
};
primary: {
textColor: string;
backgroundColor: string;
borderColor: string;
borderWidth: number;
};
secondary: {
textColor: string;
backgroundColor: string;
borderColor: string;
borderWidth: number;
};
text: {
textColor: string;
backgroundColor: string;
borderColor: string;
borderWidth: number;
};
disabled: {
textColor: string;
backgroundColor: string;
borderColor: string;
borderWidth: number;
};
};
divider: {
color: string;
variant: 'dashed' | 'dotted' | 'solid';
size: number;
};
card: {
padding: number;
backgroundColor: string;
borderWidth: number;
borderStyle: 'dashed' | 'dotted' | 'solid' | 'none';
borderColor: string;
borderRadius: number;
};
qrCode: {
padding: number | string;
backgroundColor: string;
borderWidth: number;
borderStyle: 'dashed' | 'dotted' | 'solid' | 'none';
borderColor: string;
borderRadius: number;
};
badge: {
default: {
padding: number | string;
textColor: string;
backgroundColor: string;
borderWidth: number;
borderStyle: 'dashed' | 'dotted' | 'solid' | 'none';
borderColor: string;
borderRadius: number;
};
highlight: {
padding: number | string;
textColor: string;
backgroundColor: string;
borderWidth: number;
borderStyle: 'dashed' | 'dotted' | 'solid' | 'none';
borderColor: string;
borderRadius: number;
};
error: {
padding: number | string;
textColor: string;
backgroundColor: string;
borderWidth: number;
borderStyle: 'dashed' | 'dotted' | 'solid' | 'none';
borderColor: string;
borderRadius: number;
};
success: {
padding: number | string;
textColor: string;
backgroundColor: string;
borderWidth: number;
borderStyle: 'dashed' | 'dotted' | 'solid' | 'none';
borderColor: string;
borderRadius: number;
};
warning: {
padding: number | string;
textColor: string;
backgroundColor: string;
borderWidth: number;
borderStyle: 'dashed' | 'dotted' | 'solid' | 'none';
borderColor: string;
borderRadius: number;
};
};
timer: {
padding: number | string;
textColor: string;
backgroundColor: string;
borderWidth: number;
borderStyle: 'dashed' | 'dotted' | 'solid' | 'none';
borderColor: string;
borderRadius: number;
};
cardTabs: {
activeTextColor: string;
inactiveTextColor: string;
indicatorColor: string;
borderColor: string;
};
cardTabsSegmented: {
trackBackgroundColor: string;
trackBorderRadius: number;
activeBackgroundColor: string;
activeTextColor: string;
inactiveTextColor: string;
itemBorderRadius: number;
};
savedCardSelector: {
row: {
borderColor: string;
borderWidth: number;
borderRadius: number;
};
radio: {
color: string;
activeColor: string;
};
cardNumber: {
textColor: string;
};
cardMeta: {
textColor: string;
};
deleteButton: {
color: string;
hoverColor: string;
hoverBackgroundColor: string;
confirmBackground: string;
confirmTextColor: string;
confirmActionBackground: string;
confirmActionColor: string;
confirmCancelColor: string;
confirmCancelHoverBackground: string;
confirmCancelHoverColor: string;
};
panel: {
borderColor: string;
};
};
checkbox: {
box: {
borderColor: string;
size: number;
borderRadius: number;
};
check: {
iconColor: string;
};
};
};
type APCore = {
environment?: APEnvironment;
theme?: APAvailableTheme;
language?: APAvailableLanguages;
currencyMode?: APAvailableCurrencyMode;
styles?: TDeepPartial<APComponentStyles>;
tracking?: boolean;
};
type TOrderProps = {
id?: string;
items?: Array<{
name: string;
description?: string;
units: number;
amount: {
currency: string;
value: number;
};
}>;
summary?: {
totalAmount: {
currency: string;
value: number;
};
shipping?: {
label: string;
amount: {
currency: string;
value: number;
};
};
fees?: {
label: string;
amount: {
currency: string;
value: number;
};
};
};
};
type TUserProps = {
phoneNumber?: string;
email?: string;
firstName?: string;
lastName?: string;
documentNumber?: string;
};
type TNewPayment = {
amount: number;
currency: string;
country: string;
paymentExternalId?: never;
};
type TExistingPayment = {
paymentExternalId: string;
amount?: never;
currency?: never;
country?: never;
};
type TPaymentIdentity = TNewPayment | TExistingPayment;
type APFullCheckout = TPaymentIdentity & {
showTitle?: boolean;
showDescription?: boolean;
cardConfig?: {
showPaymentSummary?: boolean | undefined;
expirationDateFormat?: 'MM/YYYY' | 'MM/YY' | undefined;
} | undefined;
user?: TUserProps | undefined;
order?: TOrderProps | undefined;
onSuccess?: () => void;
onError?: () => void;
};
type APPayment = TPaymentIdentity & {
user?: TUserProps | undefined;
order?: TOrderProps | undefined;
onSuccess?: () => void;
onError?: () => void;
};
type APCardPayment = TPaymentIdentity & {
showPaymentSummary?: boolean | undefined;
expirationDateFormat?: 'MM/YYYY' | 'MM/YY' | undefined;
order?: TOrderProps | undefined;
onSuccess?: () => void;
onError?: () => void;
};
export type { APEnvironment, APAvailableTheme, APAvailableLanguages, APAvailableCurrencyMode, APAvailableFontScale, APComponentStyles, APCore, APFullCheckout, APPayment, APCardPayment, TNewPayment, };