@solvapay/core 1.1.1 → 1.2.0-preview-e2cd9bda9dee33e68f6bba7098f7d683e6f1b742
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/business-details-public.d.ts +105 -0
- package/dist/business-details-public-C1TEVVdQ.d.cts +111 -0
- package/dist/business-details-public-C1TEVVdQ.d.ts +111 -0
- package/dist/business-details-public.cjs +360 -0
- package/dist/business-details-public.d.cts +2 -0
- package/dist/business-details-public.d.ts +105 -0
- package/dist/business-details-public.js +32 -0
- package/dist/chunk-QA4QRZMD.js +322 -0
- package/dist/index.cjs +339 -4
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +33 -0
- package/package.json +9 -3
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
export type TaxIdType = 'eu_vat' | 'gb_vat' | 'us_ein'
|
|
2
|
+
|
|
3
|
+
export type EuMemberCountry =
|
|
4
|
+
| 'AT'
|
|
5
|
+
| 'BE'
|
|
6
|
+
| 'BG'
|
|
7
|
+
| 'HR'
|
|
8
|
+
| 'CY'
|
|
9
|
+
| 'CZ'
|
|
10
|
+
| 'DK'
|
|
11
|
+
| 'EE'
|
|
12
|
+
| 'FI'
|
|
13
|
+
| 'FR'
|
|
14
|
+
| 'DE'
|
|
15
|
+
| 'GR'
|
|
16
|
+
| 'HU'
|
|
17
|
+
| 'IE'
|
|
18
|
+
| 'IT'
|
|
19
|
+
| 'LV'
|
|
20
|
+
| 'LT'
|
|
21
|
+
| 'LU'
|
|
22
|
+
| 'MT'
|
|
23
|
+
| 'NL'
|
|
24
|
+
| 'PL'
|
|
25
|
+
| 'PT'
|
|
26
|
+
| 'RO'
|
|
27
|
+
| 'SK'
|
|
28
|
+
| 'SI'
|
|
29
|
+
| 'ES'
|
|
30
|
+
| 'SE'
|
|
31
|
+
|
|
32
|
+
export type SupportedBusinessCountry = EuMemberCountry | 'GB' | 'US'
|
|
33
|
+
|
|
34
|
+
export declare const TAX_ID_TYPES: readonly TaxIdType[]
|
|
35
|
+
|
|
36
|
+
export declare const SUPPORTED_BUSINESS_COUNTRIES: readonly SupportedBusinessCountry[]
|
|
37
|
+
|
|
38
|
+
export declare const COUNTRY_TO_TAX_ID_TYPE: Record<SupportedBusinessCountry, TaxIdType>
|
|
39
|
+
|
|
40
|
+
export declare const TAX_ID_EXAMPLE_BY_COUNTRY: Record<SupportedBusinessCountry, string>
|
|
41
|
+
|
|
42
|
+
export declare function deriveTaxIdType(country: SupportedBusinessCountry): TaxIdType
|
|
43
|
+
|
|
44
|
+
export declare function getTaxIdFieldLabel(country: SupportedBusinessCountry): string
|
|
45
|
+
|
|
46
|
+
export declare function getTaxIdExample(country: SupportedBusinessCountry): string
|
|
47
|
+
|
|
48
|
+
export declare function getTaxIdHelperText(country: SupportedBusinessCountry): string
|
|
49
|
+
|
|
50
|
+
export type BusinessDetailsInput = {
|
|
51
|
+
isBusiness: boolean
|
|
52
|
+
businessName?: string
|
|
53
|
+
country?: string
|
|
54
|
+
customerCountry?: string
|
|
55
|
+
taxId?: string
|
|
56
|
+
taxIdType?: TaxIdType
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export type BusinessDetails =
|
|
60
|
+
| { isBusiness: false; customerCountry?: SupportedBusinessCountry }
|
|
61
|
+
| {
|
|
62
|
+
isBusiness: true
|
|
63
|
+
businessName: string
|
|
64
|
+
country: SupportedBusinessCountry
|
|
65
|
+
taxId: string
|
|
66
|
+
taxIdType: TaxIdType
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export type BusinessDetailsValidationIssue = {
|
|
70
|
+
path: PropertyKey[]
|
|
71
|
+
message: string
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export type BusinessDetailsValidationError = {
|
|
75
|
+
issues: BusinessDetailsValidationIssue[]
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export type ValidateBusinessDetailsResult =
|
|
79
|
+
| { success: true; data: BusinessDetails }
|
|
80
|
+
| { success: false; error: BusinessDetailsValidationError }
|
|
81
|
+
|
|
82
|
+
export declare function validateBusinessDetails(
|
|
83
|
+
input: BusinessDetailsInput,
|
|
84
|
+
): ValidateBusinessDetailsResult
|
|
85
|
+
|
|
86
|
+
export declare const TAX_BEHAVIORS: readonly ['auto', 'inclusive', 'exclusive']
|
|
87
|
+
|
|
88
|
+
export type TaxBehavior = (typeof TAX_BEHAVIORS)[number]
|
|
89
|
+
|
|
90
|
+
export declare const TAX_EXCLUSIVE_CURRENCIES: readonly ['USD', 'CAD']
|
|
91
|
+
|
|
92
|
+
export declare function resolveTaxBehavior(
|
|
93
|
+
behavior: TaxBehavior,
|
|
94
|
+
currency: string,
|
|
95
|
+
): 'inclusive' | 'exclusive'
|
|
96
|
+
|
|
97
|
+
export type TaxBreakdown = {
|
|
98
|
+
subtotal: number
|
|
99
|
+
taxAmount: number
|
|
100
|
+
taxRate: number
|
|
101
|
+
treatment: 'reverse_charge' | 'standard' | 'none' | 'not_collecting'
|
|
102
|
+
total: number
|
|
103
|
+
currency: string
|
|
104
|
+
inclusive: boolean
|
|
105
|
+
}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
declare const TAX_ID_TYPES: readonly ["eu_vat", "gb_vat", "us_ein"];
|
|
4
|
+
type TaxIdType = (typeof TAX_ID_TYPES)[number];
|
|
5
|
+
/** EU member states (ISO 3166-1 alpha-2) supported for eu_vat. */
|
|
6
|
+
declare const EU_MEMBER_COUNTRIES: readonly ["AT", "BE", "BG", "HR", "CY", "CZ", "DK", "EE", "FI", "FR", "DE", "GR", "HU", "IE", "IT", "LV", "LT", "LU", "MT", "NL", "PL", "PT", "RO", "SK", "SI", "ES", "SE"];
|
|
7
|
+
type EuMemberCountry = (typeof EU_MEMBER_COUNTRIES)[number];
|
|
8
|
+
declare const SUPPORTED_BUSINESS_COUNTRIES: readonly ["AT", "BE", "BG", "HR", "CY", "CZ", "DK", "EE", "FI", "FR", "DE", "GR", "HU", "IE", "IT", "LV", "LT", "LU", "MT", "NL", "PL", "PT", "RO", "SK", "SI", "ES", "SE", "GB", "US"];
|
|
9
|
+
type SupportedBusinessCountry = (typeof SUPPORTED_BUSINESS_COUNTRIES)[number];
|
|
10
|
+
/** Stripe Connect English display names for supported business countries. */
|
|
11
|
+
declare const BUSINESS_COUNTRY_DISPLAY_NAMES: Record<SupportedBusinessCountry, string>;
|
|
12
|
+
type BusinessCountryOption = {
|
|
13
|
+
value: SupportedBusinessCountry;
|
|
14
|
+
label: string;
|
|
15
|
+
};
|
|
16
|
+
declare const BUSINESS_COUNTRY_OPTIONS: BusinessCountryOption[];
|
|
17
|
+
declare const COUNTRY_TO_TAX_ID_TYPE: Record<SupportedBusinessCountry, TaxIdType>;
|
|
18
|
+
declare function deriveTaxIdType(country: SupportedBusinessCountry): TaxIdType;
|
|
19
|
+
/** Stripe-aligned example values that pass {@link TAX_ID_REGEX_BY_COUNTRY} validation. */
|
|
20
|
+
declare const TAX_ID_EXAMPLE_BY_COUNTRY: Record<SupportedBusinessCountry, string>;
|
|
21
|
+
declare function getTaxIdFieldLabel(country: SupportedBusinessCountry): string;
|
|
22
|
+
declare function getTaxIdExample(country: SupportedBusinessCountry): string;
|
|
23
|
+
declare function getTaxIdHelperText(country: SupportedBusinessCountry): string;
|
|
24
|
+
declare const BusinessDetailsSchema: z.ZodPipe<z.ZodObject<{
|
|
25
|
+
isBusiness: z.ZodBoolean;
|
|
26
|
+
businessName: z.ZodOptional<z.ZodString>;
|
|
27
|
+
country: z.ZodOptional<z.ZodString>;
|
|
28
|
+
customerCountry: z.ZodOptional<z.ZodString>;
|
|
29
|
+
taxId: z.ZodOptional<z.ZodString>;
|
|
30
|
+
taxIdType: z.ZodOptional<z.ZodEnum<{
|
|
31
|
+
eu_vat: "eu_vat";
|
|
32
|
+
gb_vat: "gb_vat";
|
|
33
|
+
us_ein: "us_ein";
|
|
34
|
+
}>>;
|
|
35
|
+
}, z.core.$strip>, z.ZodTransform<{
|
|
36
|
+
isBusiness: false;
|
|
37
|
+
customerCountry: "AT" | "BE" | "BG" | "HR" | "CY" | "CZ" | "DK" | "EE" | "FI" | "FR" | "DE" | "GR" | "HU" | "IE" | "IT" | "LV" | "LT" | "LU" | "MT" | "NL" | "PL" | "PT" | "RO" | "SK" | "SI" | "ES" | "SE" | "GB" | "US";
|
|
38
|
+
businessName?: undefined;
|
|
39
|
+
country?: undefined;
|
|
40
|
+
taxId?: undefined;
|
|
41
|
+
taxIdType?: undefined;
|
|
42
|
+
} | {
|
|
43
|
+
isBusiness: false;
|
|
44
|
+
customerCountry?: undefined;
|
|
45
|
+
businessName?: undefined;
|
|
46
|
+
country?: undefined;
|
|
47
|
+
taxId?: undefined;
|
|
48
|
+
taxIdType?: undefined;
|
|
49
|
+
} | {
|
|
50
|
+
isBusiness: true;
|
|
51
|
+
businessName: string;
|
|
52
|
+
country: "AT" | "BE" | "BG" | "HR" | "CY" | "CZ" | "DK" | "EE" | "FI" | "FR" | "DE" | "GR" | "HU" | "IE" | "IT" | "LV" | "LT" | "LU" | "MT" | "NL" | "PL" | "PT" | "RO" | "SK" | "SI" | "ES" | "SE" | "GB" | "US";
|
|
53
|
+
taxId: string;
|
|
54
|
+
taxIdType: "eu_vat" | "gb_vat" | "us_ein";
|
|
55
|
+
customerCountry?: undefined;
|
|
56
|
+
}, {
|
|
57
|
+
isBusiness: boolean;
|
|
58
|
+
businessName?: string | undefined;
|
|
59
|
+
country?: string | undefined;
|
|
60
|
+
customerCountry?: string | undefined;
|
|
61
|
+
taxId?: string | undefined;
|
|
62
|
+
taxIdType?: "eu_vat" | "gb_vat" | "us_ein" | undefined;
|
|
63
|
+
}>>;
|
|
64
|
+
type BusinessDetailsInput = {
|
|
65
|
+
isBusiness: boolean;
|
|
66
|
+
businessName?: string;
|
|
67
|
+
country?: string;
|
|
68
|
+
customerCountry?: string;
|
|
69
|
+
taxId?: string;
|
|
70
|
+
taxIdType?: TaxIdType;
|
|
71
|
+
};
|
|
72
|
+
type BusinessDetails = {
|
|
73
|
+
isBusiness: false;
|
|
74
|
+
customerCountry?: SupportedBusinessCountry;
|
|
75
|
+
} | {
|
|
76
|
+
isBusiness: true;
|
|
77
|
+
businessName: string;
|
|
78
|
+
country: SupportedBusinessCountry;
|
|
79
|
+
taxId: string;
|
|
80
|
+
taxIdType: TaxIdType;
|
|
81
|
+
};
|
|
82
|
+
type BusinessDetailsValidationIssue = {
|
|
83
|
+
path: PropertyKey[];
|
|
84
|
+
message: string;
|
|
85
|
+
};
|
|
86
|
+
type BusinessDetailsValidationError = {
|
|
87
|
+
issues: BusinessDetailsValidationIssue[];
|
|
88
|
+
};
|
|
89
|
+
type ValidateBusinessDetailsResult = {
|
|
90
|
+
success: true;
|
|
91
|
+
data: BusinessDetails;
|
|
92
|
+
} | {
|
|
93
|
+
success: false;
|
|
94
|
+
error: BusinessDetailsValidationError;
|
|
95
|
+
};
|
|
96
|
+
declare function validateBusinessDetails(input: BusinessDetailsInput): ValidateBusinessDetailsResult;
|
|
97
|
+
declare const TAX_BEHAVIORS: readonly ["auto", "inclusive", "exclusive"];
|
|
98
|
+
type TaxBehavior = (typeof TAX_BEHAVIORS)[number];
|
|
99
|
+
declare const TAX_EXCLUSIVE_CURRENCIES: readonly ["USD", "CAD"];
|
|
100
|
+
declare function resolveTaxBehavior(behavior: TaxBehavior, currency: string): 'inclusive' | 'exclusive';
|
|
101
|
+
type TaxBreakdown = {
|
|
102
|
+
subtotal: number;
|
|
103
|
+
taxAmount: number;
|
|
104
|
+
taxRate: number;
|
|
105
|
+
treatment: 'reverse_charge' | 'standard' | 'none' | 'not_collecting';
|
|
106
|
+
total: number;
|
|
107
|
+
currency: string;
|
|
108
|
+
inclusive: boolean;
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
export { BUSINESS_COUNTRY_DISPLAY_NAMES as B, COUNTRY_TO_TAX_ID_TYPE as C, type EuMemberCountry as E, SUPPORTED_BUSINESS_COUNTRIES as S, TAX_BEHAVIORS as T, type ValidateBusinessDetailsResult as V, BUSINESS_COUNTRY_OPTIONS as a, type BusinessCountryOption as b, type BusinessDetails as c, type BusinessDetailsInput as d, BusinessDetailsSchema as e, type BusinessDetailsValidationError as f, type BusinessDetailsValidationIssue as g, type SupportedBusinessCountry as h, TAX_EXCLUSIVE_CURRENCIES as i, TAX_ID_EXAMPLE_BY_COUNTRY as j, TAX_ID_TYPES as k, type TaxBehavior as l, type TaxBreakdown as m, type TaxIdType as n, deriveTaxIdType as o, getTaxIdExample as p, getTaxIdFieldLabel as q, getTaxIdHelperText as r, resolveTaxBehavior as s, validateBusinessDetails as v };
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
declare const TAX_ID_TYPES: readonly ["eu_vat", "gb_vat", "us_ein"];
|
|
4
|
+
type TaxIdType = (typeof TAX_ID_TYPES)[number];
|
|
5
|
+
/** EU member states (ISO 3166-1 alpha-2) supported for eu_vat. */
|
|
6
|
+
declare const EU_MEMBER_COUNTRIES: readonly ["AT", "BE", "BG", "HR", "CY", "CZ", "DK", "EE", "FI", "FR", "DE", "GR", "HU", "IE", "IT", "LV", "LT", "LU", "MT", "NL", "PL", "PT", "RO", "SK", "SI", "ES", "SE"];
|
|
7
|
+
type EuMemberCountry = (typeof EU_MEMBER_COUNTRIES)[number];
|
|
8
|
+
declare const SUPPORTED_BUSINESS_COUNTRIES: readonly ["AT", "BE", "BG", "HR", "CY", "CZ", "DK", "EE", "FI", "FR", "DE", "GR", "HU", "IE", "IT", "LV", "LT", "LU", "MT", "NL", "PL", "PT", "RO", "SK", "SI", "ES", "SE", "GB", "US"];
|
|
9
|
+
type SupportedBusinessCountry = (typeof SUPPORTED_BUSINESS_COUNTRIES)[number];
|
|
10
|
+
/** Stripe Connect English display names for supported business countries. */
|
|
11
|
+
declare const BUSINESS_COUNTRY_DISPLAY_NAMES: Record<SupportedBusinessCountry, string>;
|
|
12
|
+
type BusinessCountryOption = {
|
|
13
|
+
value: SupportedBusinessCountry;
|
|
14
|
+
label: string;
|
|
15
|
+
};
|
|
16
|
+
declare const BUSINESS_COUNTRY_OPTIONS: BusinessCountryOption[];
|
|
17
|
+
declare const COUNTRY_TO_TAX_ID_TYPE: Record<SupportedBusinessCountry, TaxIdType>;
|
|
18
|
+
declare function deriveTaxIdType(country: SupportedBusinessCountry): TaxIdType;
|
|
19
|
+
/** Stripe-aligned example values that pass {@link TAX_ID_REGEX_BY_COUNTRY} validation. */
|
|
20
|
+
declare const TAX_ID_EXAMPLE_BY_COUNTRY: Record<SupportedBusinessCountry, string>;
|
|
21
|
+
declare function getTaxIdFieldLabel(country: SupportedBusinessCountry): string;
|
|
22
|
+
declare function getTaxIdExample(country: SupportedBusinessCountry): string;
|
|
23
|
+
declare function getTaxIdHelperText(country: SupportedBusinessCountry): string;
|
|
24
|
+
declare const BusinessDetailsSchema: z.ZodPipe<z.ZodObject<{
|
|
25
|
+
isBusiness: z.ZodBoolean;
|
|
26
|
+
businessName: z.ZodOptional<z.ZodString>;
|
|
27
|
+
country: z.ZodOptional<z.ZodString>;
|
|
28
|
+
customerCountry: z.ZodOptional<z.ZodString>;
|
|
29
|
+
taxId: z.ZodOptional<z.ZodString>;
|
|
30
|
+
taxIdType: z.ZodOptional<z.ZodEnum<{
|
|
31
|
+
eu_vat: "eu_vat";
|
|
32
|
+
gb_vat: "gb_vat";
|
|
33
|
+
us_ein: "us_ein";
|
|
34
|
+
}>>;
|
|
35
|
+
}, z.core.$strip>, z.ZodTransform<{
|
|
36
|
+
isBusiness: false;
|
|
37
|
+
customerCountry: "AT" | "BE" | "BG" | "HR" | "CY" | "CZ" | "DK" | "EE" | "FI" | "FR" | "DE" | "GR" | "HU" | "IE" | "IT" | "LV" | "LT" | "LU" | "MT" | "NL" | "PL" | "PT" | "RO" | "SK" | "SI" | "ES" | "SE" | "GB" | "US";
|
|
38
|
+
businessName?: undefined;
|
|
39
|
+
country?: undefined;
|
|
40
|
+
taxId?: undefined;
|
|
41
|
+
taxIdType?: undefined;
|
|
42
|
+
} | {
|
|
43
|
+
isBusiness: false;
|
|
44
|
+
customerCountry?: undefined;
|
|
45
|
+
businessName?: undefined;
|
|
46
|
+
country?: undefined;
|
|
47
|
+
taxId?: undefined;
|
|
48
|
+
taxIdType?: undefined;
|
|
49
|
+
} | {
|
|
50
|
+
isBusiness: true;
|
|
51
|
+
businessName: string;
|
|
52
|
+
country: "AT" | "BE" | "BG" | "HR" | "CY" | "CZ" | "DK" | "EE" | "FI" | "FR" | "DE" | "GR" | "HU" | "IE" | "IT" | "LV" | "LT" | "LU" | "MT" | "NL" | "PL" | "PT" | "RO" | "SK" | "SI" | "ES" | "SE" | "GB" | "US";
|
|
53
|
+
taxId: string;
|
|
54
|
+
taxIdType: "eu_vat" | "gb_vat" | "us_ein";
|
|
55
|
+
customerCountry?: undefined;
|
|
56
|
+
}, {
|
|
57
|
+
isBusiness: boolean;
|
|
58
|
+
businessName?: string | undefined;
|
|
59
|
+
country?: string | undefined;
|
|
60
|
+
customerCountry?: string | undefined;
|
|
61
|
+
taxId?: string | undefined;
|
|
62
|
+
taxIdType?: "eu_vat" | "gb_vat" | "us_ein" | undefined;
|
|
63
|
+
}>>;
|
|
64
|
+
type BusinessDetailsInput = {
|
|
65
|
+
isBusiness: boolean;
|
|
66
|
+
businessName?: string;
|
|
67
|
+
country?: string;
|
|
68
|
+
customerCountry?: string;
|
|
69
|
+
taxId?: string;
|
|
70
|
+
taxIdType?: TaxIdType;
|
|
71
|
+
};
|
|
72
|
+
type BusinessDetails = {
|
|
73
|
+
isBusiness: false;
|
|
74
|
+
customerCountry?: SupportedBusinessCountry;
|
|
75
|
+
} | {
|
|
76
|
+
isBusiness: true;
|
|
77
|
+
businessName: string;
|
|
78
|
+
country: SupportedBusinessCountry;
|
|
79
|
+
taxId: string;
|
|
80
|
+
taxIdType: TaxIdType;
|
|
81
|
+
};
|
|
82
|
+
type BusinessDetailsValidationIssue = {
|
|
83
|
+
path: PropertyKey[];
|
|
84
|
+
message: string;
|
|
85
|
+
};
|
|
86
|
+
type BusinessDetailsValidationError = {
|
|
87
|
+
issues: BusinessDetailsValidationIssue[];
|
|
88
|
+
};
|
|
89
|
+
type ValidateBusinessDetailsResult = {
|
|
90
|
+
success: true;
|
|
91
|
+
data: BusinessDetails;
|
|
92
|
+
} | {
|
|
93
|
+
success: false;
|
|
94
|
+
error: BusinessDetailsValidationError;
|
|
95
|
+
};
|
|
96
|
+
declare function validateBusinessDetails(input: BusinessDetailsInput): ValidateBusinessDetailsResult;
|
|
97
|
+
declare const TAX_BEHAVIORS: readonly ["auto", "inclusive", "exclusive"];
|
|
98
|
+
type TaxBehavior = (typeof TAX_BEHAVIORS)[number];
|
|
99
|
+
declare const TAX_EXCLUSIVE_CURRENCIES: readonly ["USD", "CAD"];
|
|
100
|
+
declare function resolveTaxBehavior(behavior: TaxBehavior, currency: string): 'inclusive' | 'exclusive';
|
|
101
|
+
type TaxBreakdown = {
|
|
102
|
+
subtotal: number;
|
|
103
|
+
taxAmount: number;
|
|
104
|
+
taxRate: number;
|
|
105
|
+
treatment: 'reverse_charge' | 'standard' | 'none' | 'not_collecting';
|
|
106
|
+
total: number;
|
|
107
|
+
currency: string;
|
|
108
|
+
inclusive: boolean;
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
export { BUSINESS_COUNTRY_DISPLAY_NAMES as B, COUNTRY_TO_TAX_ID_TYPE as C, type EuMemberCountry as E, SUPPORTED_BUSINESS_COUNTRIES as S, TAX_BEHAVIORS as T, type ValidateBusinessDetailsResult as V, BUSINESS_COUNTRY_OPTIONS as a, type BusinessCountryOption as b, type BusinessDetails as c, type BusinessDetailsInput as d, BusinessDetailsSchema as e, type BusinessDetailsValidationError as f, type BusinessDetailsValidationIssue as g, type SupportedBusinessCountry as h, TAX_EXCLUSIVE_CURRENCIES as i, TAX_ID_EXAMPLE_BY_COUNTRY as j, TAX_ID_TYPES as k, type TaxBehavior as l, type TaxBreakdown as m, type TaxIdType as n, deriveTaxIdType as o, getTaxIdExample as p, getTaxIdFieldLabel as q, getTaxIdHelperText as r, resolveTaxBehavior as s, validateBusinessDetails as v };
|
|
@@ -0,0 +1,360 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/business-details-public.ts
|
|
21
|
+
var business_details_public_exports = {};
|
|
22
|
+
__export(business_details_public_exports, {
|
|
23
|
+
BUSINESS_COUNTRY_DISPLAY_NAMES: () => BUSINESS_COUNTRY_DISPLAY_NAMES,
|
|
24
|
+
BUSINESS_COUNTRY_OPTIONS: () => BUSINESS_COUNTRY_OPTIONS,
|
|
25
|
+
COUNTRY_TO_TAX_ID_TYPE: () => COUNTRY_TO_TAX_ID_TYPE,
|
|
26
|
+
SUPPORTED_BUSINESS_COUNTRIES: () => SUPPORTED_BUSINESS_COUNTRIES,
|
|
27
|
+
TAX_BEHAVIORS: () => TAX_BEHAVIORS,
|
|
28
|
+
TAX_EXCLUSIVE_CURRENCIES: () => TAX_EXCLUSIVE_CURRENCIES,
|
|
29
|
+
TAX_ID_EXAMPLE_BY_COUNTRY: () => TAX_ID_EXAMPLE_BY_COUNTRY,
|
|
30
|
+
TAX_ID_TYPES: () => TAX_ID_TYPES,
|
|
31
|
+
deriveTaxIdType: () => deriveTaxIdType,
|
|
32
|
+
getTaxIdExample: () => getTaxIdExample,
|
|
33
|
+
getTaxIdFieldLabel: () => getTaxIdFieldLabel,
|
|
34
|
+
getTaxIdHelperText: () => getTaxIdHelperText,
|
|
35
|
+
resolveTaxBehavior: () => resolveTaxBehavior,
|
|
36
|
+
validateBusinessDetails: () => validateBusinessDetails
|
|
37
|
+
});
|
|
38
|
+
module.exports = __toCommonJS(business_details_public_exports);
|
|
39
|
+
|
|
40
|
+
// src/business-details.ts
|
|
41
|
+
var import_zod = require("zod");
|
|
42
|
+
var TAX_ID_TYPES = ["eu_vat", "gb_vat", "us_ein"];
|
|
43
|
+
var EU_MEMBER_COUNTRIES = [
|
|
44
|
+
"AT",
|
|
45
|
+
"BE",
|
|
46
|
+
"BG",
|
|
47
|
+
"HR",
|
|
48
|
+
"CY",
|
|
49
|
+
"CZ",
|
|
50
|
+
"DK",
|
|
51
|
+
"EE",
|
|
52
|
+
"FI",
|
|
53
|
+
"FR",
|
|
54
|
+
"DE",
|
|
55
|
+
"GR",
|
|
56
|
+
"HU",
|
|
57
|
+
"IE",
|
|
58
|
+
"IT",
|
|
59
|
+
"LV",
|
|
60
|
+
"LT",
|
|
61
|
+
"LU",
|
|
62
|
+
"MT",
|
|
63
|
+
"NL",
|
|
64
|
+
"PL",
|
|
65
|
+
"PT",
|
|
66
|
+
"RO",
|
|
67
|
+
"SK",
|
|
68
|
+
"SI",
|
|
69
|
+
"ES",
|
|
70
|
+
"SE"
|
|
71
|
+
];
|
|
72
|
+
var SUPPORTED_BUSINESS_COUNTRIES = [...EU_MEMBER_COUNTRIES, "GB", "US"];
|
|
73
|
+
var BUSINESS_COUNTRY_DISPLAY_NAMES = {
|
|
74
|
+
AT: "Austria",
|
|
75
|
+
BE: "Belgium",
|
|
76
|
+
BG: "Bulgaria",
|
|
77
|
+
HR: "Croatia",
|
|
78
|
+
CY: "Cyprus",
|
|
79
|
+
CZ: "Czechia",
|
|
80
|
+
DK: "Denmark",
|
|
81
|
+
EE: "Estonia",
|
|
82
|
+
FI: "Finland",
|
|
83
|
+
FR: "France",
|
|
84
|
+
DE: "Germany",
|
|
85
|
+
GR: "Greece",
|
|
86
|
+
HU: "Hungary",
|
|
87
|
+
IE: "Ireland",
|
|
88
|
+
IT: "Italy",
|
|
89
|
+
LV: "Latvia",
|
|
90
|
+
LT: "Lithuania",
|
|
91
|
+
LU: "Luxembourg",
|
|
92
|
+
MT: "Malta",
|
|
93
|
+
NL: "Netherlands",
|
|
94
|
+
PL: "Poland",
|
|
95
|
+
PT: "Portugal",
|
|
96
|
+
RO: "Romania",
|
|
97
|
+
SK: "Slovakia",
|
|
98
|
+
SI: "Slovenia",
|
|
99
|
+
ES: "Spain",
|
|
100
|
+
SE: "Sweden",
|
|
101
|
+
GB: "United Kingdom",
|
|
102
|
+
US: "United States of America"
|
|
103
|
+
};
|
|
104
|
+
var BUSINESS_COUNTRY_OPTIONS = SUPPORTED_BUSINESS_COUNTRIES.map(
|
|
105
|
+
(code) => ({
|
|
106
|
+
value: code,
|
|
107
|
+
label: BUSINESS_COUNTRY_DISPLAY_NAMES[code]
|
|
108
|
+
})
|
|
109
|
+
).sort((a, b) => a.label.localeCompare(b.label));
|
|
110
|
+
var COUNTRY_TO_TAX_ID_TYPE = {
|
|
111
|
+
AT: "eu_vat",
|
|
112
|
+
BE: "eu_vat",
|
|
113
|
+
BG: "eu_vat",
|
|
114
|
+
HR: "eu_vat",
|
|
115
|
+
CY: "eu_vat",
|
|
116
|
+
CZ: "eu_vat",
|
|
117
|
+
DK: "eu_vat",
|
|
118
|
+
EE: "eu_vat",
|
|
119
|
+
FI: "eu_vat",
|
|
120
|
+
FR: "eu_vat",
|
|
121
|
+
DE: "eu_vat",
|
|
122
|
+
GR: "eu_vat",
|
|
123
|
+
HU: "eu_vat",
|
|
124
|
+
IE: "eu_vat",
|
|
125
|
+
IT: "eu_vat",
|
|
126
|
+
LV: "eu_vat",
|
|
127
|
+
LT: "eu_vat",
|
|
128
|
+
LU: "eu_vat",
|
|
129
|
+
MT: "eu_vat",
|
|
130
|
+
NL: "eu_vat",
|
|
131
|
+
PL: "eu_vat",
|
|
132
|
+
PT: "eu_vat",
|
|
133
|
+
RO: "eu_vat",
|
|
134
|
+
SK: "eu_vat",
|
|
135
|
+
SI: "eu_vat",
|
|
136
|
+
ES: "eu_vat",
|
|
137
|
+
SE: "eu_vat",
|
|
138
|
+
GB: "gb_vat",
|
|
139
|
+
US: "us_ein"
|
|
140
|
+
};
|
|
141
|
+
var TAX_ID_REGEX_BY_COUNTRY = {
|
|
142
|
+
AT: /^ATU\d{8}$/,
|
|
143
|
+
BE: /^BE[01]\d{9}$/,
|
|
144
|
+
BG: /^BG\d{9,10}$/,
|
|
145
|
+
HR: /^HR\d{11}$/,
|
|
146
|
+
CY: /^CY\d{8}[A-Z]$/,
|
|
147
|
+
CZ: /^CZ\d{8,10}$/,
|
|
148
|
+
DK: /^DK\d{8}$/,
|
|
149
|
+
EE: /^EE\d{9}$/,
|
|
150
|
+
FI: /^FI\d{8}$/,
|
|
151
|
+
FR: /^FR[A-HJ-NP-Z0-9]{2}\d{9}$/,
|
|
152
|
+
DE: /^DE\d{9}$/,
|
|
153
|
+
GR: /^EL\d{9}$/,
|
|
154
|
+
HU: /^HU\d{8}$/,
|
|
155
|
+
IE: /^IE\d{7}[A-W][A-I]?$/,
|
|
156
|
+
IT: /^IT\d{11}$/,
|
|
157
|
+
LV: /^LV\d{11}$/,
|
|
158
|
+
LT: /^LT(\d{9}|\d{12})$/,
|
|
159
|
+
LU: /^LU\d{8}$/,
|
|
160
|
+
MT: /^MT\d{8}$/,
|
|
161
|
+
NL: /^NL\d{9}B\d{2}$/,
|
|
162
|
+
PL: /^PL\d{10}$/,
|
|
163
|
+
PT: /^PT\d{9}$/,
|
|
164
|
+
RO: /^RO\d{2,10}$/,
|
|
165
|
+
SK: /^SK\d{10}$/,
|
|
166
|
+
SI: /^SI\d{8}$/,
|
|
167
|
+
ES: /^ES[A-Z0-9]\d{7}[A-Z0-9]$/,
|
|
168
|
+
SE: /^SE\d{12}$/,
|
|
169
|
+
GB: /^GB(\d{9}|\d{12}|GD\d{3}|HA\d{3})$/,
|
|
170
|
+
US: /^\d{2}-?\d{7}$/
|
|
171
|
+
};
|
|
172
|
+
function deriveTaxIdType(country) {
|
|
173
|
+
return COUNTRY_TO_TAX_ID_TYPE[country];
|
|
174
|
+
}
|
|
175
|
+
var TAX_ID_EXAMPLE_BY_COUNTRY = {
|
|
176
|
+
AT: "ATU12345678",
|
|
177
|
+
BE: "BE0123456789",
|
|
178
|
+
BG: "BG0123456789",
|
|
179
|
+
HR: "HR12345678912",
|
|
180
|
+
CY: "CY12345678Z",
|
|
181
|
+
CZ: "CZ1234567890",
|
|
182
|
+
DK: "DK12345678",
|
|
183
|
+
EE: "EE123456789",
|
|
184
|
+
FI: "FI12345678",
|
|
185
|
+
FR: "FRAB123456789",
|
|
186
|
+
DE: "DE123456789",
|
|
187
|
+
GR: "EL123456789",
|
|
188
|
+
HU: "HU12345678",
|
|
189
|
+
IE: "IE1234567AB",
|
|
190
|
+
IT: "IT12345678912",
|
|
191
|
+
LV: "LV12345678912",
|
|
192
|
+
LT: "LT123456789",
|
|
193
|
+
LU: "LU12345678",
|
|
194
|
+
MT: "MT12345678",
|
|
195
|
+
NL: "NL123456789B12",
|
|
196
|
+
PL: "PL1234567890",
|
|
197
|
+
PT: "PT123456789",
|
|
198
|
+
RO: "RO1234567891",
|
|
199
|
+
SK: "SK1234567891",
|
|
200
|
+
SI: "SI12345678",
|
|
201
|
+
ES: "ESA1234567Z",
|
|
202
|
+
SE: "SE123456789123",
|
|
203
|
+
GB: "GB123456789",
|
|
204
|
+
US: "12-3456789"
|
|
205
|
+
};
|
|
206
|
+
var TAX_ID_FIELD_LABEL_BY_TYPE = {
|
|
207
|
+
eu_vat: "VAT ID",
|
|
208
|
+
gb_vat: "VAT Number",
|
|
209
|
+
us_ein: "EIN (Employer Identification Number)"
|
|
210
|
+
};
|
|
211
|
+
function getTaxIdFieldLabel(country) {
|
|
212
|
+
return TAX_ID_FIELD_LABEL_BY_TYPE[deriveTaxIdType(country)];
|
|
213
|
+
}
|
|
214
|
+
function getTaxIdExample(country) {
|
|
215
|
+
return TAX_ID_EXAMPLE_BY_COUNTRY[country];
|
|
216
|
+
}
|
|
217
|
+
function getTaxIdHelperText(country) {
|
|
218
|
+
const example = getTaxIdExample(country);
|
|
219
|
+
const taxIdType = deriveTaxIdType(country);
|
|
220
|
+
if (taxIdType === "us_ein") {
|
|
221
|
+
return `Enter your EIN, e.g. ${example}`;
|
|
222
|
+
}
|
|
223
|
+
if (taxIdType === "gb_vat") {
|
|
224
|
+
return `Enter your full VAT number including the country code, e.g. ${example}`;
|
|
225
|
+
}
|
|
226
|
+
return `Enter your full VAT ID including the country code, e.g. ${example}`;
|
|
227
|
+
}
|
|
228
|
+
function isSupportedCountry(value) {
|
|
229
|
+
return SUPPORTED_BUSINESS_COUNTRIES.includes(value);
|
|
230
|
+
}
|
|
231
|
+
function normalizeTaxId(taxId) {
|
|
232
|
+
return taxId.trim().toUpperCase().replace(/\s+/g, "");
|
|
233
|
+
}
|
|
234
|
+
function isValidTaxIdForCountry(country, taxId) {
|
|
235
|
+
const normalized = normalizeTaxId(taxId);
|
|
236
|
+
return TAX_ID_REGEX_BY_COUNTRY[country].test(normalized);
|
|
237
|
+
}
|
|
238
|
+
var BusinessDetailsSchema = import_zod.z.object({
|
|
239
|
+
isBusiness: import_zod.z.boolean(),
|
|
240
|
+
businessName: import_zod.z.string().optional(),
|
|
241
|
+
country: import_zod.z.string().optional(),
|
|
242
|
+
customerCountry: import_zod.z.string().optional(),
|
|
243
|
+
taxId: import_zod.z.string().optional(),
|
|
244
|
+
taxIdType: import_zod.z.enum(TAX_ID_TYPES).optional()
|
|
245
|
+
}).superRefine((data, ctx) => {
|
|
246
|
+
if (!data.isBusiness) {
|
|
247
|
+
if (data.customerCountry?.trim()) {
|
|
248
|
+
const customerCountryUpper = data.customerCountry.trim().toUpperCase();
|
|
249
|
+
if (!isSupportedCountry(customerCountryUpper)) {
|
|
250
|
+
ctx.addIssue({
|
|
251
|
+
code: "custom",
|
|
252
|
+
message: "Billing country is not supported for tax calculation",
|
|
253
|
+
path: ["customerCountry"]
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
return;
|
|
258
|
+
}
|
|
259
|
+
if (!data.businessName?.trim()) {
|
|
260
|
+
ctx.addIssue({
|
|
261
|
+
code: "custom",
|
|
262
|
+
message: "Business name is required",
|
|
263
|
+
path: ["businessName"]
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
if (!data.country?.trim()) {
|
|
267
|
+
ctx.addIssue({
|
|
268
|
+
code: "custom",
|
|
269
|
+
message: "Country is required",
|
|
270
|
+
path: ["country"]
|
|
271
|
+
});
|
|
272
|
+
return;
|
|
273
|
+
}
|
|
274
|
+
const countryUpper = data.country.trim().toUpperCase();
|
|
275
|
+
if (!isSupportedCountry(countryUpper)) {
|
|
276
|
+
ctx.addIssue({
|
|
277
|
+
code: "custom",
|
|
278
|
+
message: "Country is not supported for business purchases",
|
|
279
|
+
path: ["country"]
|
|
280
|
+
});
|
|
281
|
+
return;
|
|
282
|
+
}
|
|
283
|
+
if (!data.taxId?.trim()) {
|
|
284
|
+
ctx.addIssue({
|
|
285
|
+
code: "custom",
|
|
286
|
+
message: "Tax ID is required",
|
|
287
|
+
path: ["taxId"]
|
|
288
|
+
});
|
|
289
|
+
return;
|
|
290
|
+
}
|
|
291
|
+
const normalizedTaxId = normalizeTaxId(data.taxId);
|
|
292
|
+
if (!isValidTaxIdForCountry(countryUpper, normalizedTaxId)) {
|
|
293
|
+
ctx.addIssue({
|
|
294
|
+
code: "custom",
|
|
295
|
+
message: `Enter a valid tax ID for ${countryUpper}`,
|
|
296
|
+
path: ["taxId"]
|
|
297
|
+
});
|
|
298
|
+
}
|
|
299
|
+
}).transform((data) => {
|
|
300
|
+
if (!data.isBusiness) {
|
|
301
|
+
const customerCountry = data.customerCountry?.trim().toUpperCase();
|
|
302
|
+
if (customerCountry && isSupportedCountry(customerCountry)) {
|
|
303
|
+
return { isBusiness: false, customerCountry };
|
|
304
|
+
}
|
|
305
|
+
return { isBusiness: false };
|
|
306
|
+
}
|
|
307
|
+
const country = data.country.trim().toUpperCase();
|
|
308
|
+
const taxId = normalizeTaxId(data.taxId);
|
|
309
|
+
const taxIdType = deriveTaxIdType(country);
|
|
310
|
+
return {
|
|
311
|
+
isBusiness: true,
|
|
312
|
+
businessName: data.businessName.trim(),
|
|
313
|
+
country,
|
|
314
|
+
taxId,
|
|
315
|
+
taxIdType
|
|
316
|
+
};
|
|
317
|
+
});
|
|
318
|
+
function validateBusinessDetails(input) {
|
|
319
|
+
const parsed = BusinessDetailsSchema.safeParse(input);
|
|
320
|
+
if (!parsed.success) {
|
|
321
|
+
return {
|
|
322
|
+
success: false,
|
|
323
|
+
error: {
|
|
324
|
+
issues: parsed.error.issues.map((issue) => ({
|
|
325
|
+
path: issue.path,
|
|
326
|
+
message: issue.message
|
|
327
|
+
}))
|
|
328
|
+
}
|
|
329
|
+
};
|
|
330
|
+
}
|
|
331
|
+
return { success: true, data: parsed.data };
|
|
332
|
+
}
|
|
333
|
+
var TAX_BEHAVIORS = ["auto", "inclusive", "exclusive"];
|
|
334
|
+
var TAX_EXCLUSIVE_CURRENCIES = ["USD", "CAD"];
|
|
335
|
+
function resolveTaxBehavior(behavior, currency) {
|
|
336
|
+
if (behavior === "inclusive" || behavior === "exclusive") {
|
|
337
|
+
return behavior;
|
|
338
|
+
}
|
|
339
|
+
const normalizedCurrency = currency.toUpperCase();
|
|
340
|
+
return TAX_EXCLUSIVE_CURRENCIES.includes(
|
|
341
|
+
normalizedCurrency
|
|
342
|
+
) ? "exclusive" : "inclusive";
|
|
343
|
+
}
|
|
344
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
345
|
+
0 && (module.exports = {
|
|
346
|
+
BUSINESS_COUNTRY_DISPLAY_NAMES,
|
|
347
|
+
BUSINESS_COUNTRY_OPTIONS,
|
|
348
|
+
COUNTRY_TO_TAX_ID_TYPE,
|
|
349
|
+
SUPPORTED_BUSINESS_COUNTRIES,
|
|
350
|
+
TAX_BEHAVIORS,
|
|
351
|
+
TAX_EXCLUSIVE_CURRENCIES,
|
|
352
|
+
TAX_ID_EXAMPLE_BY_COUNTRY,
|
|
353
|
+
TAX_ID_TYPES,
|
|
354
|
+
deriveTaxIdType,
|
|
355
|
+
getTaxIdExample,
|
|
356
|
+
getTaxIdFieldLabel,
|
|
357
|
+
getTaxIdHelperText,
|
|
358
|
+
resolveTaxBehavior,
|
|
359
|
+
validateBusinessDetails
|
|
360
|
+
});
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export { B as BUSINESS_COUNTRY_DISPLAY_NAMES, a as BUSINESS_COUNTRY_OPTIONS, b as BusinessCountryOption, c as BusinessDetails, d as BusinessDetailsInput, f as BusinessDetailsValidationError, g as BusinessDetailsValidationIssue, C as COUNTRY_TO_TAX_ID_TYPE, E as EuMemberCountry, S as SUPPORTED_BUSINESS_COUNTRIES, h as SupportedBusinessCountry, T as TAX_BEHAVIORS, i as TAX_EXCLUSIVE_CURRENCIES, j as TAX_ID_EXAMPLE_BY_COUNTRY, k as TAX_ID_TYPES, l as TaxBehavior, m as TaxBreakdown, n as TaxIdType, V as ValidateBusinessDetailsResult, o as deriveTaxIdType, p as getTaxIdExample, q as getTaxIdFieldLabel, r as getTaxIdHelperText, s as resolveTaxBehavior, v as validateBusinessDetails } from './business-details-public-C1TEVVdQ.cjs';
|
|
2
|
+
import 'zod';
|