ionic-vhframeworks 10.8.1 → 10.8.2

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.
@@ -27,6 +27,7 @@ import { BluetoothSerial } from '@ionic-native/bluetooth-serial/ngx';
27
27
  import { TranslateLoader, TranslateService } from '@ngx-translate/core';
28
28
  import { HttpClient } from '@angular/common/http';
29
29
  import { MyUploadImageAdapter } from "./my-class";
30
+ import "cordova-plugin-purchase";
30
31
  import * as i0 from "@angular/core";
31
32
  export declare class VhIDB {
32
33
  private db;
@@ -170,6 +171,154 @@ export declare class VhEventMediator {
170
171
  static ɵfac: i0.ɵɵFactoryDeclaration<VhEventMediator, never>;
171
172
  static ɵprov: i0.ɵɵInjectableDeclaration<VhEventMediator>;
172
173
  }
174
+ /**
175
+ * 🧩 Iap2Service
176
+ * -------------------------
177
+ * Service quản lý toàn bộ luồng In-App Purchase (IAP)
178
+ * Sử dụng plugin: `cordova-plugin-purchase`
179
+ *
180
+ * 👉 Hỗ trợ cả:
181
+ * - Android (Google Play)
182
+ * - iOS (App Store)
183
+ *
184
+ * Các nhiệm vụ chính:
185
+ * - Khởi tạo store
186
+ * - Đăng ký danh sách sản phẩm
187
+ * - Theo dõi sự kiện mua hàng
188
+ * - Xử lý các trạng thái giao dịch (approved, verified, expired, ...)
189
+ * - Cho phép refresh / restore / purchase thủ công
190
+ */
191
+ /*************************** CÁCH DÙNG FW Iap2Service *******************************************
192
+ import { Component, OnInit, OnDestroy } from '@angular/core';
193
+ import { Iap2Service } from '../services/iap2.service';
194
+ import { Subscription } from 'rxjs';
195
+
196
+ @Component({
197
+ selector: 'app-home',
198
+ templateUrl: 'home.page.html',
199
+ styleUrls: ['home.page.scss'],
200
+ })
201
+ export class HomePage implements OnInit, OnDestroy {
202
+ private PRODUCT_IDS: string[] = [
203
+ "inapp_xprinterpos_main_standard_1month",
204
+ "inapp_xprinterpos_main_standard_12month",
205
+ "inapp_xprinterpos_main_pro_1month",
206
+ "inapp_xprinterpos_main_pro_12month",
207
+ "inapp_xprinterpos_main_super_pro_1month",
208
+ "inapp_xprinterpos_main_super_pro_12month",
209
+ ];
210
+ products: Array<{ id: string; title: string; desc: string; price: string; saveTag?: string }> = [];
211
+ selectedPlanIndex: number = 0;
212
+ private productsSub?: Subscription;
213
+
214
+ constructor(private iap2Service: Iap2Service) {}
215
+
216
+ ngOnInit(): void {
217
+ this.iap2Service.initPurchase(this.PRODUCT_IDS);
218
+ this.productsSub = this.iap2Service.products$.subscribe((tmp: any[]) => {
219
+ this.products = (tmp || []).map((item: any) => {
220
+ let price: string = '';
221
+ if (Array.isArray(item.offers) && item.offers.length > 0 && Array.isArray(item.offers[0].pricingPhases) && item.offers[0].pricingPhases.length > 0) {
222
+ price = item.offers[0].pricingPhases[0].price;
223
+ }
224
+ return {
225
+ id: item.id as string,
226
+ title: item.title as string,
227
+ desc: item.description as string,
228
+ price: price,
229
+ };
230
+ });
231
+ });
232
+ }
233
+
234
+ ngOnDestroy(): void {
235
+ this.productsSub?.unsubscribe();
236
+ }
237
+
238
+ selectPlan(i: number): void {
239
+ this.selectedPlanIndex = i;
240
+ }
241
+
242
+ purchaseSelectedPlan(): void {
243
+ const selectedProduct = this.products[this.selectedPlanIndex];
244
+ if (selectedProduct) {
245
+ console.log("==> product id", selectedProduct.id);
246
+ this.iap2Service.purchase(selectedProduct.id);
247
+ }
248
+ }
249
+ }
250
+ */
251
+ export declare class Iap2Service {
252
+ private platform;
253
+ private vhMGDB_auth;
254
+ /**
255
+ * 🔸 Danh sách ID sản phẩm trên Store (Google / Apple)
256
+ *
257
+ * 👉 Các ID này phải trùng với phần bạn cấu hình trên Google Play Console hoặc App Store Connect.
258
+ * 👉 Nếu sai, store sẽ không nhận diện được sản phẩm.
259
+ */
260
+ private PRODUCT_IDS;
261
+ private productID;
262
+ private id_branch;
263
+ /**
264
+ * 🔹 Biến lưu instance store (được plugin quản lý)
265
+ * - Là trung tâm quản lý mọi giao dịch mua hàng
266
+ */
267
+ private store?;
268
+ /** Observable phát danh sách sản phẩm đã load */
269
+ private productsSubject;
270
+ products$: Observable<any[]>;
271
+ constructor(platform: Platform, vhMGDB_auth: VhMGDB_auth);
272
+ /**
273
+ * 🚀 Khởi tạo hệ thống In-App Purchase
274
+ * -----------------------------------
275
+ * Thực hiện tuần tự:
276
+ * 1️⃣ Chờ thiết bị sẵn sàng (Platform Ready)
277
+ * 2️⃣ Lấy instance `CdvPurchase.store`
278
+ * 3️⃣ Xác định nền tảng (Android hoặc iOS)
279
+ * 4️⃣ Đăng ký sản phẩm vào store
280
+ * 5️⃣ Gắn các event handler xử lý giao dịch
281
+ * 6️⃣ Khởi tạo và làm mới store
282
+ * 7️⃣ Chờ store sẵn sàng hoàn toàn (store.ready())
283
+ * PRODUCT_IDS: string[] = [
284
+ "store_main_package_standard_1month",
285
+ "store_main_package_standard_12month",
286
+ "store_main_package_standard_24month",
287
+ "store_main_package_standard_60month",
288
+ ];
289
+ */
290
+ initPurchase(PRODUCT_IDS: any): void;
291
+ /**
292
+ * 🧠 Gắn các event handler xử lý luồng mua hàng
293
+ * ---------------------------------------------
294
+ * Mỗi bước của giao dịch (approved, verified, refunded, expired, rejected, error)
295
+ * đều được log ra console để dev theo dõi và xử lý nghiệp vụ phía backend nếu cần.
296
+ */
297
+ private registerHandlersForPurchase;
298
+ /**
299
+ * Thực hiện mua sản phẩm
300
+ * @param productID - ID của sản phẩm cần mua
301
+ */
302
+ purchase(productID: any, id_branch: string): void;
303
+ /**
304
+ * Refresh thông tin sản phẩm từ store
305
+ * Cập nhật giá cả và thông tin sản phẩm mới nhất
306
+ */
307
+ refreshPurchase(): void;
308
+ /**
309
+ * Lấy danh sách các sản phẩm đã được đăng ký
310
+ * @returns Mảng các sản phẩm đã được load thành công
311
+ */
312
+ getRegisteredProducts(): any[];
313
+ /**
314
+ * Khôi phục các giao dịch đã mua trước đó
315
+ * Hữu ích khi user cài đặt lại app hoặc chuyển thiết bị
316
+ */
317
+ restorePurchase(): void;
318
+ private create_Payment_Apple_Google_Pay;
319
+ static ɵfac: i0.ɵɵFactoryDeclaration<Iap2Service, never>;
320
+ static ɵprov: i0.ɵɵInjectableDeclaration<Iap2Service>;
321
+ }
173
322
  export declare class VhAlgorithm {
174
323
  private platform;
175
324
  private file;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ionic-vhframeworks",
3
- "version": "10.8.1",
3
+ "version": "10.8.2",
4
4
  "peerDependencies": {
5
5
  "@angular/common": "^12.2.0",
6
6
  "@angular/core": "^12.2.0"