-
Notifications
You must be signed in to change notification settings - Fork 0
/
types.d.ts
108 lines (108 loc) · 2.8 KB
/
types.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
import type { config as MSSQLConfig } from 'mssql';
export interface MiniShopConfig {
mssqlConfig: MSSQLConfig;
orderNumberFunction: () => string;
products: Record<string, Product>;
fees: Record<string, Fee>;
}
export interface ShippingForm {
fullName: string;
address: string;
address2: string;
city: string;
province: string;
country: string;
postalCode: string;
phoneNumberDay: string;
phoneNumberEvening: string;
emailAddress: string;
redirectURL: string;
cartItems: CartItem[];
}
export interface CartItem {
productSKU: string;
quantity: string;
unitPrice: string;
[formFieldName: string]: string;
}
export interface Order {
orderID: number;
orderNumber: string;
orderSecret?: string;
orderTime: Date;
shippingName: string;
shippingAddress1: string;
shippingAddress2?: string;
shippingCity: string;
shippingProvince: string;
shippingCountry: string;
shippingPostalCode: string;
shippingPhoneNumberDay: string;
shippingPhoneNumberEvening?: string;
shippingEmailAddress: string;
paymentID?: string;
paymentTime?: Date;
orderIsPaid: boolean;
refundID?: string;
refundTime?: Date;
refundUser?: string;
refundReason?: string;
orderIsRefunded: boolean;
redirectURL?: string;
items?: OrderItem[];
fees?: Array<{
feeName: string;
feeTotal: number;
}>;
paymentData?: Array<{
dataName: string;
dataValue: string;
}>;
}
export interface OrderItem {
orderID?: number;
itemIndex: number;
productSKU: string;
unitPrice: number;
quantity: number;
itemTotal: number;
fields?: OrderItemField[];
acknowledgedTime?: Date;
acknowledgedUser?: string;
itemIsAcknowledged: boolean;
}
export interface OrderItemField {
itemIndex?: number;
formFieldName: string;
fieldValue: string;
}
export interface Product {
productSKU?: string;
productName?: string;
price: number | 'form';
formFieldsToSave?: Array<{
fieldName?: string;
formFieldName: string;
}>;
fees?: string[];
feeTotals?: Record<string, number>;
}
export interface Fee {
feeSKU?: string;
feeName: string;
feeCalculation: (product: Product) => number;
}
export type StoreValidatorErrorMessage = 'noHandler' | 'noResult' | 'missingOrderNumber' | 'invalidOrderNumber' | 'missingOrderSecret' | 'paymentDeclined';
export interface StoreValidatorValidReturn {
isValid: true;
orderNumber: string;
orderSecret: string;
paymentID: string;
paymentData?: Record<string, string>;
}
interface StoreValidatorInvalidReturn {
isValid: false;
errorCode: StoreValidatorErrorMessage;
}
export type StoreValidatorReturn = StoreValidatorValidReturn | StoreValidatorInvalidReturn;
export {};