@astropay/payments-lib
Version:
Official AstroPay payments library for web and mobile.
337 lines (336 loc) • 9.53 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"];
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 APCardConfig = {
userId: string;
};
type APComponentStyles = {
backgroundColor: string;
fontFamily: string;
textColor: string;
primaryColor: string;
textPrimaryColor: string;
secondaryColor: string;
textSecondaryColor: string;
width: string | number;
paddingWrapper: string | number;
borderRadiusWrapper: string | number;
messages: {
success: {
textColor: string;
textSize: number;
};
error: {
textColor: string;
textSize: number;
};
};
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;
};
};
type APCore = {
environment?: APEnvironment;
theme?: APAvailableTheme;
language?: APAvailableLanguages;
currencyMode?: APAvailableCurrencyMode;
styles?: TDeepPartial<APComponentStyles>;
tracking?: boolean;
};
type APFullCheckout = {
amount: number;
currency: string;
country: string;
paymentExternalId?: string;
showTitle?: boolean;
showDescription?: boolean;
cardConfig?: (APCardConfig & {
showPaymentSummary?: boolean;
expirationDateFormat?: 'MM/YYYY' | 'MM/YY';
}) | undefined;
user?: {
phoneNumber?: string;
email?: string;
firstName?: string;
lastName?: string;
documentNumber?: string;
} | undefined;
order?: {
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;
};
};
};
} | undefined;
onSuccess?: () => void;
onError?: () => void;
};
type APPayment = {
amount: number;
currency: string;
country: string;
user?: {
phoneNumber?: string;
email?: string;
firstName?: string;
lastName?: string;
documentNumber?: string;
} | undefined;
order?: {
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;
};
};
};
} | undefined;
onSuccess?: () => void;
onError?: () => void;
};
type APCardPayment = {
amount: number;
currency: string;
country: string;
config: APCardConfig;
showPaymentSummary?: boolean | undefined;
expirationDateFormat?: 'MM/YYYY' | 'MM/YY' | undefined;
order?: {
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;
};
};
};
} | undefined;
onSuccess?: () => void;
onError?: () => void;
};
export type { APCardConfig, APEnvironment, APAvailableTheme, APAvailableLanguages, APAvailableCurrencyMode, APComponentStyles, APCore, APFullCheckout, APPayment, APCardPayment, };