zmp-sdk 2.53.1 → 2.53.3

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/index.d.ts CHANGED
@@ -1442,6 +1442,10 @@ type VoucherAction = {
1442
1442
  */
1443
1443
  cta: string;
1444
1444
  };
1445
+ /**
1446
+ * @deprecated Dùng `AddCardParams` với `type` là `voucher`; type này sẽ bị loại bỏ cùng
1447
+ * `addVoucher`.
1448
+ */
1445
1449
  type AddVoucherData = {
1446
1450
  /**
1447
1451
  * Tên voucher / ưu đãi.
@@ -1504,6 +1508,112 @@ type AddVoucherReturns = {
1504
1508
  */
1505
1509
  oaMessageToken: string;
1506
1510
  };
1511
+ /**
1512
+ * Loại thẻ mà `addCard` hỗ trợ. Hiện chỉ có `voucher`.
1513
+ */
1514
+ type CardType = "voucher";
1515
+ type VoucherCardMeta = {
1516
+ /**
1517
+ * Mã voucher dạng plain text, hệ thống tự render thành QR / barcode;
1518
+ * tối đa 140 ký tự. Bỏ trống thì thẻ không hiển thị mã.
1519
+ */
1520
+ code?: string;
1521
+ /**
1522
+ * Loại mã hiển thị, chỉ có tác dụng khi có `code`. Mặc định là `qr_code`.
1523
+ */
1524
+ display?: VoucherDisplayType;
1525
+ /**
1526
+ * Nguồn phát hành voucher.
1527
+ */
1528
+ partner?: string;
1529
+ /**
1530
+ * Tên ưu đãi, khác với `data.name`; tối đa 200 ký tự. Hiện chưa được sử dụng: thẻ
1531
+ * không hiển thị trường này.
1532
+ */
1533
+ name?: string;
1534
+ /**
1535
+ * Tên thương hiệu / cửa hàng phát hành; tối đa 100 ký tự.
1536
+ */
1537
+ merchantName: string;
1538
+ /**
1539
+ * OA ID của merchant trên Zalo; tối đa 50 ký tự.
1540
+ */
1541
+ merchantOaId: string;
1542
+ /**
1543
+ * Tên chủ thẻ; tối đa 100 ký tự. Bỏ trống thì thẻ không hiển thị tên chủ thẻ.
1544
+ */
1545
+ ownerName?: string;
1546
+ /**
1547
+ * Điều kiện áp dụng tóm tắt, hiển thị trực tiếp trên thẻ; tối đa 500 ký tự.
1548
+ */
1549
+ condition: string;
1550
+ /**
1551
+ * Điều kiện áp dụng chi tiết; tối đa 2000 ký tự.
1552
+ */
1553
+ conditionDetail?: string;
1554
+ /**
1555
+ * Thời gian bắt đầu hiệu lực, epoch milliseconds; phải nhỏ hơn `expiredAt`.
1556
+ */
1557
+ validAt?: number;
1558
+ /**
1559
+ * Hạn sử dụng, epoch milliseconds; phải ở tương lai và không quá 365 ngày.
1560
+ */
1561
+ expiredAt: number;
1562
+ /**
1563
+ * Danh sách CTA hiển thị trên thẻ (tối đa 3).
1564
+ */
1565
+ actions?: VoucherAction[];
1566
+ };
1567
+ type VoucherCardData = {
1568
+ /**
1569
+ * Tiêu đề hiển thị trên thẻ, thường đặt bằng tên merchant; tối đa 200 ký tự.
1570
+ */
1571
+ title: string;
1572
+ /**
1573
+ * Tên voucher / ưu đãi, hiển thị nổi bật; tối đa 200 ký tự.
1574
+ */
1575
+ name: string;
1576
+ /**
1577
+ * Mô tả phụ dưới tên voucher, thường là tên chủ thẻ; tối đa 500 ký tự.
1578
+ */
1579
+ desc?: string;
1580
+ /**
1581
+ * Logo merchant dạng tròn; tối đa 500 ký tự. Dùng cho cả cửa sổ xem trước lẫn Ví QR.
1582
+ * Bỏ trống hoặc URL load lỗi thì dùng ảnh mặc định.
1583
+ */
1584
+ avatarUrl?: string;
1585
+ /**
1586
+ * Thông tin nghiệp vụ của voucher.
1587
+ */
1588
+ meta: VoucherCardMeta;
1589
+ };
1590
+ /**
1591
+ * Dữ liệu thẻ, tương ứng với `type` được truyền vào `addCard`.
1592
+ */
1593
+ type AddCardData = VoucherCardData;
1594
+ type AddCardParams = {
1595
+ /**
1596
+ * Loại thẻ; hiện chỉ hỗ trợ `voucher`.
1597
+ */
1598
+ type: CardType;
1599
+ /**
1600
+ * Dữ liệu thẻ, tương ứng với `type`.
1601
+ */
1602
+ data: AddCardData;
1603
+ /**
1604
+ * Token để merchant gửi tin nhắn không tốn phí. Lấy từ callback
1605
+ * `onDataReceived` của `showFunctionButtonWidget`.
1606
+ */
1607
+ interactToken?: string;
1608
+ };
1609
+ type AddCardReturns = {
1610
+ /**
1611
+ * Token để merchant gửi tin nhắn OA cho người dùng; không có trường này nếu không gửi
1612
+ * `interactToken` hoặc token không hợp lệ. Vẫn có giá trị khi người dùng không
1613
+ * thêm thẻ.
1614
+ */
1615
+ oaMessageToken?: string;
1616
+ };
1507
1617
  type TempFile = {
1508
1618
  /**
1509
1619
  * Đường dẫn các temp file đã chọn.
@@ -5356,11 +5466,12 @@ declare function addRating(args?: AsyncVoidCallback): Promise<void>;
5356
5466
  /**
5357
5467
  * Lưu voucher vào Ví QR của người dùng.
5358
5468
  *
5359
- * API này gửi dữ liệu voucher từ Mini App về server trung gian. Server trung gian
5360
- * chịu trách nhiệm đăng nhập Ví QR, mã hoá dữ liệu bằng `secureKey`, sau đó trả về
5361
- * deeplink thêm thẻ vào Ví QR. SDK sẽ tự mở deeplink này bằng `openWebview` để đưa
5362
- * người dùng tới màn hình thêm thẻ; deeplink không được trả về cho bên gọi, chỉ
5363
- * trả về `oaMessageToken`.
5469
+ * Khi gọi API, Zalo mở cửa sổ xem trước thẻ ở nửa dưới màn hình như {@link addCard}.
5470
+ * Người dùng chọn "Thêm vào ví" thì voucher được lưu vào Ví QR, chọn "Bỏ qua" hoặc
5471
+ * đóng cửa sổ thì không có thẻ nào được lưu. API hoàn tất khi cửa sổ đóng và trả về
5472
+ * `oaMessageToken`.
5473
+ *
5474
+ * @deprecated Dùng {@link addCard} với `type` là `voucher`.
5364
5475
  *
5365
5476
  * @zaloOnly Chỉ hoạt động khi chạy bên trong ứng dụng Zalo mobile.
5366
5477
  *
@@ -5373,7 +5484,7 @@ declare function addRating(args?: AsyncVoidCallback): Promise<void>;
5373
5484
  * @param {string} merchantLogoUrl Logo OA, dùng làm logo hiển thị trên voucher.
5374
5485
  * @param {string} [conditionDetail] Điều kiện áp dụng chi tiết (phụ).
5375
5486
  * @param {number} [validAt] Thời gian bắt đầu hiệu lực, epoch milliseconds.
5376
- * @param {string} [code] Mã voucher; không truyền thì tự sinh QR OA của merchant.
5487
+ * @param {string} [code] Mã voucher; không truyền thì thẻ không hiển thị mã.
5377
5488
  * @param {"qr_code" | "bar_code"} [display="qr_code"] Loại mã hiển thị.
5378
5489
  * @param {string} [ownerName] Tên khách hàng sở hữu; không truyền thì không hiển thị trên vé.
5379
5490
  * @param {string} [interactToken] Token để merchant gửi tin nhắn không tốn phí.
@@ -5382,9 +5493,9 @@ declare function addRating(args?: AsyncVoidCallback): Promise<void>;
5382
5493
  * @param {VoucherAction[]} [actions] Danh sách CTA hiển thị trên thẻ (tối đa 2);
5383
5494
  * nội dung button (`cta`) tối đa 15 ký tự.
5384
5495
  *
5385
- * @returns {Promise<AddVoucherReturns>} Promise resolve khi tạo thẻ thành công và
5386
- * deeplink đã được mở, trả về `oaMessageToken` (chuỗi rỗng nếu server không
5387
- * trả về); reject kèm mã lỗi từ server nếu thất bại.
5496
+ * @returns {Promise<AddVoucherReturns>} Promise resolve khi cửa sổ đóng lại, kể cả
5497
+ * khi người dùng không lưu thẻ, trả về `oaMessageToken` (chuỗi rỗng nếu không truyền
5498
+ * `interactToken` hoặc token không còn hợp lệ); reject kèm mã lỗi nếu lưu thẻ thất bại.
5388
5499
  *
5389
5500
  * @example Thêm voucher vào Ví QR:
5390
5501
  * ```ts
@@ -5420,6 +5531,56 @@ declare function addRating(args?: AsyncVoidCallback): Promise<void>;
5420
5531
  */
5421
5532
  declare function addVoucher(args: AsyncCallback<AddVoucherReturns> & AddVoucherData): Promise<AddVoucherReturns>;
5422
5533
 
5534
+ /**
5535
+ * API lưu thẻ vào Ví QR của người dùng, hiện hỗ trợ thẻ voucher (ưu đãi).
5536
+ *
5537
+ * Khi gọi API, Zalo mở cửa sổ xem trước thẻ ở nửa dưới màn hình. Người dùng chọn "Thêm vào ví" thì thẻ được lưu vào Ví QR và Zalo hiện thông báo kết quả; lưu thẻ thất bại thì API trả về lỗi. Người dùng chọn "Bỏ qua" hoặc đóng cửa sổ thì không có thẻ nào được lưu; API hoàn tất ngay sau khi cửa sổ được đóng.
5538
+ *
5539
+ * @zaloOnly Chỉ hoạt động khi chạy bên trong ứng dụng Zalo mobile.
5540
+ *
5541
+ * @param {CardType} type Loại thẻ, hiện chỉ hỗ trợ `voucher`.
5542
+ * @param {AddCardData} data Dữ liệu thẻ tương ứng với `type`. Với `voucher`, các trường bắt buộc là `title`, `name`, `meta.merchantName`, `meta.merchantOaId`, `meta.condition` và `meta.expiredAt`; xem {@link VoucherCardData} để biết toàn bộ các trường.
5543
+ * @param {string} [interactToken] Token để Mini App gửi tin nhắn OA cho người dùng không tốn phí, lấy từ callback `onDataReceived` của {@link showFunctionButtonWidget}.
5544
+ *
5545
+ * @returns {AddCardReturns} `oaMessageToken` để gửi tin nhắn OA cho người dùng. Không có trường `oaMessageToken` nếu không truyền `interactToken` hoặc token không còn hợp lệ; nếu có, token vẫn được trả về kể cả người dùng không thêm vào ví.
5546
+ *
5547
+ * @example Thêm voucher vào Ví QR:
5548
+ * ```ts
5549
+ * await addCard({
5550
+ * type: "voucher",
5551
+ * data: {
5552
+ * title: "The Face Shop",
5553
+ * name: "Giảm 50% giá trị đơn hàng",
5554
+ * avatarUrl: "https://static.example.com/logo.png",
5555
+ * meta: {
5556
+ * code: "SUMMER50",
5557
+ * merchantName: "The Face Shop",
5558
+ * merchantOaId: "2646373759294038927",
5559
+ * condition: "Áp dụng cho hóa đơn trên 200.000đ",
5560
+ * expiredAt: 1743440399000,
5561
+ * },
5562
+ * },
5563
+ * });
5564
+ * ```
5565
+ *
5566
+ * @example Gửi kèm `interactToken` lấy từ Function Button Widget:
5567
+ * ```ts
5568
+ * showFunctionButtonWidget({
5569
+ * id: "orderButton",
5570
+ * type: "ORDER",
5571
+ * text: "Tạo đơn hàng",
5572
+ * onDataReceived: async (interactToken) => {
5573
+ * const { oaMessageToken } = await addCard({
5574
+ * type: "voucher",
5575
+ * data: voucherCardData,
5576
+ * interactToken,
5577
+ * });
5578
+ * },
5579
+ * });
5580
+ * ```
5581
+ */
5582
+ declare function addCard(args: AsyncCallback<AddCardReturns> & AddCardParams): Promise<AddCardReturns>;
5583
+
5423
5584
  declare const interactOAArgs$1: ZodObject<{
5424
5585
  oaId: ZodString;
5425
5586
  }, "strip", ZodTypeAny, {
@@ -6372,6 +6533,7 @@ declare const otherApis: {
6372
6533
  requestSendNotification: typeof requestSendNotification;
6373
6534
  addRating: typeof addRating;
6374
6535
  addVoucher: typeof addVoucher;
6536
+ addCard: typeof addCard;
6375
6537
  interactOA: typeof interactOA;
6376
6538
  interactOa: typeof interactOA;
6377
6539
  isAllowedInteractWithOA: typeof checkIsAllowedInteractWithOA;
@@ -6438,4 +6600,4 @@ declare const otherApis: {
6438
6600
  ZMACameraImp: typeof ZMACameraImp;
6439
6601
  };
6440
6602
 
6441
- export { Action, AddVoucherData, AddVoucherReturns, AndroidBottomNavigationBarType, AppError, AsyncCallback, AsyncCallbackFailObject, AsyncProgressCallback, AsyncVoidCallback, AuthorizeType, CameraEvents, CameraParams, ChatType, CheckStateBioAuthenticationReturns, CheckTransactionReturns, CheckZaloCameraPermissionReturns, CheckoutKit, CheckoutPopupOpenParams, CheckoutPopupResponseData, CheckoutSDK, ChooseImageReturns, Common, ContextInfo, CreateOrderIAPReturns, CreateOrderReturns, Events as EventName, Events, FacingMode, FileInfo, FunctionProps, GetAppInfoReturns, GetAuthCodeReturns, GetBeaconDiscoveryReturns, GetDeviceInfoReturn, GetFileInfoReturns, GetLocationReturns, GetNetworkTypeReturns, GetPhoneNumberReturns, GetSettingReturn, GetStorageReturns, GetUserInfoReturns, GetZPITokenReturns, IAPMethodType, IAPPayType, IAPPayTypeType, IOSSafeAreaBottomType, IsSupportReturns, JumpStatus, KeepScreenReturns, LFSStorage, ListFile, LogData, MediaConstraints, MediaDevice, MediaPickerType, NativeCallBackData, NetworkType, OpenBioAuthenticationReturns, OpenMediaPickerReturns, OpenPostFeedReturns, OpenProfilePickerReturns, OpenProfilePickerType, OpenShareSheetReturns, OpenWebviewReturns, OrientationType, Payment, PhotoConstraint, PhotoFormat, PhotoFrame, PhotoQuality, PickAttr, PickedProfile, PlatformType, PostFeedType, ProfileInfo, ProfileType, ProrationMode, ProrationModeType, RemoveStorageReturns, RequestCameraPermissionReturns, SaveFileReturns, ScanNFCType, ScanQRCodeReturns, SelectPaymentMethodReturns, SetStorageReturns, ShareSheetType, StatusBarType, StorageInfo, StreamType, SystemInfo, TempFile, TextAlignType, UserInfo, VibrateType, VoucherAction, VoucherActionType, VoucherDisplayType, ZMACamera, ZMACameraImp, addRating, addVoucher, authorize, checkNFC, checkStateBioAuthentication, checkTransaction, checkZaloCameraPermission, chooseImage, clearStorage, closeApp, closeLoading, configAppView, connectWifi, createCameraContext, createOrder, createOrderIAP, createShortcut, otherApis as default, displayAd, downloadFile, events, favoriteApp, followOA, getAccessToken, getAppInfo, getAuthCode, getBeacons, getContext, getContextAsync, getDeviceId, getDeviceIdAsync, getDeviceInfo, getEntrySource, getIDToken, getLocation, getNetworkType, getPhoneNumber, getRouteParams, getSetting, getShareableLink, getStorage, getStorageInfo, getSystemInfo, getUserID, getUserInfo, getVersion, getZPIToken, hideKeyboard, iBeaconInfo, interactOA, interactOA as interactOa, checkIsAllowedInteractWithOA as isAllowedInteractWithOA, keepScreen, loadAd, login, minimizeApp, nativeStorage, offConfirmToExit, offKeepScreen, onCallbackData, onConfirmToExit, onKeepScreen, onNetworkStatusChange, openBioAuthentication, openChat, openDocument, openGroupList, openMediaPicker, openMiniApp, openOutApp, openPermissionSetting, openPhone, openPostFeed, openProfile, openProfilePicker, openSMS, openShareSheet, openWebview, purchase, refreshAd, removeStorage, requestCameraPermission, requestSendNotification, requestUpdateZalo, saveImageToGallery, saveVideoToGallery, scanNFC, scanQRCode, selectPaymentMethod, sendDataToPreviousMiniApp, setAccessToken, setAndroidBottomNavigationBar, setIOSBottomSafeArea, setNavigationBarColor, setNavigationBarLeftButton, setNavigationBarTitle, setStatusBar, setStorage, setupAd, showCustomOAWidget, showFunctionButtonWidget, showOAWidget, showToast, startBeaconDiscovery, stopBeaconDiscovery, trackingManager, unfollowOA, vibrate, viewOAQr };
6603
+ export { Action, AddCardData, AddCardParams, AddCardReturns, AddVoucherData, AddVoucherReturns, AndroidBottomNavigationBarType, AppError, AsyncCallback, AsyncCallbackFailObject, AsyncProgressCallback, AsyncVoidCallback, AuthorizeType, CameraEvents, CameraParams, CardType, ChatType, CheckStateBioAuthenticationReturns, CheckTransactionReturns, CheckZaloCameraPermissionReturns, CheckoutKit, CheckoutPopupOpenParams, CheckoutPopupResponseData, CheckoutSDK, ChooseImageReturns, Common, ContextInfo, CreateOrderIAPReturns, CreateOrderReturns, Events as EventName, Events, FacingMode, FileInfo, FunctionProps, GetAppInfoReturns, GetAuthCodeReturns, GetBeaconDiscoveryReturns, GetDeviceInfoReturn, GetFileInfoReturns, GetLocationReturns, GetNetworkTypeReturns, GetPhoneNumberReturns, GetSettingReturn, GetStorageReturns, GetUserInfoReturns, GetZPITokenReturns, IAPMethodType, IAPPayType, IAPPayTypeType, IOSSafeAreaBottomType, IsSupportReturns, JumpStatus, KeepScreenReturns, LFSStorage, ListFile, LogData, MediaConstraints, MediaDevice, MediaPickerType, NativeCallBackData, NetworkType, OpenBioAuthenticationReturns, OpenMediaPickerReturns, OpenPostFeedReturns, OpenProfilePickerReturns, OpenProfilePickerType, OpenShareSheetReturns, OpenWebviewReturns, OrientationType, Payment, PhotoConstraint, PhotoFormat, PhotoFrame, PhotoQuality, PickAttr, PickedProfile, PlatformType, PostFeedType, ProfileInfo, ProfileType, ProrationMode, ProrationModeType, RemoveStorageReturns, RequestCameraPermissionReturns, SaveFileReturns, ScanNFCType, ScanQRCodeReturns, SelectPaymentMethodReturns, SetStorageReturns, ShareSheetType, StatusBarType, StorageInfo, StreamType, SystemInfo, TempFile, TextAlignType, UserInfo, VibrateType, VoucherAction, VoucherActionType, VoucherCardData, VoucherCardMeta, VoucherDisplayType, ZMACamera, ZMACameraImp, addCard, addRating, addVoucher, authorize, checkNFC, checkStateBioAuthentication, checkTransaction, checkZaloCameraPermission, chooseImage, clearStorage, closeApp, closeLoading, configAppView, connectWifi, createCameraContext, createOrder, createOrderIAP, createShortcut, otherApis as default, displayAd, downloadFile, events, favoriteApp, followOA, getAccessToken, getAppInfo, getAuthCode, getBeacons, getContext, getContextAsync, getDeviceId, getDeviceIdAsync, getDeviceInfo, getEntrySource, getIDToken, getLocation, getNetworkType, getPhoneNumber, getRouteParams, getSetting, getShareableLink, getStorage, getStorageInfo, getSystemInfo, getUserID, getUserInfo, getVersion, getZPIToken, hideKeyboard, iBeaconInfo, interactOA, interactOA as interactOa, checkIsAllowedInteractWithOA as isAllowedInteractWithOA, keepScreen, loadAd, login, minimizeApp, nativeStorage, offConfirmToExit, offKeepScreen, onCallbackData, onConfirmToExit, onKeepScreen, onNetworkStatusChange, openBioAuthentication, openChat, openDocument, openGroupList, openMediaPicker, openMiniApp, openOutApp, openPermissionSetting, openPhone, openPostFeed, openProfile, openProfilePicker, openSMS, openShareSheet, openWebview, purchase, refreshAd, removeStorage, requestCameraPermission, requestSendNotification, requestUpdateZalo, saveImageToGallery, saveVideoToGallery, scanNFC, scanQRCode, selectPaymentMethod, sendDataToPreviousMiniApp, setAccessToken, setAndroidBottomNavigationBar, setIOSBottomSafeArea, setNavigationBarColor, setNavigationBarLeftButton, setNavigationBarTitle, setStatusBar, setStorage, setupAd, showCustomOAWidget, showFunctionButtonWidget, showOAWidget, showToast, startBeaconDiscovery, stopBeaconDiscovery, trackingManager, unfollowOA, vibrate, viewOAQr };