@paynl/payparts-types 1.4.0-alpha.93
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/dist/index.d.ts +1 -0
- package/dist/src/core/errors/PaymentError.d.ts +9 -0
- package/dist/src/core/errors/api-error-response.d.ts +10 -0
- package/dist/src/core/payment-status.d.ts +10 -0
- package/dist/src/core/types.d.ts +655 -0
- package/dist/types-pkg/src/index.d.ts +4 -0
- package/package.json +24 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './types-pkg/src/index';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ApiErrorResponse, ApiFieldError } from './api-error-response';
|
|
2
|
+
export declare class PaymentError extends Error {
|
|
3
|
+
readonly errorId: string;
|
|
4
|
+
readonly errorTag: string;
|
|
5
|
+
readonly errorMessage: string;
|
|
6
|
+
readonly fieldErrors?: ApiFieldError[] | undefined;
|
|
7
|
+
constructor(errorId: string, errorTag: string, errorMessage: string, fieldErrors?: ApiFieldError[] | undefined);
|
|
8
|
+
static fromResponse(response: ApiErrorResponse): PaymentError;
|
|
9
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export type PaymentOutcome = 'success' | 'failure' | 'pending' | 'unknown';
|
|
2
|
+
export interface PaymentStatusInfo {
|
|
3
|
+
code: number;
|
|
4
|
+
action: string;
|
|
5
|
+
outcome: PaymentOutcome;
|
|
6
|
+
}
|
|
7
|
+
export declare function getPaymentOutcome(code: number): PaymentOutcome;
|
|
8
|
+
export declare function isSuccessfulPayment(code: number): boolean;
|
|
9
|
+
export declare function isFailedPayment(code: number): boolean;
|
|
10
|
+
export declare function isPendingPayment(code: number): boolean;
|
|
@@ -0,0 +1,655 @@
|
|
|
1
|
+
export interface OrderPaymentStatus {
|
|
2
|
+
code: number;
|
|
3
|
+
action: string;
|
|
4
|
+
}
|
|
5
|
+
export interface OrderPaymentMethodInfo {
|
|
6
|
+
id: number;
|
|
7
|
+
name?: string;
|
|
8
|
+
icon?: string;
|
|
9
|
+
}
|
|
10
|
+
export interface OrderPaymentInfo {
|
|
11
|
+
id: string;
|
|
12
|
+
paymentMethod: OrderPaymentMethodInfo;
|
|
13
|
+
amount: AmountDto;
|
|
14
|
+
capturedAmount: AmountDto;
|
|
15
|
+
authorizedAmount: AmountDto;
|
|
16
|
+
status: OrderPaymentStatus;
|
|
17
|
+
state: string;
|
|
18
|
+
}
|
|
19
|
+
export interface PartialPaymentUpdate {
|
|
20
|
+
orderId: string;
|
|
21
|
+
isFullyPaid: boolean;
|
|
22
|
+
transaction: {
|
|
23
|
+
transactionId: string;
|
|
24
|
+
amount: AmountDto;
|
|
25
|
+
};
|
|
26
|
+
order: {
|
|
27
|
+
amount: AmountDto;
|
|
28
|
+
authorizedAmount: AmountDto;
|
|
29
|
+
capturedAmount: AmountDto;
|
|
30
|
+
payments: OrderPaymentInfo[];
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
export interface PaymentMethodContext {
|
|
34
|
+
method: PaymentMethod;
|
|
35
|
+
amount: number;
|
|
36
|
+
currency: string;
|
|
37
|
+
language: string;
|
|
38
|
+
apiUrl: string;
|
|
39
|
+
config: CheckoutConfig;
|
|
40
|
+
getConfig: () => Readonly<Required<CheckoutConfig>>;
|
|
41
|
+
onSubmit: (data: {
|
|
42
|
+
method: string;
|
|
43
|
+
details?: Record<string, unknown>;
|
|
44
|
+
}) => void;
|
|
45
|
+
onError: (error: {
|
|
46
|
+
message: string;
|
|
47
|
+
errorId?: string;
|
|
48
|
+
errorTag?: string;
|
|
49
|
+
errors?: FieldError[];
|
|
50
|
+
}, errorId?: string, result?: string) => void;
|
|
51
|
+
onSuccess?: (data: {
|
|
52
|
+
orderId: string;
|
|
53
|
+
returnUrl: string;
|
|
54
|
+
threeDs?: ThreeDsData;
|
|
55
|
+
transaction?: TransactionData;
|
|
56
|
+
}) => void;
|
|
57
|
+
onPartialPaid?: (data: PartialPaymentEventData) => void;
|
|
58
|
+
onInfoUpdated?: (data: InfoUpdatedEvent['data']) => void;
|
|
59
|
+
onShippingUpdated?: (data: ShippingUpdatedEvent['data']) => void;
|
|
60
|
+
}
|
|
61
|
+
export interface InternalPaymentMethodContext extends PaymentMethodContext {
|
|
62
|
+
/** @internal */
|
|
63
|
+
_updatePartialPayment?: (response: PartialPaymentUpdate) => void;
|
|
64
|
+
/** @internal Returns the amount to display for payment (accounts for partial payments) */
|
|
65
|
+
_getOutstandingAmount: () => {
|
|
66
|
+
value: number;
|
|
67
|
+
currency: string;
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
export interface LocationTranslations {
|
|
71
|
+
name?: Record<string, string>;
|
|
72
|
+
}
|
|
73
|
+
export interface MerchantInfo {
|
|
74
|
+
code: string;
|
|
75
|
+
name: string;
|
|
76
|
+
status: string;
|
|
77
|
+
}
|
|
78
|
+
export interface CategoryInfo {
|
|
79
|
+
code: string;
|
|
80
|
+
name: string;
|
|
81
|
+
}
|
|
82
|
+
export interface PaymentMethodOption {
|
|
83
|
+
id?: string;
|
|
84
|
+
name?: unknown;
|
|
85
|
+
image?: string;
|
|
86
|
+
}
|
|
87
|
+
export interface CheckoutTranslations {
|
|
88
|
+
name?: unknown;
|
|
89
|
+
description?: unknown;
|
|
90
|
+
minAge?: unknown;
|
|
91
|
+
}
|
|
92
|
+
export interface PaymentMethod {
|
|
93
|
+
id: number;
|
|
94
|
+
name: string;
|
|
95
|
+
description?: unknown;
|
|
96
|
+
translations?: CheckoutTranslations;
|
|
97
|
+
image?: string;
|
|
98
|
+
payLink?: string;
|
|
99
|
+
targetCountries: string[];
|
|
100
|
+
options?: PaymentMethodOption[];
|
|
101
|
+
settings?: unknown;
|
|
102
|
+
minAmount: number;
|
|
103
|
+
maxAmount: number;
|
|
104
|
+
}
|
|
105
|
+
export interface CheckoutOption {
|
|
106
|
+
tag: string;
|
|
107
|
+
id: number;
|
|
108
|
+
smartGrouping: boolean;
|
|
109
|
+
name?: unknown;
|
|
110
|
+
translations?: CheckoutTranslations;
|
|
111
|
+
image?: string;
|
|
112
|
+
paymentMethods: PaymentMethod[];
|
|
113
|
+
requiredFields?: unknown;
|
|
114
|
+
}
|
|
115
|
+
export interface SequenceGroup {
|
|
116
|
+
primary: string[];
|
|
117
|
+
secondary: string[];
|
|
118
|
+
}
|
|
119
|
+
export interface CheckoutSequence {
|
|
120
|
+
default: SequenceGroup;
|
|
121
|
+
NL?: SequenceGroup;
|
|
122
|
+
BE?: SequenceGroup;
|
|
123
|
+
}
|
|
124
|
+
export type CountrySequence = 'NL' | 'BE';
|
|
125
|
+
export interface LocationInfo {
|
|
126
|
+
code: string;
|
|
127
|
+
testMode: boolean;
|
|
128
|
+
name: string;
|
|
129
|
+
translations?: {
|
|
130
|
+
name?: Record<string, string>;
|
|
131
|
+
};
|
|
132
|
+
status: string;
|
|
133
|
+
merchant?: {
|
|
134
|
+
code: string;
|
|
135
|
+
name: string;
|
|
136
|
+
status: string;
|
|
137
|
+
};
|
|
138
|
+
category?: {
|
|
139
|
+
code: string;
|
|
140
|
+
name: string;
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
export interface AmountDto {
|
|
144
|
+
value: number;
|
|
145
|
+
currency: string;
|
|
146
|
+
formatted?: string;
|
|
147
|
+
}
|
|
148
|
+
export interface PaymentMethodInputDto {
|
|
149
|
+
cardNumber?: string;
|
|
150
|
+
pincode?: string;
|
|
151
|
+
}
|
|
152
|
+
export interface SessionPaymentMethodInfo {
|
|
153
|
+
id: number;
|
|
154
|
+
input?: PaymentMethodInputDto;
|
|
155
|
+
}
|
|
156
|
+
export interface PaymentStatusDto {
|
|
157
|
+
code: number;
|
|
158
|
+
action: string;
|
|
159
|
+
}
|
|
160
|
+
export interface SessionPaymentInfo {
|
|
161
|
+
id: string;
|
|
162
|
+
paymentMethod: number;
|
|
163
|
+
paymentMethodName?: string;
|
|
164
|
+
paymentMethodImage?: string;
|
|
165
|
+
amount: AmountDto;
|
|
166
|
+
capturedAmount: AmountDto;
|
|
167
|
+
authorizedAmount: AmountDto;
|
|
168
|
+
status: string;
|
|
169
|
+
last4?: string;
|
|
170
|
+
}
|
|
171
|
+
export interface PaymentInfo {
|
|
172
|
+
id: string;
|
|
173
|
+
paymentMethod: number;
|
|
174
|
+
paymentMethodName?: string;
|
|
175
|
+
paymentMethodImage?: string;
|
|
176
|
+
amount: AmountDto;
|
|
177
|
+
capturedAmount: AmountDto;
|
|
178
|
+
authorizedAmount: AmountDto;
|
|
179
|
+
status: string;
|
|
180
|
+
}
|
|
181
|
+
export interface CheckoutConfig {
|
|
182
|
+
sessionToken?: string;
|
|
183
|
+
sessionId?: string;
|
|
184
|
+
apiUrl: string;
|
|
185
|
+
language?: string;
|
|
186
|
+
/**
|
|
187
|
+
* Country for payment method sequencing.
|
|
188
|
+
* Independent from language - controls which checkoutSequence to use (NL, BE, or default).
|
|
189
|
+
* Use 'NL' for Nederland, 'BE' for België, or 'DEFAULT' for default sequence.
|
|
190
|
+
*/
|
|
191
|
+
country?: 'DEFAULT' | 'NL' | 'BE';
|
|
192
|
+
/**
|
|
193
|
+
* Custom translations to override or extend default translations.
|
|
194
|
+
* Object with translation keys and values.
|
|
195
|
+
*/
|
|
196
|
+
translations?: Record<string, unknown>;
|
|
197
|
+
amount?: number;
|
|
198
|
+
currency?: string;
|
|
199
|
+
merchantName?: string;
|
|
200
|
+
checkoutOptions?: CheckoutOption[];
|
|
201
|
+
checkoutSequence?: CheckoutSequence;
|
|
202
|
+
creditCard?: {
|
|
203
|
+
brands: string[];
|
|
204
|
+
assets?: {
|
|
205
|
+
brandIcons: Record<string, string>;
|
|
206
|
+
};
|
|
207
|
+
};
|
|
208
|
+
customer?: CustomerInfo;
|
|
209
|
+
order?: OrderInfo;
|
|
210
|
+
payments?: SessionPaymentInfo[];
|
|
211
|
+
capturedAmount?: AmountDto;
|
|
212
|
+
authorizedAmount?: AmountDto;
|
|
213
|
+
outstandingAmount?: AmountDto;
|
|
214
|
+
isFullyPaid?: boolean;
|
|
215
|
+
applePayOptions?: ApplePayOptions;
|
|
216
|
+
paypalOptions?: PayPalOptions;
|
|
217
|
+
/**
|
|
218
|
+
* Link mode for payment methods - controls how the payment URL is opened.
|
|
219
|
+
* 'same_page' (default) - navigate to the payment URL in the same tab
|
|
220
|
+
* 'new_tab' - open the payment URL in a new tab
|
|
221
|
+
*/
|
|
222
|
+
methodLinkMode?: 'new_tab' | 'same_page';
|
|
223
|
+
debugMode?: boolean;
|
|
224
|
+
/**
|
|
225
|
+
* Payment method tags to exclude from display (e.g., ['PM_10', 'PM_11']).
|
|
226
|
+
* These methods will not be shown in the payment methods list.
|
|
227
|
+
*/
|
|
228
|
+
excludedMethods?: string[];
|
|
229
|
+
}
|
|
230
|
+
export interface PaymentInfo {
|
|
231
|
+
method: 'creditcard' | 'paypal' | 'ideal' | 'bancontact' | 'sepa';
|
|
232
|
+
details?: Record<string, unknown>;
|
|
233
|
+
}
|
|
234
|
+
export type CheckoutState = 'NOT_READY' | 'INITIALIZING' | 'READY';
|
|
235
|
+
export interface InitialisingEventData {
|
|
236
|
+
state: CheckoutState;
|
|
237
|
+
}
|
|
238
|
+
export interface ReadyEventData {
|
|
239
|
+
state: CheckoutState;
|
|
240
|
+
config: Readonly<Required<CheckoutConfig>>;
|
|
241
|
+
}
|
|
242
|
+
export interface StateChangeEventData {
|
|
243
|
+
previousState: CheckoutState;
|
|
244
|
+
currentState: CheckoutState;
|
|
245
|
+
}
|
|
246
|
+
export interface PaymentSubmitEventData {
|
|
247
|
+
method: string;
|
|
248
|
+
details?: Record<string, unknown>;
|
|
249
|
+
}
|
|
250
|
+
export interface PaymentErrorEventData {
|
|
251
|
+
error: string;
|
|
252
|
+
errorId?: string;
|
|
253
|
+
result?: string;
|
|
254
|
+
}
|
|
255
|
+
export interface PaymentSuccessEventData {
|
|
256
|
+
orderId?: string;
|
|
257
|
+
returnUrl?: string;
|
|
258
|
+
threeDs?: ThreeDsData;
|
|
259
|
+
transaction?: TransactionData;
|
|
260
|
+
}
|
|
261
|
+
export interface PartialPaymentEventData {
|
|
262
|
+
orderId: string;
|
|
263
|
+
amountPaid: number;
|
|
264
|
+
amountRemaining: number;
|
|
265
|
+
currency: string;
|
|
266
|
+
transactionId?: string;
|
|
267
|
+
}
|
|
268
|
+
export interface ThreeDsData {
|
|
269
|
+
nextAction?: string;
|
|
270
|
+
challengeType?: string;
|
|
271
|
+
challengeForm?: string;
|
|
272
|
+
challengeFullScreen?: string;
|
|
273
|
+
challengeWindowWidth?: string;
|
|
274
|
+
challengeWindowHeight?: string;
|
|
275
|
+
tdsApiURLStatus?: string;
|
|
276
|
+
tdsMode?: string;
|
|
277
|
+
acquirerID?: string;
|
|
278
|
+
transactionID?: string;
|
|
279
|
+
transactionStatusCode?: string;
|
|
280
|
+
checkStatusInterval?: string;
|
|
281
|
+
challengeValidUntil?: string;
|
|
282
|
+
threeDSMethodURL?: string;
|
|
283
|
+
threeDSMethodData?: string;
|
|
284
|
+
}
|
|
285
|
+
export interface TransactionData {
|
|
286
|
+
transactionId?: string;
|
|
287
|
+
orderId?: string;
|
|
288
|
+
paymentProfileId?: string;
|
|
289
|
+
state?: string;
|
|
290
|
+
stateName?: string;
|
|
291
|
+
amount?: {
|
|
292
|
+
value: number;
|
|
293
|
+
currency: string;
|
|
294
|
+
};
|
|
295
|
+
created?: number;
|
|
296
|
+
identifierName?: string;
|
|
297
|
+
identifierPublic?: string;
|
|
298
|
+
identifierHash?: string;
|
|
299
|
+
startIpAddress?: string;
|
|
300
|
+
completedIpAddress?: string;
|
|
301
|
+
orderNumber?: string;
|
|
302
|
+
amountOriginal?: {
|
|
303
|
+
value: number;
|
|
304
|
+
currency: string;
|
|
305
|
+
};
|
|
306
|
+
amountPaidOriginal?: {
|
|
307
|
+
value: number;
|
|
308
|
+
currency: string;
|
|
309
|
+
};
|
|
310
|
+
amountPaid?: {
|
|
311
|
+
value: number;
|
|
312
|
+
currency: string;
|
|
313
|
+
};
|
|
314
|
+
amountRefundOriginal?: {
|
|
315
|
+
value: number;
|
|
316
|
+
currency: string;
|
|
317
|
+
};
|
|
318
|
+
amountRefund?: {
|
|
319
|
+
value: number;
|
|
320
|
+
currency: string;
|
|
321
|
+
};
|
|
322
|
+
entranceCode?: string;
|
|
323
|
+
}
|
|
324
|
+
export type CheckoutEventType = 'initialising' | 'ready' | 'state:change' | 'payment:submit' | 'payment:success' | 'payment:error' | 'cancel' | 'close' | 'infoUpdated' | 'shippingUpdated';
|
|
325
|
+
export interface MountOptions {
|
|
326
|
+
target: string | HTMLElement;
|
|
327
|
+
config: CheckoutConfig;
|
|
328
|
+
events?: MountEventHandlers;
|
|
329
|
+
}
|
|
330
|
+
export interface MountEventHandlers {
|
|
331
|
+
onStateChange?: (state: CheckoutState) => void;
|
|
332
|
+
onReady?: (data: ReadyEventData) => void;
|
|
333
|
+
onPaymentSubmit?: (data: PaymentSubmitEventData) => void;
|
|
334
|
+
onPaymentSuccess?: (data: PaymentSuccessEventData) => void;
|
|
335
|
+
onPaymentError?: (data: PaymentErrorEventData) => void;
|
|
336
|
+
onCancel?: () => void;
|
|
337
|
+
onClose?: () => void;
|
|
338
|
+
onSubmit?: (event: PaymentSubmitEvent) => void;
|
|
339
|
+
onSuccess?: (event: PaymentSuccessEvent) => void;
|
|
340
|
+
onError?: (event: PaymentErrorEvent) => void;
|
|
341
|
+
onPartialPaid?: (event: PartialPaymentEvent) => void;
|
|
342
|
+
onInfoUpdated?: (event: InfoUpdatedEvent) => void;
|
|
343
|
+
onShippingUpdated?: (event: ShippingUpdatedEvent) => void;
|
|
344
|
+
}
|
|
345
|
+
export interface MountResult {
|
|
346
|
+
unmount: () => void;
|
|
347
|
+
updateConfig: (config: Partial<CheckoutConfig>) => void;
|
|
348
|
+
getLocationInfo: () => LocationInfo | null;
|
|
349
|
+
getCheckoutSequence: () => CheckoutSequence | null;
|
|
350
|
+
getConfig: () => Readonly<Required<CheckoutConfig>>;
|
|
351
|
+
getState: () => CheckoutState;
|
|
352
|
+
isReady: () => boolean;
|
|
353
|
+
}
|
|
354
|
+
export interface PaymentSubmitEvent {
|
|
355
|
+
method: string;
|
|
356
|
+
details?: Record<string, unknown>;
|
|
357
|
+
resolve: (data?: unknown) => void;
|
|
358
|
+
reject: (error: Error) => void;
|
|
359
|
+
}
|
|
360
|
+
export interface PaymentStatusInfo {
|
|
361
|
+
code: number;
|
|
362
|
+
action: string;
|
|
363
|
+
outcome: 'success' | 'failure' | 'pending' | 'unknown';
|
|
364
|
+
}
|
|
365
|
+
export interface PaymentSuccessEvent {
|
|
366
|
+
orderId: string;
|
|
367
|
+
returnUrl: string;
|
|
368
|
+
paymentStatus?: PaymentStatusInfo;
|
|
369
|
+
resolve: () => void;
|
|
370
|
+
reject: (error: Error) => void;
|
|
371
|
+
}
|
|
372
|
+
export interface FieldError {
|
|
373
|
+
field: string;
|
|
374
|
+
message: string;
|
|
375
|
+
}
|
|
376
|
+
export interface PaymentErrorEvent {
|
|
377
|
+
error: string;
|
|
378
|
+
errorId?: string;
|
|
379
|
+
errorTag?: string;
|
|
380
|
+
result?: string;
|
|
381
|
+
paymentStatus?: PaymentStatusInfo;
|
|
382
|
+
errors?: FieldError[];
|
|
383
|
+
resolve: () => void;
|
|
384
|
+
reject: (error: Error) => void;
|
|
385
|
+
}
|
|
386
|
+
export interface PartialPaymentEvent {
|
|
387
|
+
orderId: string;
|
|
388
|
+
amountPaid: number;
|
|
389
|
+
amountRemaining: number;
|
|
390
|
+
currency: string;
|
|
391
|
+
transactionId?: string;
|
|
392
|
+
paymentStatus?: PaymentStatusInfo;
|
|
393
|
+
resolve: () => void;
|
|
394
|
+
reject: (error: Error) => void;
|
|
395
|
+
}
|
|
396
|
+
export interface CheckoutReadyEvent {
|
|
397
|
+
config: Readonly<Required<CheckoutConfig>>;
|
|
398
|
+
}
|
|
399
|
+
export interface CheckoutEventHandlers {
|
|
400
|
+
onSubmit?: (event: PaymentSubmitEvent) => void;
|
|
401
|
+
onSuccess?: (event: PaymentSuccessEvent) => void;
|
|
402
|
+
onError?: (event: PaymentErrorEvent) => void;
|
|
403
|
+
onPartialPaid?: (event: PartialPaymentEvent) => void;
|
|
404
|
+
onReady?: (event: CheckoutReadyEvent) => void;
|
|
405
|
+
}
|
|
406
|
+
export interface PaymentComponent {
|
|
407
|
+
bind: (target: string | HTMLElement) => void;
|
|
408
|
+
unmount: () => void;
|
|
409
|
+
updateContext: (context: Partial<PaymentMethodContext>) => void;
|
|
410
|
+
isReady: () => boolean;
|
|
411
|
+
refresh: () => Promise<void>;
|
|
412
|
+
}
|
|
413
|
+
export interface Checkout {
|
|
414
|
+
events: MountEventHandlers;
|
|
415
|
+
prepare: (methodOrSection: string) => PaymentComponent;
|
|
416
|
+
updateConfig: (config: Partial<CheckoutConfig>) => void;
|
|
417
|
+
getConfig: () => Readonly<Required<CheckoutConfig>>;
|
|
418
|
+
}
|
|
419
|
+
export interface ApplePayShippingMethod {
|
|
420
|
+
label: string;
|
|
421
|
+
amount: string;
|
|
422
|
+
detail: string;
|
|
423
|
+
identifier: string;
|
|
424
|
+
dateComponentsRange?: {
|
|
425
|
+
startDateComponents?: ApplePayDateComponents;
|
|
426
|
+
endDateComponents?: ApplePayDateComponents;
|
|
427
|
+
};
|
|
428
|
+
}
|
|
429
|
+
export interface ApplePayDateComponents {
|
|
430
|
+
years?: number;
|
|
431
|
+
months?: number;
|
|
432
|
+
days?: number;
|
|
433
|
+
hours?: number;
|
|
434
|
+
minutes?: number;
|
|
435
|
+
seconds?: number;
|
|
436
|
+
}
|
|
437
|
+
export interface ApplePayLineItem {
|
|
438
|
+
label: string;
|
|
439
|
+
amount: string;
|
|
440
|
+
}
|
|
441
|
+
export interface ApplePayShippingContact {
|
|
442
|
+
administrativeArea?: string;
|
|
443
|
+
country?: string;
|
|
444
|
+
countryCode?: string;
|
|
445
|
+
familyName?: string;
|
|
446
|
+
givenName?: string;
|
|
447
|
+
locality?: string;
|
|
448
|
+
postalCode?: string;
|
|
449
|
+
subAdministrativeArea?: string;
|
|
450
|
+
subLocality?: string;
|
|
451
|
+
emailAddress?: string;
|
|
452
|
+
phoneNumber?: string;
|
|
453
|
+
addressLines?: string[];
|
|
454
|
+
}
|
|
455
|
+
export interface ApplePayPaymentMethod {
|
|
456
|
+
displayName: string;
|
|
457
|
+
network: string;
|
|
458
|
+
type: string;
|
|
459
|
+
}
|
|
460
|
+
export interface ApplePayPaymentMethodUpdate {
|
|
461
|
+
newTotal: {
|
|
462
|
+
label: string;
|
|
463
|
+
amount: string;
|
|
464
|
+
};
|
|
465
|
+
newLineItems?: ApplePayLineItem[];
|
|
466
|
+
}
|
|
467
|
+
export interface ApplePayShippingMethodUpdate {
|
|
468
|
+
newTotal: {
|
|
469
|
+
label: string;
|
|
470
|
+
amount: string;
|
|
471
|
+
};
|
|
472
|
+
newLineItems?: ApplePayLineItem[];
|
|
473
|
+
}
|
|
474
|
+
export interface ApplePayShippingContactUpdate {
|
|
475
|
+
newTotal?: {
|
|
476
|
+
label: string;
|
|
477
|
+
amount: string;
|
|
478
|
+
};
|
|
479
|
+
newLineItems?: ApplePayLineItem[];
|
|
480
|
+
errors?: {
|
|
481
|
+
code: string;
|
|
482
|
+
message: string;
|
|
483
|
+
}[];
|
|
484
|
+
}
|
|
485
|
+
export interface ApplePayOptions {
|
|
486
|
+
shippingMethods?: ApplePayShippingMethod[];
|
|
487
|
+
requiredBillingContactFields?: string[];
|
|
488
|
+
requiredShippingContactFields?: string[];
|
|
489
|
+
lineItems?: ApplePayLineItem[];
|
|
490
|
+
total?: {
|
|
491
|
+
label: string;
|
|
492
|
+
type?: 'final' | 'pending';
|
|
493
|
+
};
|
|
494
|
+
shippingType?: 'shipping' | 'delivery' | 'store' | 'service';
|
|
495
|
+
onShippingMethodSelected?: (method: ApplePayShippingMethod) => ApplePayShippingMethodUpdate;
|
|
496
|
+
onShippingContactSelected?: (contact: ApplePayShippingContact) => ApplePayShippingContactUpdate;
|
|
497
|
+
onPaymentMethodSelected?: (method: ApplePayPaymentMethod) => ApplePayPaymentMethodUpdate;
|
|
498
|
+
}
|
|
499
|
+
export interface PayPalOptions {
|
|
500
|
+
clientId?: string;
|
|
501
|
+
/**
|
|
502
|
+
* PayPal button style options
|
|
503
|
+
*/
|
|
504
|
+
buttonStyle?: {
|
|
505
|
+
color?: 'gold' | 'blue' | 'white' | 'black';
|
|
506
|
+
shape?: 'rect' | 'pill';
|
|
507
|
+
size?: 'small' | 'medium' | 'large';
|
|
508
|
+
layout?: 'vertical' | 'horizontal';
|
|
509
|
+
};
|
|
510
|
+
/**
|
|
511
|
+
* Custom callback when PayPal button is clicked
|
|
512
|
+
*/
|
|
513
|
+
onButtonClick?: () => void;
|
|
514
|
+
}
|
|
515
|
+
export interface CustomerInfo {
|
|
516
|
+
email?: string;
|
|
517
|
+
firstName?: string;
|
|
518
|
+
lastName?: string;
|
|
519
|
+
phone?: string;
|
|
520
|
+
billingAddress?: AddressInfo;
|
|
521
|
+
shippingAddress?: AddressInfo;
|
|
522
|
+
}
|
|
523
|
+
export interface OrderProduct {
|
|
524
|
+
id?: string;
|
|
525
|
+
name?: string;
|
|
526
|
+
description?: string;
|
|
527
|
+
quantity?: number;
|
|
528
|
+
unitPrice?: number;
|
|
529
|
+
totalAmount?: number;
|
|
530
|
+
}
|
|
531
|
+
export interface OrderInfo {
|
|
532
|
+
amount?: number;
|
|
533
|
+
currency?: string;
|
|
534
|
+
orderId?: string;
|
|
535
|
+
reference?: string;
|
|
536
|
+
description?: string;
|
|
537
|
+
products?: OrderProduct[];
|
|
538
|
+
}
|
|
539
|
+
export interface AddressInfo {
|
|
540
|
+
street?: string;
|
|
541
|
+
streetNumber?: string;
|
|
542
|
+
streetNumberExtension?: string;
|
|
543
|
+
city?: string;
|
|
544
|
+
country?: string;
|
|
545
|
+
countryCode?: string;
|
|
546
|
+
zipCode?: string;
|
|
547
|
+
administrativeArea?: string;
|
|
548
|
+
}
|
|
549
|
+
export interface InfoUpdatedEvent {
|
|
550
|
+
type: 'infoUpdated';
|
|
551
|
+
data: {
|
|
552
|
+
lineItems?: ApplePayLineItem[];
|
|
553
|
+
total?: {
|
|
554
|
+
label: string;
|
|
555
|
+
amount: string;
|
|
556
|
+
};
|
|
557
|
+
customer?: CustomerInfo;
|
|
558
|
+
};
|
|
559
|
+
}
|
|
560
|
+
export interface ShippingUpdatedEvent {
|
|
561
|
+
type: 'shippingUpdated';
|
|
562
|
+
data: {
|
|
563
|
+
selectedMethod?: string;
|
|
564
|
+
shippingCost?: number;
|
|
565
|
+
deliveryAddress?: AddressInfo;
|
|
566
|
+
};
|
|
567
|
+
}
|
|
568
|
+
export type CheckoutEvent = {
|
|
569
|
+
type: 'initialising';
|
|
570
|
+
data: InitialisingEventData;
|
|
571
|
+
timestamp: Date;
|
|
572
|
+
} | {
|
|
573
|
+
type: 'ready';
|
|
574
|
+
data: ReadyEventData;
|
|
575
|
+
timestamp: Date;
|
|
576
|
+
} | {
|
|
577
|
+
type: 'state:change';
|
|
578
|
+
data: StateChangeEventData;
|
|
579
|
+
timestamp: Date;
|
|
580
|
+
} | {
|
|
581
|
+
type: 'payment:submit';
|
|
582
|
+
data: PaymentSubmitEventData;
|
|
583
|
+
timestamp: Date;
|
|
584
|
+
} | {
|
|
585
|
+
type: 'payment:success';
|
|
586
|
+
data: PaymentSuccessEventData;
|
|
587
|
+
timestamp: Date;
|
|
588
|
+
} | {
|
|
589
|
+
type: 'payment:error';
|
|
590
|
+
data: PaymentErrorEventData;
|
|
591
|
+
timestamp: Date;
|
|
592
|
+
} | {
|
|
593
|
+
type: 'cancel';
|
|
594
|
+
data: null;
|
|
595
|
+
timestamp: Date;
|
|
596
|
+
} | {
|
|
597
|
+
type: 'close';
|
|
598
|
+
data: null;
|
|
599
|
+
timestamp: Date;
|
|
600
|
+
} | {
|
|
601
|
+
type: 'infoUpdated';
|
|
602
|
+
data: InfoUpdatedEvent['data'];
|
|
603
|
+
timestamp: Date;
|
|
604
|
+
} | {
|
|
605
|
+
type: 'shippingUpdated';
|
|
606
|
+
data: ShippingUpdatedEvent['data'];
|
|
607
|
+
timestamp: Date;
|
|
608
|
+
};
|
|
609
|
+
export interface CheckoutEventHandlers {
|
|
610
|
+
onSubmit?: (event: PaymentSubmitEvent) => void;
|
|
611
|
+
onSuccess?: (event: PaymentSuccessEvent) => void;
|
|
612
|
+
onError?: (event: PaymentErrorEvent) => void;
|
|
613
|
+
onReady?: (event: CheckoutReadyEvent) => void;
|
|
614
|
+
onInfoUpdated?: (event: InfoUpdatedEvent) => void;
|
|
615
|
+
onShippingUpdated?: (event: ShippingUpdatedEvent) => void;
|
|
616
|
+
}
|
|
617
|
+
export interface InitOptions {
|
|
618
|
+
sessionToken: string;
|
|
619
|
+
apiUrl?: string;
|
|
620
|
+
language?: string;
|
|
621
|
+
/**
|
|
622
|
+
* Country for payment method sequencing.
|
|
623
|
+
* Independent from language - controls which checkoutSequence to use (NL, BE, or default).
|
|
624
|
+
*/
|
|
625
|
+
country?: 'DEFAULT' | 'NL' | 'BE';
|
|
626
|
+
/**
|
|
627
|
+
* Payment method tags to exclude from display (e.g., ['PM_10', 'PM_11']).
|
|
628
|
+
* These methods will not be shown in the payment methods list.
|
|
629
|
+
*/
|
|
630
|
+
excludedMethods?: string[];
|
|
631
|
+
/**
|
|
632
|
+
* Apple Pay configuration options.
|
|
633
|
+
*/
|
|
634
|
+
applePayOptions?: ApplePayOptions;
|
|
635
|
+
/**
|
|
636
|
+
* PayPal configuration options.
|
|
637
|
+
*/
|
|
638
|
+
paypalOptions?: PayPalOptions;
|
|
639
|
+
/**
|
|
640
|
+
* Link mode for payment methods - controls how the payment URL is opened.
|
|
641
|
+
* 'same_page' (default) - navigate to the payment URL in the same tab
|
|
642
|
+
* 'new_tab' - open the payment URL in a new tab
|
|
643
|
+
*/
|
|
644
|
+
methodLinkMode?: 'new_tab' | 'same_page';
|
|
645
|
+
/**
|
|
646
|
+
* Debug mode - shows disabled/hidden payment methods with min/max amounts.
|
|
647
|
+
*/
|
|
648
|
+
debugMode?: boolean;
|
|
649
|
+
/**
|
|
650
|
+
* Custom translations to override or extend default translations.
|
|
651
|
+
*/
|
|
652
|
+
translations?: Record<string, unknown>;
|
|
653
|
+
}
|
|
654
|
+
/** @deprecated Use ApplePayOptions instead */
|
|
655
|
+
export type ApplePayConfig = ApplePayOptions;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export type { CheckoutConfig, CheckoutOption, PaymentMethod, PaymentMethodOption, CountrySequence, CheckoutSequence, PaymentInfo, SessionPaymentInfo, OrderPaymentInfo, CheckoutState, CheckoutEventType, CheckoutEvent, InitialisingEventData, ReadyEventData, StateChangeEventData, PaymentSubmitEventData, PaymentErrorEventData, PaymentSuccessEventData, PartialPaymentEventData, ThreeDsData, TransactionData, MountOptions, MountEventHandlers, MountResult, Checkout, PaymentComponent, CheckoutEventHandlers, PaymentMethodContext, PaymentSubmitEvent, PaymentSuccessEvent, PaymentErrorEvent, FieldError, CheckoutReadyEvent, InitOptions, ShippingUpdatedEvent, InfoUpdatedEvent, PartialPaymentEvent, ApplePayOptions, ApplePayShippingMethod, ApplePayLineItem, ApplePayShippingContact, PayPalOptions, CustomerInfo, AddressInfo, OrderInfo, OrderProduct, AmountDto, MerchantInfo, LocationInfo, } from '../../src/core/types';
|
|
2
|
+
export type { PaymentOutcome, PaymentStatusInfo } from '../../src/core/payment-status';
|
|
3
|
+
export type { ApiErrorResponse, ApiFieldError } from '../../src/core/errors/api-error-response';
|
|
4
|
+
export type { PaymentError } from '../../src/core/errors/PaymentError';
|
package/package.json
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@paynl/payparts-types",
|
|
3
|
+
"version": "1.4.0-alpha.93",
|
|
4
|
+
"description": "TypeScript type definitions for the PayParts payment SDK",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"types": "./dist/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./dist/index.d.ts"
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
"files": [
|
|
13
|
+
"dist"
|
|
14
|
+
],
|
|
15
|
+
"scripts": {
|
|
16
|
+
"build": "../node_modules/.bin/tsc",
|
|
17
|
+
"postbuild": "node -e \"require('fs').writeFileSync('./dist/index.d.ts', \\\"export * from './types-pkg/src/index';\\\\n\\\")\"",
|
|
18
|
+
"typecheck": "../node_modules/.bin/tsc --noEmit"
|
|
19
|
+
},
|
|
20
|
+
"publishConfig": {
|
|
21
|
+
"registry": "https://registry.npmjs.org",
|
|
22
|
+
"access": "public"
|
|
23
|
+
}
|
|
24
|
+
}
|