@funnelfox/billing 0.1.0 → 0.2.1
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/README.md +62 -49
- package/dist/chunk-index.cjs.js +56 -0
- package/dist/chunk-index.es.js +54 -0
- package/dist/funnelfox-billing.cjs.js +1071 -1382
- package/dist/funnelfox-billing.esm.js +1072 -1382
- package/dist/funnelfox-billing.js +1176 -1436
- package/dist/funnelfox-billing.min.js +1 -1
- package/package.json +25 -16
- package/src/types.d.ts +71 -27
- package/dist/funnelfox-billing.cjs.d.ts +0 -2
- package/dist/funnelfox-billing.d.ts +0 -204
- package/dist/funnelfox-billing.esm.d.ts +0 -2
- package/types.d.ts +0 -203
package/types.d.ts
DELETED
|
@@ -1,203 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* TypeScript definitions for @funnelfox/billing
|
|
3
|
-
* These types are importable by users and used internally via JSDoc
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
export interface SDKConfig {
|
|
7
|
-
orgId: string;
|
|
8
|
-
baseUrl?: string;
|
|
9
|
-
region?: string;
|
|
10
|
-
sandbox?: boolean;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export interface APIConfig {
|
|
14
|
-
baseUrl?: string;
|
|
15
|
-
region?: string;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export interface Customer {
|
|
19
|
-
email: string;
|
|
20
|
-
externalId: string;
|
|
21
|
-
countryCode?: string;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export interface CheckoutConfig {
|
|
25
|
-
customer: Customer;
|
|
26
|
-
priceId: string;
|
|
27
|
-
container: string;
|
|
28
|
-
clientMetadata?: Record<string, any>;
|
|
29
|
-
universalCheckoutOptions?: PrimerCheckoutOptions;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export interface CheckoutConfigWithCallbacks extends CheckoutConfig {
|
|
33
|
-
onSuccess?: (result: PaymentResult) => void;
|
|
34
|
-
onError?: (error: Error) => void;
|
|
35
|
-
onStatusChange?: (newState: CheckoutState, oldState?: CheckoutState) => void;
|
|
36
|
-
onDestroy?: () => void;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export interface CreateCheckoutOptions extends CheckoutConfigWithCallbacks {
|
|
40
|
-
orgId?: string;
|
|
41
|
-
apiConfig?: APIConfig;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export interface PrimerCheckoutOptions {
|
|
45
|
-
paymentHandling?: 'MANUAL' | 'AUTO';
|
|
46
|
-
apiVersion?: string;
|
|
47
|
-
paypal?: {
|
|
48
|
-
buttonColor?: 'blue' | 'gold' | 'silver' | 'white' | 'black';
|
|
49
|
-
paymentFlow?: 'PREFER_VAULT' | 'VAULT_ONLY' | 'CHECKOUT_ONLY';
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export interface PaymentResult {
|
|
54
|
-
orderId: string;
|
|
55
|
-
status: 'succeeded' | 'failed' | 'cancelled' | 'processing';
|
|
56
|
-
transactionId?: string;
|
|
57
|
-
failureReason?: string;
|
|
58
|
-
metadata?: Record<string, any>;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export type CheckoutState =
|
|
62
|
-
| 'initializing'
|
|
63
|
-
| 'ready'
|
|
64
|
-
| 'processing'
|
|
65
|
-
| 'action_required'
|
|
66
|
-
| 'updating'
|
|
67
|
-
| 'completed'
|
|
68
|
-
| 'error'
|
|
69
|
-
| 'destroyed';
|
|
70
|
-
|
|
71
|
-
export type CheckoutEventName = 'success' | 'error' | 'status-change' | 'destroy';
|
|
72
|
-
|
|
73
|
-
export interface CheckoutStatus {
|
|
74
|
-
id: string;
|
|
75
|
-
state: CheckoutState;
|
|
76
|
-
orderId: string | null;
|
|
77
|
-
priceId: string;
|
|
78
|
-
isDestroyed: boolean;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
export interface CheckoutInstance {
|
|
82
|
-
readonly id: string;
|
|
83
|
-
readonly state: CheckoutState;
|
|
84
|
-
readonly orderId: string | null;
|
|
85
|
-
readonly isDestroyed: boolean;
|
|
86
|
-
|
|
87
|
-
updatePrice(newPriceId: string): Promise<void>;
|
|
88
|
-
getStatus(): CheckoutStatus;
|
|
89
|
-
destroy(): Promise<void>;
|
|
90
|
-
getContainer(): Element | null;
|
|
91
|
-
isInState(state: CheckoutState): boolean;
|
|
92
|
-
isReady(): boolean;
|
|
93
|
-
isProcessing(): boolean;
|
|
94
|
-
|
|
95
|
-
on(eventName: 'success', handler: (result: PaymentResult) => void): this;
|
|
96
|
-
on(eventName: 'error', handler: (error: Error) => void): this;
|
|
97
|
-
on(eventName: 'status-change', handler: (newState: CheckoutState, oldState?: CheckoutState) => void): this;
|
|
98
|
-
on(eventName: 'destroy', handler: () => void): this;
|
|
99
|
-
on(eventName: CheckoutEventName, handler: (...args: any[]) => void): this;
|
|
100
|
-
|
|
101
|
-
off(eventName: CheckoutEventName, handler?: Function): this;
|
|
102
|
-
once(eventName: CheckoutEventName, handler: Function): this;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
// API Response types
|
|
106
|
-
export interface ClientSessionResponse {
|
|
107
|
-
status: 'success' | 'error';
|
|
108
|
-
data: {
|
|
109
|
-
client_token: string;
|
|
110
|
-
order_id: string;
|
|
111
|
-
action_required_token?: string;
|
|
112
|
-
checkout_status?: 'succeeded' | 'failed' | 'cancelled' | 'processing';
|
|
113
|
-
failed_message_for_user?: string;
|
|
114
|
-
};
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
export interface PaymentMethodTokenData {
|
|
118
|
-
token: string;
|
|
119
|
-
metadata?: Record<string, any>;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
export interface ResumeTokenData {
|
|
123
|
-
resumeToken: string;
|
|
124
|
-
metadata?: Record<string, any>;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
export interface PrimerHandler {
|
|
128
|
-
handleSuccess(): void;
|
|
129
|
-
handleFailure(message: string): void;
|
|
130
|
-
continueWithNewClientToken(token: string): void;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
// Error types
|
|
134
|
-
export interface FunnefoxSDKError extends Error {
|
|
135
|
-
code: string;
|
|
136
|
-
details: any;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
export interface ValidationError extends FunnefoxSDKError {
|
|
140
|
-
field: string;
|
|
141
|
-
value: any;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
export interface APIError extends FunnefoxSDKError {
|
|
145
|
-
statusCode: number | null;
|
|
146
|
-
errorCode: string | null;
|
|
147
|
-
errorType: string | null;
|
|
148
|
-
requestId: string | null;
|
|
149
|
-
response: any;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
export interface PrimerError extends FunnefoxSDKError {
|
|
153
|
-
primerError: any;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
export interface CheckoutError extends FunnefoxSDKError {
|
|
157
|
-
phase: string | null;
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
export interface ConfigurationError extends FunnefoxSDKError {}
|
|
161
|
-
|
|
162
|
-
export interface NetworkError extends FunnefoxSDKError {
|
|
163
|
-
originalError: any;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
// Function signatures
|
|
167
|
-
export declare function configure(config: SDKConfig): void;
|
|
168
|
-
|
|
169
|
-
export declare function createCheckout(options: CreateCheckoutOptions): Promise<CheckoutInstance>;
|
|
170
|
-
|
|
171
|
-
export declare function showUniversalCheckout(clientToken: string, options: any): Promise<any>;
|
|
172
|
-
|
|
173
|
-
export interface CreateClientSessionOptions {
|
|
174
|
-
priceId: string;
|
|
175
|
-
externalId: string;
|
|
176
|
-
email: string;
|
|
177
|
-
orgId?: string;
|
|
178
|
-
apiConfig?: APIConfig;
|
|
179
|
-
clientMetadata?: Record<string, any>;
|
|
180
|
-
countryCode?: string;
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
export interface ClientSessionData {
|
|
184
|
-
clientToken: string;
|
|
185
|
-
orderId: string;
|
|
186
|
-
type: string;
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
export declare function createClientSession(params: CreateClientSessionOptions): Promise<ClientSessionData>;
|
|
190
|
-
|
|
191
|
-
// Billing namespace
|
|
192
|
-
export declare const Billing: {
|
|
193
|
-
configure: typeof configure;
|
|
194
|
-
createCheckout: typeof createCheckout;
|
|
195
|
-
showUniversalCheckout: typeof showUniversalCheckout;
|
|
196
|
-
createClientSession: typeof createClientSession;
|
|
197
|
-
};
|
|
198
|
-
|
|
199
|
-
// Constants
|
|
200
|
-
export declare const SDK_VERSION: string;
|
|
201
|
-
export declare const CHECKOUT_STATES: Record<string, CheckoutState>;
|
|
202
|
-
export declare const EVENTS: Record<string, CheckoutEventName>;
|
|
203
|
-
export declare const ERROR_CODES: Record<string, string>;
|