@nicefer/types 1.0.217 → 1.0.218
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/api.js +1 -0
- package/dist/api.js.map +1 -0
- package/dist/bag.js +1 -0
- package/dist/bag.js.map +1 -0
- package/dist/branch.js +1 -0
- package/dist/branch.js.map +1 -0
- package/dist/company.js +1 -0
- package/dist/company.js.map +1 -0
- package/dist/countries.js +5 -4
- package/dist/countries.js.map +1 -0
- package/dist/index.d.ts +0 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -0
- package/dist/orders.js +1 -0
- package/dist/orders.js.map +1 -0
- package/dist/org/event.js +1 -0
- package/dist/org/event.js.map +1 -0
- package/dist/org/index.d.ts +1 -1
- package/dist/org/index.js +1 -1
- package/dist/org/index.js.map +1 -0
- package/dist/org/radar.js +1 -0
- package/dist/org/radar.js.map +1 -0
- package/dist/payments.js +1 -0
- package/dist/payments.js.map +1 -0
- package/dist/product-category.js +1 -0
- package/dist/product-category.js.map +1 -0
- package/dist/products.js +1 -0
- package/dist/products.js.map +1 -0
- package/dist/replenishment.js +1 -0
- package/dist/replenishment.js.map +1 -0
- package/dist/stats.js +1 -0
- package/dist/stats.js.map +1 -0
- package/dist/translations.js +1 -0
- package/dist/translations.js.map +1 -0
- package/dist/users.js +1 -0
- package/dist/users.js.map +1 -0
- package/dist/warehouses.js +1 -0
- package/dist/warehouses.js.map +1 -0
- package/package.json +1 -14
- package/src/api.ts +12 -0
- package/src/bag.ts +45 -0
- package/src/branch.ts +22 -0
- package/src/company.ts +11 -0
- package/src/countries.ts +227 -0
- package/src/index.ts +19 -0
- package/src/orders.ts +112 -0
- package/src/org/event.ts +17 -0
- package/src/org/index.ts +2 -0
- package/src/org/radar.ts +86 -0
- package/src/payments.ts +79 -0
- package/src/product-category.ts +34 -0
- package/src/products.ts +129 -0
- package/src/replenishment.ts +114 -0
- package/src/stats.ts +18 -0
- package/src/translations.ts +3 -0
- package/src/users.ts +85 -0
- package/src/warehouses.ts +53 -0
- package/tsconfig.json +40 -0
- package/tsconfig.json.old +16 -0
package/src/countries.ts
ADDED
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
import { PaymentInDB } from "./payments";
|
|
2
|
+
|
|
3
|
+
export interface Country {
|
|
4
|
+
id: 'HN' | 'US' | 'SV' | 'CN';
|
|
5
|
+
name: string;
|
|
6
|
+
ccy: PaymentInDB['ccy'];
|
|
7
|
+
code: number | null | undefined;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface City {
|
|
11
|
+
id: string;
|
|
12
|
+
name: string;
|
|
13
|
+
regionId: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface Region {
|
|
17
|
+
id: string;
|
|
18
|
+
name: string;
|
|
19
|
+
cities?: City[];
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export const Countries: Country[] = [
|
|
23
|
+
{
|
|
24
|
+
id: 'HN',
|
|
25
|
+
name: 'Honduras',
|
|
26
|
+
code: 504,
|
|
27
|
+
ccy: 'HNL'
|
|
28
|
+
},
|
|
29
|
+
|
|
30
|
+
{
|
|
31
|
+
id: 'SV',
|
|
32
|
+
name: 'El Salvador',
|
|
33
|
+
code: 503,
|
|
34
|
+
ccy: 'USD'
|
|
35
|
+
},
|
|
36
|
+
|
|
37
|
+
{
|
|
38
|
+
id: 'US',
|
|
39
|
+
name: 'Estados Unidos',
|
|
40
|
+
code: 1,
|
|
41
|
+
ccy: 'USD',
|
|
42
|
+
},
|
|
43
|
+
|
|
44
|
+
{
|
|
45
|
+
id: 'CN',
|
|
46
|
+
name: 'China',
|
|
47
|
+
code: 56,
|
|
48
|
+
ccy: 'USD'
|
|
49
|
+
},
|
|
50
|
+
];
|
|
51
|
+
|
|
52
|
+
export const Regions: {[countryId in Country['id']]: Region[]} = {
|
|
53
|
+
HN: [
|
|
54
|
+
{
|
|
55
|
+
id: "AT",
|
|
56
|
+
name: "Atlántida",
|
|
57
|
+
cities: [
|
|
58
|
+
{ id: "LCB", name: "La Ceiba", regionId: "AT" },
|
|
59
|
+
{ id: "ELP", name: "El Porvenir", regionId: "AT" },
|
|
60
|
+
{ id: "ESP", name: "Esparta", regionId: "AT" },
|
|
61
|
+
{ id: "JUT", name: "Jutiapa", regionId: "AT" },
|
|
62
|
+
{ id: "LAM", name: "La Masica", regionId: "AT" },
|
|
63
|
+
{ id: "SFR", name: "San Francisco", regionId: "AT" },
|
|
64
|
+
{ id: "TEL", name: "Tela", regionId: "AT" },
|
|
65
|
+
{ id: "ARI", name: "Arizona", regionId: "AT" }
|
|
66
|
+
]
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
id: "CH",
|
|
70
|
+
name: "Choluteca",
|
|
71
|
+
cities: [
|
|
72
|
+
|
|
73
|
+
]
|
|
74
|
+
},
|
|
75
|
+
{ id: "CL", name: "Colón" },
|
|
76
|
+
{ id: "CM", name: "Comayagua" },
|
|
77
|
+
{ id: "CP", name: "Copán" },
|
|
78
|
+
{ id: "CR", name: "Cortés" },
|
|
79
|
+
{ id: "EP", name: "El Paraíso" },
|
|
80
|
+
{
|
|
81
|
+
id: "FM",
|
|
82
|
+
name: "Francisco Morazán",
|
|
83
|
+
cities: [
|
|
84
|
+
{ id: "TGU", name: "Tegucigalpa", regionId: "FM" },
|
|
85
|
+
{ id: "AMA", name: "Amarateca", regionId: "FM" },
|
|
86
|
+
{ id: "AZA", name: "Azacualpa", regionId: "FM" },
|
|
87
|
+
{ id: "CAR", name: "Carpinteron", regionId: "FM" },
|
|
88
|
+
{ id: "CEN", name: "Cerro Grande", regionId: "FM" },
|
|
89
|
+
{ id: "COA", name: "Coa Abajo", regionId: "FM" },
|
|
90
|
+
{ id: "COU", name: "Coa Arriba", regionId: "FM" }, // id corregido
|
|
91
|
+
{ id: "COF", name: "Cofradía", regionId: "FM" },
|
|
92
|
+
{ id: "CON", name: "Concepción de Río Grande", regionId: "FM" },
|
|
93
|
+
{ id: "ELN", name: "El Naranjal", regionId: "FM" },
|
|
94
|
+
{ id: "EPI", name: "El Piliguín", regionId: "FM" },
|
|
95
|
+
{ id: "TIZ", name: "El Tizatillo", regionId: "FM" },
|
|
96
|
+
{ id: "GER", name: "Germania", regionId: "FM" },
|
|
97
|
+
{ id: "GUA", name: "Guangololo", regionId: "FM" },
|
|
98
|
+
{ id: "GUS", name: "Guasculile", regionId: "FM" },
|
|
99
|
+
{ id: "JAC", name: "Jacaleapa", regionId: "FM" },
|
|
100
|
+
{ id: "JUT", name: "Jutiapa", regionId: "FM" },
|
|
101
|
+
{ id: "CAL", name: "La Calera", regionId: "FM" },
|
|
102
|
+
{ id: "CU2", name: "La Cuesta No.2", regionId: "FM" },
|
|
103
|
+
{ id: "MON", name: "La Montañita", regionId: "FM" },
|
|
104
|
+
{ id: "SAB", name: "La Sábana", regionId: "FM" },
|
|
105
|
+
{ id: "VEN", name: "La Venta", regionId: "FM" },
|
|
106
|
+
{ id: "CAS", name: "Las Casitas", regionId: "FM" },
|
|
107
|
+
{ id: "FLO", name: "Las Flores", regionId: "FM" },
|
|
108
|
+
{ id: "TAP", name: "Las Tapias", regionId: "FM" },
|
|
109
|
+
{ id: "JUT2", name: "Los Jutes", regionId: "FM" },
|
|
110
|
+
{ id: "MAT", name: "Mateo", regionId: "FM" },
|
|
111
|
+
{ id: "RED", name: "Monte Redondo", regionId: "FM" },
|
|
112
|
+
{ id: "NAL", name: "Nueva Aldea", regionId: "FM" },
|
|
113
|
+
{ id: "RAB", name: "Río Abajo", regionId: "FM" },
|
|
114
|
+
{ id: "RHO", name: "Río Hondo", regionId: "FM" },
|
|
115
|
+
{ id: "SOR", name: "San Francisco de Soroguara", regionId: "FM" },
|
|
116
|
+
{ id: "SJC", name: "San Juancito", regionId: "FM" },
|
|
117
|
+
{ id: "SJR", name: "San Juan del Rancho", regionId: "FM" },
|
|
118
|
+
{ id: "SRG", name: "San Juan del Río Grande", regionId: "FM" },
|
|
119
|
+
{ id: "SMT", name: "San Matías", regionId: "FM" },
|
|
120
|
+
{ id: "SCA", name: "Santa Cruz Abajo", regionId: "FM" },
|
|
121
|
+
{ id: "SCR", name: "Santa Cruz Arriba", regionId: "FM" },
|
|
122
|
+
{ id: "SAR", name: "Santa Rosa", regionId: "FM" },
|
|
123
|
+
{ id: "SRO", name: "Soroguara", regionId: "FM" },
|
|
124
|
+
{ id: "TAM", name: "Támara", regionId: "FM" },
|
|
125
|
+
{ id: "VNU", name: "Villa Nueva", regionId: "FM" },
|
|
126
|
+
{ id: "YAG", name: "Yaguacire", regionId: "FM" },
|
|
127
|
+
{ id: "ZAM", name: "Zambrano", regionId: "FM" }
|
|
128
|
+
]
|
|
129
|
+
},
|
|
130
|
+
{ id: "GD", name: "Gracias a Dios" },
|
|
131
|
+
{ id: "IN", name: "Intibucá" },
|
|
132
|
+
{ id: "IB", name: "Islas de la Bahía" },
|
|
133
|
+
{ id: "LP", name: "La Paz" },
|
|
134
|
+
{ id: "LE", name: "Lempira" },
|
|
135
|
+
{ id: "OC", name: "Ocotepeque" },
|
|
136
|
+
{ id: "OL", name: "Olancho" },
|
|
137
|
+
{ id: "SB", name: "Santa Bárbara" },
|
|
138
|
+
{ id: "VA", name: "Valle" },
|
|
139
|
+
{ id: "YO", name: "Yoro" }
|
|
140
|
+
],
|
|
141
|
+
|
|
142
|
+
US: [
|
|
143
|
+
{ id: "AL", name: "Alabama" },
|
|
144
|
+
{ id: "AK", name: "Alaska" },
|
|
145
|
+
{ id: "AZ", name: "Arizona" },
|
|
146
|
+
{ id: "AR", name: "Arkansas" },
|
|
147
|
+
{ id: "CA", name: "California" },
|
|
148
|
+
{ id: "CO", name: "Colorado" },
|
|
149
|
+
{ id: "CT", name: "Connecticut" },
|
|
150
|
+
{ id: "DE", name: "Delaware" },
|
|
151
|
+
{ id: "FL", name: "Florida" },
|
|
152
|
+
{ id: "GA", name: "Georgia" },
|
|
153
|
+
{ id: "HI", name: "Hawaii" },
|
|
154
|
+
{ id: "ID", name: "Idaho" },
|
|
155
|
+
{ id: "IL", name: "Illinois" },
|
|
156
|
+
{ id: "IN", name: "Indiana" },
|
|
157
|
+
{ id: "IA", name: "Iowa" },
|
|
158
|
+
{ id: "KS", name: "Kansas" },
|
|
159
|
+
{ id: "KY", name: "Kentucky" },
|
|
160
|
+
{ id: "LA", name: "Louisiana" },
|
|
161
|
+
{ id: "ME", name: "Maine" },
|
|
162
|
+
{ id: "MD", name: "Maryland" },
|
|
163
|
+
{ id: "MA", name: "Massachusetts" },
|
|
164
|
+
{ id: "MI", name: "Michigan" },
|
|
165
|
+
{ id: "MN", name: "Minnesota" },
|
|
166
|
+
{ id: "MS", name: "Mississippi" },
|
|
167
|
+
{ id: "MO", name: "Missouri" },
|
|
168
|
+
{ id: "MT", name: "Montana" },
|
|
169
|
+
{ id: "NE", name: "Nebraska" },
|
|
170
|
+
{ id: "NV", name: "Nevada" },
|
|
171
|
+
{ id: "NH", name: "New Hampshire" },
|
|
172
|
+
{ id: "NJ", name: "New Jersey" },
|
|
173
|
+
{ id: "NM", name: "New Mexico" },
|
|
174
|
+
{ id: "NY", name: "New York" },
|
|
175
|
+
{ id: "NC", name: "North Carolina" },
|
|
176
|
+
{ id: "ND", name: "North Dakota" },
|
|
177
|
+
{ id: "OH", name: "Ohio" },
|
|
178
|
+
{ id: "OK", name: "Oklahoma" },
|
|
179
|
+
{ id: "OR", name: "Oregon" },
|
|
180
|
+
{ id: "PA", name: "Pennsylvania" },
|
|
181
|
+
{ id: "RI", name: "Rhode Island" },
|
|
182
|
+
{ id: "SC", name: "South Carolina" },
|
|
183
|
+
{ id: "SD", name: "South Dakota" },
|
|
184
|
+
{ id: "TN", name: "Tennessee" },
|
|
185
|
+
{ id: "TX", name: "Texas" },
|
|
186
|
+
{ id: "UT", name: "Utah" },
|
|
187
|
+
{ id: "VT", name: "Vermont" },
|
|
188
|
+
{ id: "VA", name: "Virginia" },
|
|
189
|
+
{ id: "WA", name: "Washington" },
|
|
190
|
+
{ id: "WV", name: "West Virginia" },
|
|
191
|
+
{ id: "WI", name: "Wisconsin" },
|
|
192
|
+
{ id: "WY", name: "Wyoming" }
|
|
193
|
+
],
|
|
194
|
+
|
|
195
|
+
SV: [
|
|
196
|
+
{ id: "AH", name: "Ahuachapán" },
|
|
197
|
+
{ id: "CA", name: "Cabañas" },
|
|
198
|
+
{ id: "CH", name: "Chalatenango" },
|
|
199
|
+
{ id: "CU", name: "Cuscatlán" },
|
|
200
|
+
{ id: "LI", name: "La Libertad" },
|
|
201
|
+
{ id: "PA", name: "La Paz" },
|
|
202
|
+
{ id: "ONU", name: "La Unión" },
|
|
203
|
+
{ id: "MO", name: "Morazán" },
|
|
204
|
+
{ id: "SM", name: "San Miguel" },
|
|
205
|
+
{ id: "SS", name: "San Salvador" },
|
|
206
|
+
{ id: "SV", name: "San Vicente" },
|
|
207
|
+
{ id: "SA", name: "Santa Ana" },
|
|
208
|
+
{ id: "SO", name: "Sonsonate" },
|
|
209
|
+
{ id: "US", name: "Usulutan" }
|
|
210
|
+
],
|
|
211
|
+
|
|
212
|
+
CN: []
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
export function getRegionsByCountryId(id: 'HN' | 'US' | 'SV'): Region[] | any[] {
|
|
216
|
+
return Regions[id];
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* Usado en el atributo [compareWith] de los mat-select's
|
|
221
|
+
* de los formularios que manejan paises y regiones.
|
|
222
|
+
* @param c1
|
|
223
|
+
* @param c2
|
|
224
|
+
* @returns
|
|
225
|
+
*/
|
|
226
|
+
export const compareCountries = (c1: Country, c2: Country) => c1 && c2 ? c1.id === c2.id : false;
|
|
227
|
+
export const compareRegions = (r1: Region, r2: Region) => r1 && r2 ? r1.id === r2.id : false;
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// src/index.ts
|
|
2
|
+
|
|
3
|
+
/** ID único para un usuario */
|
|
4
|
+
// export type UserId = string & { __brand: 'UserId' };
|
|
5
|
+
export * from './api';
|
|
6
|
+
export * from './bag';
|
|
7
|
+
export * from './branch';
|
|
8
|
+
export * from './countries';
|
|
9
|
+
export * from './orders';
|
|
10
|
+
export * from './stats';
|
|
11
|
+
export * from './payments';
|
|
12
|
+
export * from './product-category';
|
|
13
|
+
export * from './products';
|
|
14
|
+
export * from './replenishment';
|
|
15
|
+
export * from './users';
|
|
16
|
+
export * from './warehouses';
|
|
17
|
+
export * from './translations';
|
|
18
|
+
export * from './company';
|
|
19
|
+
|
package/src/orders.ts
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { PaymentIntent } from "@stripe/stripe-js";
|
|
2
|
+
import { ProductWithVariantInBag } from "./bag";
|
|
3
|
+
import { UserAddressInDB } from "./users";
|
|
4
|
+
import { Country } from "./countries";
|
|
5
|
+
import { CategoryType } from "./product-category";
|
|
6
|
+
import { DeliveryMethod } from "./warehouses";
|
|
7
|
+
|
|
8
|
+
export interface Gift { fullname: string; msg?: string | null | undefined; };
|
|
9
|
+
|
|
10
|
+
export interface OrderDiscount {
|
|
11
|
+
id: string;
|
|
12
|
+
name: string;
|
|
13
|
+
subtitle: string;
|
|
14
|
+
code: string;
|
|
15
|
+
automatic?: boolean;
|
|
16
|
+
amount: number;
|
|
17
|
+
isPercent: boolean;
|
|
18
|
+
condition: 'first_order' | 'delivery_free' | 'none' | 'student' | 'share_5_friends';
|
|
19
|
+
conditionDescription: string;
|
|
20
|
+
categoriesTypes?: CategoryType['type'][];
|
|
21
|
+
minOrderAmount?: number;
|
|
22
|
+
dueDate: string;
|
|
23
|
+
public?: boolean;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export interface OrderDiscountApplied extends OrderDiscount {
|
|
27
|
+
amountInCurrentCcy?: number;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export interface ProductPrepared {
|
|
31
|
+
productId: string;
|
|
32
|
+
variantId: string;
|
|
33
|
+
qty: number;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Indicará qué productos de {@link OrderInDB.products} fueron ordenados y cuales fueron preparados
|
|
38
|
+
*/
|
|
39
|
+
export interface ProductCheckedAfterPrepared {
|
|
40
|
+
productId: string;
|
|
41
|
+
variantId: string;
|
|
42
|
+
qtyOrdered: number;
|
|
43
|
+
qtyPrepared: number;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export interface OrderInDB {
|
|
47
|
+
id: string;
|
|
48
|
+
customerName: string;
|
|
49
|
+
customerId: string;
|
|
50
|
+
customerCountry: Country;
|
|
51
|
+
|
|
52
|
+
products: ProductWithVariantInBag[];
|
|
53
|
+
/**
|
|
54
|
+
* Indicará qué productos de {@link products} fueron preparados y cuantas unidades.
|
|
55
|
+
*/
|
|
56
|
+
productsPrepared?: ProductPrepared[];
|
|
57
|
+
|
|
58
|
+
subtotalPrice: number;
|
|
59
|
+
subtotalWithDiscount: number;
|
|
60
|
+
totalPrice: number;
|
|
61
|
+
shippingPrice: number;
|
|
62
|
+
discounts?: OrderDiscountApplied[];
|
|
63
|
+
|
|
64
|
+
status: 'pending' | 'payment_error' | 'processing' | 'prepared' | 'shipped' | 'delivered' | 'canceled';
|
|
65
|
+
orderDate: string;
|
|
66
|
+
deliveryAddress: UserAddressInDB;
|
|
67
|
+
paymentStatus?: PaymentIntent.Status,
|
|
68
|
+
paymentMethod: 'credit_card' | 'paypal' | 'bank_transfer' | 'cash_on_delivery';
|
|
69
|
+
shippingMethod: DeliveryMethod;
|
|
70
|
+
gift?: Gift,
|
|
71
|
+
notes?: string;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export type OrderErrorCodes = 'ERR_CREATE_ORDER' | 'ERR_ORDER_INFO' | 'ERR_CHANGE_ORDER_STATUS';
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Interfaz para comunicación con la API
|
|
79
|
+
*/
|
|
80
|
+
export interface ConfirmOrderPayload {
|
|
81
|
+
orderReadyToPay: OrderReady;
|
|
82
|
+
customerCountry: Country;
|
|
83
|
+
paymentMethod: OrderInDB['paymentMethod'];
|
|
84
|
+
shippingMethod: OrderInDB['shippingMethod'];
|
|
85
|
+
deliveryAddress: OrderInDB['deliveryAddress'];
|
|
86
|
+
gift?: Gift;
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Orden lista para que el usuario decida pagar
|
|
91
|
+
*/
|
|
92
|
+
export interface OrderReady {
|
|
93
|
+
warehouseId: string;
|
|
94
|
+
warehouseCountryId: Country['id'];
|
|
95
|
+
products: ProductWithVariantInBag[];
|
|
96
|
+
paymentMethod?: OrderInDB['paymentMethod'];
|
|
97
|
+
shippingMethod?: DeliveryMethod;
|
|
98
|
+
deliveryAddress?: UserAddressInDB;
|
|
99
|
+
gift?: { fullname: string; msg?: string | null | undefined; };
|
|
100
|
+
subtotalPrice: number;
|
|
101
|
+
shippingPrice: number;
|
|
102
|
+
subtotalWithDiscount: number;
|
|
103
|
+
totalPrice: number;
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Ordenes listas para que el usuario decida pagar
|
|
109
|
+
*/
|
|
110
|
+
export interface OrdersReady {
|
|
111
|
+
[warehouseId: string]: OrderReady;
|
|
112
|
+
};
|
package/src/org/event.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export interface NiceEvent {
|
|
2
|
+
id: string;
|
|
3
|
+
title: string;
|
|
4
|
+
description: string;
|
|
5
|
+
inPerson: boolean;
|
|
6
|
+
organizerName: string;
|
|
7
|
+
createdBy: {
|
|
8
|
+
id: string;
|
|
9
|
+
name: string;
|
|
10
|
+
};
|
|
11
|
+
location: string;
|
|
12
|
+
coverUrl?: string;
|
|
13
|
+
startDate: Date;
|
|
14
|
+
endDate: Date;
|
|
15
|
+
createdAt: string;
|
|
16
|
+
updatedAt?: string;
|
|
17
|
+
}
|
package/src/org/index.ts
ADDED
package/src/org/radar.ts
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { PaymentIntent } from "@stripe/stripe-js";
|
|
2
|
+
|
|
3
|
+
export type Currency = 'HNL' | 'EUR' | 'USD';
|
|
4
|
+
export type DonationStatus = 'pending_pay' | 'pending' | 'payment_error' | 'processing' | 'resolve' | 'rejected' | 'expired' | 'used';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Tipos de donaciones usadas en el radar
|
|
8
|
+
*
|
|
9
|
+
* Valores posibles:
|
|
10
|
+
* - `direct_donation`: Donación directa a una persona
|
|
11
|
+
* - `event`: Evento
|
|
12
|
+
* - `operating_expenses`: Gastos operativos
|
|
13
|
+
*/
|
|
14
|
+
export type UsedIn = 'direct_donation' | 'event' | 'operating_expenses';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Tipos de movimientos del radar
|
|
18
|
+
*
|
|
19
|
+
* Valores posibles:
|
|
20
|
+
* - `info`: Movimiento informativo
|
|
21
|
+
* - `cash_converted_to_hnl`: Convertido a lempiras
|
|
22
|
+
* - `cash_income`: Ingreso
|
|
23
|
+
* - `cash_expense`: Gasto
|
|
24
|
+
* - `cash_refund`: Reembolso
|
|
25
|
+
* - `cash_reversion`: Reversión
|
|
26
|
+
*
|
|
27
|
+
* @remarks
|
|
28
|
+
* El reembolso es para el cliente, mientras que la reversión
|
|
29
|
+
* es para devolver el dinero a la donación original.
|
|
30
|
+
*/
|
|
31
|
+
export type FlowType = 'info' | 'cash_converted_to_hnl' | 'cash_income' | 'cash_expense' | 'cash_refund' | 'cash_reversion';
|
|
32
|
+
|
|
33
|
+
export interface Movement {
|
|
34
|
+
id: string;
|
|
35
|
+
title: string;
|
|
36
|
+
desc?: string;
|
|
37
|
+
/**
|
|
38
|
+
* Tipos de donaciones usadas en el radar
|
|
39
|
+
*
|
|
40
|
+
* Valores posibles:
|
|
41
|
+
* - `direct_donation`: Donación directa a una persona
|
|
42
|
+
* - `event`: Evento
|
|
43
|
+
* - `operating_expenses`: Gastos operativos
|
|
44
|
+
*/
|
|
45
|
+
usedIn: UsedIn;
|
|
46
|
+
icon: 'ok' | 'error' | 'info' | 'waiting';
|
|
47
|
+
type: FlowType;
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Monto involucrado en el movimiento,
|
|
51
|
+
* se debe proporcionar `0` cuándo {@link FlowType} sea `none`.
|
|
52
|
+
* Ej. `amount: 0`
|
|
53
|
+
*/
|
|
54
|
+
amount: number;
|
|
55
|
+
createdAt: string;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
export interface DonationCharges {
|
|
59
|
+
subtotal: number;
|
|
60
|
+
fees: number;
|
|
61
|
+
total: number;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* La donación se puede recibir en HNL, USD o EUR,
|
|
66
|
+
* pero se deberá convertir a lempiras antes de ser usada.
|
|
67
|
+
*/
|
|
68
|
+
export interface Donation {
|
|
69
|
+
id: string;
|
|
70
|
+
donorId: string;
|
|
71
|
+
fullname: string,
|
|
72
|
+
anonymous: boolean;
|
|
73
|
+
charges: DonationCharges;
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Cuándo se reciba en una moneda distinta de HNL, se convertirá a HNL.
|
|
77
|
+
* De lo contrario será `undefined`
|
|
78
|
+
*/
|
|
79
|
+
chargesInHNL?: DonationCharges;
|
|
80
|
+
status: DonationStatus;
|
|
81
|
+
mainCcy: Currency;
|
|
82
|
+
paymentStatus?: PaymentIntent.Status;
|
|
83
|
+
|
|
84
|
+
radar?: { [movementId: string]: Movement };
|
|
85
|
+
createdAt?: string;
|
|
86
|
+
};
|
package/src/payments.ts
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { Metadata, PaymentIntent } from "@stripe/stripe-js";
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Payment como está registrado en la base de datos
|
|
6
|
+
*/
|
|
7
|
+
export interface PaymentInDB {
|
|
8
|
+
/**
|
|
9
|
+
* @property {string} `id`
|
|
10
|
+
* mismo que `Stripe.PaymentIntent.id`
|
|
11
|
+
*/
|
|
12
|
+
id: string;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @property {@link Issuer} `recipientMap`
|
|
16
|
+
* Quién pagó
|
|
17
|
+
*/
|
|
18
|
+
issuerMap: { id: string; displayName: string; };
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* @property {number} `amount`
|
|
22
|
+
* Monto a pagar, incluyendo impuestos, tarifas y comisiones.
|
|
23
|
+
*/
|
|
24
|
+
amount: number;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* @property {number} `tax`
|
|
28
|
+
* Impuesto de la transacción, basado en EEUU.
|
|
29
|
+
*/
|
|
30
|
+
tax: 8.25;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* @property ccy {@link PaymentCCY}
|
|
34
|
+
* Moneda en la que se ejecutará el pago.
|
|
35
|
+
*/
|
|
36
|
+
ccy: 'HNL' | 'USD' | 'EUR';
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* @property {Timestamp} `createdAt`
|
|
40
|
+
* Fecha y hora en que se generó la transacción,
|
|
41
|
+
* igual que `Stripe.PaymentIntent.created`.
|
|
42
|
+
*/
|
|
43
|
+
createdAt: string;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Parámetros que se enviarán al servidor,
|
|
49
|
+
* y así registrar el PaymentIntent con stripe.
|
|
50
|
+
*/
|
|
51
|
+
export interface StripePaymentIntentParams {
|
|
52
|
+
cardHolder: string | string | null | undefined;
|
|
53
|
+
billingAddressLine1: string | string | null | undefined;
|
|
54
|
+
billingAddressCity: string | string | null | undefined;
|
|
55
|
+
amount: number;
|
|
56
|
+
currency: string;
|
|
57
|
+
metadata: PaymentInStripeMetadata;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export interface PaymentInStripeMetadata {
|
|
61
|
+
/** Ej. users/{userId}/orders/{orderId} */
|
|
62
|
+
refDB: string;
|
|
63
|
+
issuerId: string;
|
|
64
|
+
issuerName: string;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Respuesta de la API Ivife cuándo se busca un PaymentIntent por su {@link StripeMetadata.refId}
|
|
69
|
+
*/
|
|
70
|
+
export interface StripePaymentIntentResponse {
|
|
71
|
+
metadata: PaymentInStripeMetadata | Metadata;
|
|
72
|
+
status: PaymentIntent.Status;
|
|
73
|
+
amount: number;
|
|
74
|
+
amount_capturable: number;
|
|
75
|
+
amount_received: number;
|
|
76
|
+
currency: string;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export type PaymentErrorCodes = 'ERR_PAYMENT' | 'ERR_REINTENT_PAYMENT' | 'authentication_required' | 'requires_action';
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { Country } from "./countries";
|
|
2
|
+
import { Translations } from "./translations";
|
|
3
|
+
|
|
4
|
+
export interface Category {
|
|
5
|
+
id: string;
|
|
6
|
+
title: string;
|
|
7
|
+
translations?: Translations<string>;
|
|
8
|
+
icon?: string;
|
|
9
|
+
subcategories?: SubCategory[];
|
|
10
|
+
hidden?: boolean;
|
|
11
|
+
adultsOnly?: boolean;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface SubCategory {
|
|
15
|
+
id: string;
|
|
16
|
+
title: string;
|
|
17
|
+
translations?: Translations<string>;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface CategoryType {
|
|
21
|
+
title: string;
|
|
22
|
+
type: 'clothes' |'gifts' | 'perfumes' | 'electric' | 'electronics' | 'handmade-jewelry' | 'jewelry' | 'home' | 'beauty' | 'health' | 'books' | 'shoes' | 'bags';
|
|
23
|
+
translations?: Translations<string>;
|
|
24
|
+
icon?: string;
|
|
25
|
+
categories: Category[];
|
|
26
|
+
countries: Country['id'][];
|
|
27
|
+
hidden?: boolean;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
export interface ProductCategoryInDB {
|
|
32
|
+
id: string;
|
|
33
|
+
subcategory: string
|
|
34
|
+
};
|