@warriorteam/redai-zalo-sdk 1.30.0 → 1.32.0

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.
@@ -0,0 +1,417 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PurchaseService = void 0;
4
+ const common_1 = require("../types/common");
5
+ const purchase_1 = require("../types/purchase");
6
+ /**
7
+ * Service xử lý các API mua sản phẩm/dịch vụ OA của Zalo
8
+ *
9
+ * ĐIỀU KIỆN SỬ DỤNG PURCHASE API:
10
+ *
11
+ * 1. QUYỀN TRUY CẬP:
12
+ * - Ứng dụng cần được cấp quyền quản lý "Mua sản phẩm dịch vụ OA"
13
+ * - OA phải được xác minh và có quyền bán sản phẩm/dịch vụ
14
+ *
15
+ * 2. THỜI GIAN TẠO ĐỚN:
16
+ * - Order chỉ được tạo từ 00:01 đến 23:54 hàng ngày
17
+ * - Không thể tạo đơn hàng trong khung giờ bảo trì (23:55 - 00:00)
18
+ *
19
+ * 3. SẢN PHẨM/DỊCH VỤ:
20
+ * - Sản phẩm phải có sẵn và được phép bán
21
+ * - Đối tượng thụ hưởng (beneficiary) phải phù hợp với sản phẩm
22
+ * - Có thể sử dụng product_id HOẶC redeem_code, không được dùng cả hai
23
+ *
24
+ * 4. THANH TOÁN:
25
+ * - Tài khoản ZCA phải có đủ số dư để thanh toán
26
+ * - Voucher code (nếu có) phải hợp lệ và chưa hết hạn
27
+ *
28
+ * 5. XÁC THỰC:
29
+ * - Mỗi đơn hàng sẽ có verified_token (OTT) để xác nhận thanh toán
30
+ * - OTT có hiệu lực trong vòng 5 phút kể từ khi tạo đơn
31
+ *
32
+ * LỖI THƯỜNG GẶP:
33
+ * - 1001: Beneficiary không hợp lệ
34
+ * - 1002: Product ID không tồn tại hoặc không khả dụng
35
+ * - 1003: Redeem code không hợp lệ hoặc đã được sử dụng
36
+ * - 1004: Voucher code không hợp lệ hoặc đã hết hạn
37
+ * - 1005: Sản phẩm không khả dụng cho đối tượng thụ hưởng
38
+ * - 1006: Số dư tài khoản không đủ
39
+ * - 1007: Ngoài thời gian cho phép tạo đơn hàng
40
+ * - 1008: Đơn hàng trùng lặp
41
+ * - 1009: Không có quyền truy cập
42
+ */
43
+ class PurchaseService {
44
+ constructor(client) {
45
+ this.client = client;
46
+ this.purchaseApiUrl = "https://openapi.zalo.me/v3.0/oa/purchase";
47
+ }
48
+ /**
49
+ * Tạo đơn hàng mua sản phẩm/dịch vụ OA
50
+ * @param accessToken Access token của Official Account
51
+ * @param request Thông tin đơn hàng cần tạo
52
+ * @returns Thông tin đơn hàng đã tạo
53
+ */
54
+ async createOrder(accessToken, request) {
55
+ try {
56
+ // Validate request
57
+ this.validateCreateOrderRequest(request);
58
+ const result = await this.client.apiPost(`${this.purchaseApiUrl}/create_order`, accessToken, request);
59
+ if (result.error !== 0) {
60
+ throw new common_1.ZaloSDKError(result.message || "Failed to create order", result.error, result);
61
+ }
62
+ return result.data;
63
+ }
64
+ catch (error) {
65
+ if (error instanceof common_1.ZaloSDKError) {
66
+ throw error;
67
+ }
68
+ throw new common_1.ZaloSDKError(`Failed to create order: ${error.message}`, purchase_1.PurchaseErrorCode.SYSTEM_ERROR, error);
69
+ }
70
+ }
71
+ /**
72
+ * Tạo đơn hàng với product_id
73
+ * @param accessToken Access token của Official Account
74
+ * @param beneficiary Đối tượng thụ hưởng (OA hoặc APP)
75
+ * @param productId ID sản phẩm
76
+ * @param voucherCode Mã giảm giá (tùy chọn)
77
+ * @returns Thông tin đơn hàng đã tạo
78
+ */
79
+ async createOrderWithProduct(accessToken, beneficiary, productId, voucherCode) {
80
+ const request = {
81
+ beneficiary,
82
+ product_id: productId,
83
+ ...(voucherCode && { voucher_code: voucherCode }),
84
+ };
85
+ return this.createOrder(accessToken, request);
86
+ }
87
+ /**
88
+ * Tạo đơn hàng với redeem_code (mã quà tặng)
89
+ * @param accessToken Access token của Official Account
90
+ * @param beneficiary Đối tượng thụ hưởng (OA hoặc APP)
91
+ * @param redeemCode Mã quà tặng
92
+ * @param voucherCode Mã giảm giá (tùy chọn)
93
+ * @returns Thông tin đơn hàng đã tạo
94
+ */
95
+ async createOrderWithRedeemCode(accessToken, beneficiary, redeemCode, voucherCode) {
96
+ const request = {
97
+ beneficiary,
98
+ redeem_code: redeemCode,
99
+ ...(voucherCode && { voucher_code: voucherCode }),
100
+ };
101
+ return this.createOrder(accessToken, request);
102
+ }
103
+ /**
104
+ * Validate create order request
105
+ * @param request Request to validate
106
+ */
107
+ validateCreateOrderRequest(request) {
108
+ // Validate beneficiary
109
+ if (!request.beneficiary || !["OA", "APP"].includes(request.beneficiary)) {
110
+ throw new common_1.ZaloSDKError("Beneficiary must be either 'OA' or 'APP'", purchase_1.PurchaseErrorCode.INVALID_BENEFICIARY);
111
+ }
112
+ // Validate that either product_id or redeem_code is provided, but not both
113
+ const hasProductId = (0, purchase_1.isProductOrderRequest)(request);
114
+ const hasRedeemCode = (0, purchase_1.isRedeemOrderRequest)(request);
115
+ if (!hasProductId && !hasRedeemCode) {
116
+ throw new common_1.ZaloSDKError("Either product_id or redeem_code must be provided", purchase_1.PurchaseErrorCode.INVALID_PRODUCT_ID);
117
+ }
118
+ if (hasProductId && hasRedeemCode) {
119
+ throw new common_1.ZaloSDKError("Cannot use both product_id and redeem_code in the same request", purchase_1.PurchaseErrorCode.INVALID_PRODUCT_ID);
120
+ }
121
+ // Validate product_id
122
+ if (hasProductId && (!request.product_id || request.product_id <= 0)) {
123
+ throw new common_1.ZaloSDKError("Product ID must be a positive number", purchase_1.PurchaseErrorCode.INVALID_PRODUCT_ID);
124
+ }
125
+ // Validate redeem_code
126
+ if (hasRedeemCode && (!request.redeem_code || request.redeem_code.trim() === "")) {
127
+ throw new common_1.ZaloSDKError("Redeem code cannot be empty", purchase_1.PurchaseErrorCode.INVALID_REDEEM_CODE);
128
+ }
129
+ // Validate voucher_code if provided
130
+ if (request.voucher_code && request.voucher_code.trim() === "") {
131
+ throw new common_1.ZaloSDKError("Voucher code cannot be empty if provided", purchase_1.PurchaseErrorCode.INVALID_VOUCHER_CODE);
132
+ }
133
+ }
134
+ /**
135
+ * Kiểm tra thời gian có thể tạo đơn hàng
136
+ * @returns true nếu trong thời gian cho phép tạo đơn hàng
137
+ */
138
+ isOrderCreationTimeValid() {
139
+ const now = new Date();
140
+ const hours = now.getHours();
141
+ const minutes = now.getMinutes();
142
+ // Order chỉ được tạo từ 00:01 đến 23:54
143
+ if (hours === 0 && minutes === 0) {
144
+ return false; // 00:00
145
+ }
146
+ if (hours === 23 && minutes >= 55) {
147
+ return false; // 23:55 - 23:59
148
+ }
149
+ return true;
150
+ }
151
+ /**
152
+ * Tính toán thời gian hết hạn của OTT (One Time Token)
153
+ * @param createdTime Thời gian tạo đơn hàng (milliseconds)
154
+ * @returns Thời gian hết hạn OTT (milliseconds)
155
+ */
156
+ calculateOTTExpiration(createdTime) {
157
+ // OTT có hiệu lực trong vòng 5 phút
158
+ return createdTime + 5 * 60 * 1000;
159
+ }
160
+ /**
161
+ * Kiểm tra OTT còn hiệu lực hay không
162
+ * @param createdTime Thời gian tạo đơn hàng (milliseconds)
163
+ * @returns true nếu OTT còn hiệu lực
164
+ */
165
+ isOTTValid(createdTime) {
166
+ const now = Date.now();
167
+ const expirationTime = this.calculateOTTExpiration(createdTime);
168
+ return now < expirationTime;
169
+ }
170
+ /**
171
+ * Xác nhận thanh toán đơn hàng
172
+ * @param accessToken Access token của Official Account
173
+ * @param request Thông tin xác nhận đơn hàng
174
+ * @returns Thông tin đơn hàng đã được xác nhận thanh toán
175
+ */
176
+ async confirmOrder(accessToken, request) {
177
+ try {
178
+ // Validate request
179
+ this.validateConfirmOrderRequest(request);
180
+ const result = await this.client.apiPost(`${this.purchaseApiUrl}/confirm_order`, accessToken, request);
181
+ if (result.error !== 0) {
182
+ throw new common_1.ZaloSDKError(result.message || "Failed to confirm order", result.error, result);
183
+ }
184
+ return result.data;
185
+ }
186
+ catch (error) {
187
+ if (error instanceof common_1.ZaloSDKError) {
188
+ throw error;
189
+ }
190
+ throw new common_1.ZaloSDKError(`Failed to confirm order: ${error.message}`, purchase_1.PurchaseErrorCode.SYSTEM_ERROR, error);
191
+ }
192
+ }
193
+ /**
194
+ * Xác nhận thanh toán đơn hàng với order ID và verified token
195
+ * @param accessToken Access token của Official Account
196
+ * @param orderId ID đơn hàng
197
+ * @param verifiedToken OTT token để xác nhận
198
+ * @returns Thông tin đơn hàng đã được xác nhận thanh toán
199
+ */
200
+ async confirmOrderById(accessToken, orderId, verifiedToken) {
201
+ const request = {
202
+ order_id: orderId,
203
+ verified_token: verifiedToken,
204
+ };
205
+ return this.confirmOrder(accessToken, request);
206
+ }
207
+ /**
208
+ * Lấy thông tin sản phẩm theo ID
209
+ * @param productId ID sản phẩm
210
+ * @returns Thông tin sản phẩm hoặc undefined nếu không tìm thấy
211
+ */
212
+ getProductInfo(productId) {
213
+ return purchase_1.PRODUCT_INFO[productId];
214
+ }
215
+ /**
216
+ * Lấy danh sách tất cả sản phẩm có sẵn
217
+ * @returns Danh sách thông tin sản phẩm
218
+ */
219
+ getAllProducts() {
220
+ return Object.values(purchase_1.PRODUCT_INFO);
221
+ }
222
+ /**
223
+ * Lấy danh sách sản phẩm theo loại
224
+ * @param category Loại sản phẩm
225
+ * @returns Danh sách sản phẩm thuộc loại đó
226
+ */
227
+ getProductsByCategory(category) {
228
+ return Object.values(purchase_1.PRODUCT_INFO).filter(product => product.category === category);
229
+ }
230
+ /**
231
+ * Lấy danh sách sản phẩm theo đối tượng thụ hưởng
232
+ * @param beneficiary Đối tượng thụ hưởng
233
+ * @returns Danh sách sản phẩm phù hợp với đối tượng thụ hưởng
234
+ */
235
+ getProductsByBeneficiary(beneficiary) {
236
+ return Object.values(purchase_1.PRODUCT_INFO).filter(product => product.beneficiary.includes(beneficiary));
237
+ }
238
+ /**
239
+ * Kiểm tra sản phẩm có phù hợp với đối tượng thụ hưởng không
240
+ * @param productId ID sản phẩm
241
+ * @param beneficiary Đối tượng thụ hưởng
242
+ * @returns true nếu sản phẩm phù hợp với đối tượng thụ hưởng
243
+ */
244
+ isProductCompatibleWithBeneficiary(productId, beneficiary) {
245
+ const product = this.getProductInfo(productId);
246
+ if (!product) {
247
+ return false;
248
+ }
249
+ return product.beneficiary.includes(beneficiary);
250
+ }
251
+ // ==================== SPECIALIZED PRODUCT APIS ====================
252
+ /**
253
+ * Tạo đơn hàng gói OA Subscription
254
+ * @param accessToken Access token của Official Account
255
+ * @param subscriptionType Loại gói subscription
256
+ * @param voucherCode Mã giảm giá (tùy chọn)
257
+ * @returns Thông tin đơn hàng đã tạo
258
+ */
259
+ async createOASubscriptionOrder(accessToken, subscriptionType, voucherCode) {
260
+ const productIdMap = {
261
+ 'advanced_6m': purchase_1.OA_PRODUCTS.OA_ADVANCED_6M,
262
+ 'advanced_12m': purchase_1.OA_PRODUCTS.OA_ADVANCED_12M,
263
+ 'premium_6m': purchase_1.OA_PRODUCTS.OA_PREMIUM_6M,
264
+ 'premium_12m': purchase_1.OA_PRODUCTS.OA_PREMIUM_12M,
265
+ };
266
+ const productId = productIdMap[subscriptionType];
267
+ return this.createOrderWithProduct(accessToken, "OA", productId, voucherCode);
268
+ }
269
+ /**
270
+ * Tạo đơn hàng gói GMF (Group Message Framework)
271
+ * @param accessToken Access token của Official Account
272
+ * @param memberLimit Giới hạn số thành viên
273
+ * @param voucherCode Mã giảm giá (tùy chọn)
274
+ * @returns Thông tin đơn hàng đã tạo
275
+ */
276
+ async createGMFOrder(accessToken, memberLimit, voucherCode) {
277
+ const productIdMap = {
278
+ 10: purchase_1.OA_PRODUCTS.GMF_10_MEMBERS,
279
+ 50: purchase_1.OA_PRODUCTS.GMF_50_MEMBERS,
280
+ 100: purchase_1.OA_PRODUCTS.GMF_100_MEMBERS,
281
+ 1000: purchase_1.OA_PRODUCTS.GMF_1000_MEMBERS,
282
+ };
283
+ const productId = productIdMap[memberLimit];
284
+ return this.createOrderWithProduct(accessToken, "OA", productId, voucherCode);
285
+ }
286
+ /**
287
+ * Tạo đơn hàng gói quota tin nhắn giao dịch
288
+ * @param accessToken Access token của Official Account
289
+ * @param beneficiary Đối tượng thụ hưởng (OA hoặc APP)
290
+ * @param quotaSize Kích thước gói quota
291
+ * @param voucherCode Mã giảm giá (tùy chọn)
292
+ * @returns Thông tin đơn hàng đã tạo
293
+ */
294
+ async createTransactionQuotaOrder(accessToken, beneficiary, quotaSize, voucherCode) {
295
+ const productIdMap = {
296
+ '5k': purchase_1.OA_PRODUCTS.TRANSACTION_5K,
297
+ '50k': purchase_1.OA_PRODUCTS.TRANSACTION_50K,
298
+ '500k': purchase_1.OA_PRODUCTS.TRANSACTION_500K,
299
+ };
300
+ const productId = productIdMap[quotaSize];
301
+ // Validate beneficiary compatibility
302
+ if (!this.isProductCompatibleWithBeneficiary(productId, beneficiary)) {
303
+ throw new common_1.ZaloSDKError(`Product ${quotaSize} transaction quota is not compatible with beneficiary ${beneficiary}`, purchase_1.PurchaseErrorCode.PRODUCT_NOT_AVAILABLE);
304
+ }
305
+ return this.createOrderWithProduct(accessToken, beneficiary, productId, voucherCode);
306
+ }
307
+ // ==================== BULK ORDER OPERATIONS ====================
308
+ /**
309
+ * Tạo nhiều đơn hàng cùng lúc (batch operation)
310
+ * @param accessToken Access token của Official Account
311
+ * @param orders Danh sách đơn hàng cần tạo
312
+ * @returns Danh sách kết quả tạo đơn hàng
313
+ */
314
+ async createMultipleOrders(accessToken, orders) {
315
+ const results = [];
316
+ for (const order of orders) {
317
+ try {
318
+ const orderData = await this.createOrder(accessToken, order);
319
+ results.push({ success: true, data: orderData });
320
+ }
321
+ catch (error) {
322
+ results.push({
323
+ success: false,
324
+ error: error instanceof common_1.ZaloSDKError ? error.message : error.message
325
+ });
326
+ }
327
+ }
328
+ return results;
329
+ }
330
+ /**
331
+ * Tạo combo đơn hàng OA Premium + GMF
332
+ * @param accessToken Access token của Official Account
333
+ * @param premiumDuration Thời hạn gói Premium
334
+ * @param gmfMemberLimit Giới hạn thành viên GMF
335
+ * @param voucherCode Mã giảm giá (tùy chọn)
336
+ * @returns Danh sách kết quả tạo đơn hàng
337
+ */
338
+ async createOAPremiumGMFCombo(accessToken, premiumDuration, gmfMemberLimit, voucherCode) {
339
+ const premiumResult = await this.createOASubscriptionOrder(accessToken, premiumDuration === '6m' ? 'premium_6m' : 'premium_12m', voucherCode).then(data => ({ success: true, data }))
340
+ .catch(error => ({
341
+ success: false,
342
+ error: error instanceof common_1.ZaloSDKError ? error.message : error.message
343
+ }));
344
+ const gmfResult = await this.createGMFOrder(accessToken, gmfMemberLimit, voucherCode).then(data => ({ success: true, data }))
345
+ .catch(error => ({
346
+ success: false,
347
+ error: error instanceof common_1.ZaloSDKError ? error.message : error.message
348
+ }));
349
+ return {
350
+ premium: premiumResult,
351
+ gmf: gmfResult
352
+ };
353
+ }
354
+ // ==================== PRODUCT RECOMMENDATION ====================
355
+ /**
356
+ * Gợi ý sản phẩm dựa trên nhu cầu
357
+ * @param requirements Yêu cầu của khách hàng
358
+ * @returns Danh sách sản phẩm được gợi ý
359
+ */
360
+ recommendProducts(requirements) {
361
+ let recommendations = [];
362
+ // Filter by beneficiary
363
+ const compatibleProducts = this.getProductsByBeneficiary(requirements.beneficiary);
364
+ // Add recommendations based on features
365
+ if (requirements.features?.includes('subscription')) {
366
+ const subscriptionProducts = compatibleProducts.filter(p => p.category === 'subscription');
367
+ if (requirements.duration === 'long') {
368
+ recommendations.push(...subscriptionProducts.filter(p => p.name.includes('12 tháng')));
369
+ }
370
+ else {
371
+ recommendations.push(...subscriptionProducts.filter(p => p.name.includes('6 tháng')));
372
+ }
373
+ }
374
+ if (requirements.features?.includes('group_messaging')) {
375
+ const gmfProducts = compatibleProducts.filter(p => p.category === 'gmf');
376
+ if (requirements.budget === 'low') {
377
+ recommendations.push(...gmfProducts.filter(p => p.name.includes('10 thành viên')));
378
+ }
379
+ else if (requirements.budget === 'high') {
380
+ recommendations.push(...gmfProducts.filter(p => p.name.includes('1000 thành viên')));
381
+ }
382
+ else {
383
+ recommendations.push(...gmfProducts.filter(p => p.name.includes('50 thành viên') || p.name.includes('100 thành viên')));
384
+ }
385
+ }
386
+ if (requirements.features?.includes('transaction_quota')) {
387
+ const quotaProducts = compatibleProducts.filter(p => p.category === 'quota');
388
+ if (requirements.budget === 'low') {
389
+ recommendations.push(...quotaProducts.filter(p => p.name.includes('5k tin')));
390
+ }
391
+ else if (requirements.budget === 'high') {
392
+ recommendations.push(...quotaProducts.filter(p => p.name.includes('500k tin')));
393
+ }
394
+ else {
395
+ recommendations.push(...quotaProducts.filter(p => p.name.includes('50k tin')));
396
+ }
397
+ }
398
+ // Remove duplicates
399
+ return recommendations.filter((product, index, self) => index === self.findIndex(p => p.id === product.id));
400
+ }
401
+ /**
402
+ * Validate confirm order request
403
+ * @param request Request to validate
404
+ */
405
+ validateConfirmOrderRequest(request) {
406
+ // Validate order_id
407
+ if (!request.order_id || request.order_id.trim() === "") {
408
+ throw new common_1.ZaloSDKError("Order ID cannot be empty", purchase_1.PurchaseErrorCode.INVALID_ORDER_ID);
409
+ }
410
+ // Validate verified_token
411
+ if (!request.verified_token || request.verified_token.trim() === "") {
412
+ throw new common_1.ZaloSDKError("Verified token cannot be empty", purchase_1.PurchaseErrorCode.INVALID_VERIFIED_TOKEN);
413
+ }
414
+ }
415
+ }
416
+ exports.PurchaseService = PurchaseService;
417
+ //# sourceMappingURL=purchase.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"purchase.service.js","sourceRoot":"","sources":["../../src/services/purchase.service.ts"],"names":[],"mappings":";;;AACA,4CAA6D;AAC7D,gDAa2B;AAE3B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,MAAa,eAAe;IAG1B,YAA6B,MAAkB;QAAlB,WAAM,GAAN,MAAM,CAAY;QAF9B,mBAAc,GAAG,0CAA0C,CAAC;IAE3B,CAAC;IAEnD;;;;;OAKG;IACI,KAAK,CAAC,WAAW,CACtB,WAAmB,EACnB,OAA2B;QAE3B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