-
Notifications
You must be signed in to change notification settings - Fork 0
/
types.ts
130 lines (115 loc) · 2.6 KB
/
types.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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
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 // maxlength = 20
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 // maxlength = 30
}>
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