ionic-vhframeworks 10.8.1 → 10.8.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.
|
@@ -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,155 @@ 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_1day,
|
|
204
|
+
"inapp_xprinterpos_main_standard_1month",
|
|
205
|
+
"inapp_xprinterpos_main_standard_12month",
|
|
206
|
+
"inapp_xprinterpos_main_pro_1month",
|
|
207
|
+
"inapp_xprinterpos_main_pro_12month",
|
|
208
|
+
"inapp_xprinterpos_main_super_pro_1month",
|
|
209
|
+
"inapp_xprinterpos_main_super_pro_12month",
|
|
210
|
+
];
|
|
211
|
+
products: Array<{ id: string; title: string; desc: string; price: string; saveTag?: string }> = [];
|
|
212
|
+
selectedPlanIndex: number = 0;
|
|
213
|
+
private productsSub?: Subscription;
|
|
214
|
+
|
|
215
|
+
constructor(private iap2Service: Iap2Service) {}
|
|
216
|
+
|
|
217
|
+
ngOnInit(): void {
|
|
218
|
+
this.iap2Service.initPurchase(this.PRODUCT_IDS);
|
|
219
|
+
this.productsSub = this.iap2Service.products$.subscribe((tmp: any[]) => {
|
|
220
|
+
this.products = (tmp || []).map((item: any) => {
|
|
221
|
+
let price: string = '';
|
|
222
|
+
if (Array.isArray(item.offers) && item.offers.length > 0 && Array.isArray(item.offers[0].pricingPhases) && item.offers[0].pricingPhases.length > 0) {
|
|
223
|
+
price = item.offers[0].pricingPhases[0].price;
|
|
224
|
+
}
|
|
225
|
+
return {
|
|
226
|
+
id: item.id as string,
|
|
227
|
+
title: item.title as string,
|
|
228
|
+
desc: item.description as string,
|
|
229
|
+
price: price,
|
|
230
|
+
};
|
|
231
|
+
});
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
ngOnDestroy(): void {
|
|
236
|
+
this.productsSub?.unsubscribe();
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
selectPlan(i: number): void {
|
|
240
|
+
this.selectedPlanIndex = i;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
purchaseSelectedPlan(): void {
|
|
244
|
+
const selectedProduct = this.products[this.selectedPlanIndex];
|
|
245
|
+
if (selectedProduct) {
|
|
246
|
+
console.log("==> product id", selectedProduct.id);
|
|
247
|
+
this.iap2Service.purchase(selectedProduct.id, 'oIpCK6jgMxLHOPrwV1Sm');
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
*/
|
|
252
|
+
export declare class Iap2Service {
|
|
253
|
+
private platform;
|
|
254
|
+
private vhMGDB_auth;
|
|
255
|
+
/**
|
|
256
|
+
* 🔸 Danh sách ID sản phẩm trên Store (Google / Apple)
|
|
257
|
+
*
|
|
258
|
+
* 👉 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.
|
|
259
|
+
* 👉 Nếu sai, store sẽ không nhận diện được sản phẩm.
|
|
260
|
+
*/
|
|
261
|
+
private PRODUCT_IDS;
|
|
262
|
+
private app_product;
|
|
263
|
+
private id_branch;
|
|
264
|
+
/**
|
|
265
|
+
* 🔹 Biến lưu instance store (được plugin quản lý)
|
|
266
|
+
* - Là trung tâm quản lý mọi giao dịch mua hàng
|
|
267
|
+
*/
|
|
268
|
+
private store?;
|
|
269
|
+
/** Observable phát danh sách sản phẩm đã load */
|
|
270
|
+
private productsSubject;
|
|
271
|
+
products$: Observable<any[]>;
|
|
272
|
+
constructor(platform: Platform, vhMGDB_auth: VhMGDB_auth);
|
|
273
|
+
/**
|
|
274
|
+
* 🚀 Khởi tạo hệ thống In-App Purchase
|
|
275
|
+
* -----------------------------------
|
|
276
|
+
* Thực hiện tuần tự:
|
|
277
|
+
* 1️⃣ Chờ thiết bị sẵn sàng (Platform Ready)
|
|
278
|
+
* 2️⃣ Lấy instance `CdvPurchase.store`
|
|
279
|
+
* 3️⃣ Xác định nền tảng (Android hoặc iOS)
|
|
280
|
+
* 4️⃣ Đăng ký sản phẩm vào store
|
|
281
|
+
* 5️⃣ Gắn các event handler xử lý giao dịch
|
|
282
|
+
* 6️⃣ Khởi tạo và làm mới store
|
|
283
|
+
* 7️⃣ Chờ store sẵn sàng hoàn toàn (store.ready())
|
|
284
|
+
* PRODUCT_IDS: string[] = [
|
|
285
|
+
"store_main_package_standard_1month",
|
|
286
|
+
"store_main_package_standard_12month",
|
|
287
|
+
"store_main_package_standard_24month",
|
|
288
|
+
"store_main_package_standard_60month",
|
|
289
|
+
];
|
|
290
|
+
*/
|
|
291
|
+
initPurchase(PRODUCT_IDS: any): void;
|
|
292
|
+
/**
|
|
293
|
+
* 🧠 Gắn các event handler xử lý luồng mua hàng
|
|
294
|
+
* ---------------------------------------------
|
|
295
|
+
* Mỗi bước của giao dịch (approved, verified, refunded, expired, rejected, error)
|
|
296
|
+
* đều được log ra console để dev theo dõi và xử lý nghiệp vụ phía backend nếu cần.
|
|
297
|
+
*/
|
|
298
|
+
private registerHandlersForPurchase;
|
|
299
|
+
/**
|
|
300
|
+
* Thực hiện mua sản phẩm
|
|
301
|
+
* @param app_product - sản phẩm trên chplay, appstore cần mua
|
|
302
|
+
*/
|
|
303
|
+
purchase(app_product: any, id_branch: string): void;
|
|
304
|
+
/**
|
|
305
|
+
* Refresh thông tin sản phẩm từ store
|
|
306
|
+
* Cập nhật giá cả và thông tin sản phẩm mới nhất
|
|
307
|
+
*/
|
|
308
|
+
refreshPurchase(): void;
|
|
309
|
+
/**
|
|
310
|
+
* Lấy danh sách các sản phẩm đã được đăng ký
|
|
311
|
+
* @returns Mảng các sản phẩm đã được load thành công
|
|
312
|
+
*/
|
|
313
|
+
getRegisteredProducts(): any[];
|
|
314
|
+
/**
|
|
315
|
+
* Khôi phục các giao dịch đã mua trước đó
|
|
316
|
+
* Hữu ích khi user cài đặt lại app hoặc chuyển thiết bị
|
|
317
|
+
*/
|
|
318
|
+
restorePurchase(): void;
|
|
319
|
+
private create_Payment_Apple_Google_Pay;
|
|
320
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<Iap2Service, never>;
|
|
321
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<Iap2Service>;
|
|
322
|
+
}
|
|
173
323
|
export declare class VhAlgorithm {
|
|
174
324
|
private platform;
|
|
175
325
|
private file;
|
|
@@ -6518,7 +6668,21 @@ export declare class VhQueryCafe {
|
|
|
6518
6668
|
*/
|
|
6519
6669
|
getLicenseKEYs(query: any, projection?: object, sort?: object, limit?: number): Promise<unknown>;
|
|
6520
6670
|
/**
|
|
6521
|
-
|
|
6671
|
+
* Lấy về danh sách các ngân hàng (kèm logo) mà vietqr hỗ trợ tạo mã QR
|
|
6672
|
+
* @example:
|
|
6673
|
+
* this.vhQueryCafe.vietqr_getBanks()
|
|
6674
|
+
.then((rsp:any)=>{
|
|
6675
|
+
if(rsp.vcode === 0){
|
|
6676
|
+
}
|
|
6677
|
+
}, error=>{
|
|
6678
|
+
console.log(error)
|
|
6679
|
+
})
|
|
6680
|
+
* @returns Promise => rsp ={vcode, msg, data(array)} / error
|
|
6681
|
+
* vcode == 0: success
|
|
6682
|
+
*/
|
|
6683
|
+
vietqr_getBanks(): Promise<unknown>;
|
|
6684
|
+
/**
|
|
6685
|
+
* Tạo mã QR cho Shop quét thanh toán vào tài khoản ngân hàng đã đăng ký Casso
|
|
6522
6686
|
* @example:
|
|
6523
6687
|
* this.vhQueryCafe.vietqr_generateQR('0909925354', 'LE DUC HUY', '970422', 'compact2', '674fd94a9ace7267deb685fd', 99000)
|
|
6524
6688
|
.then((rsp:any)=>{
|
|
@@ -17488,7 +17652,21 @@ export declare class VhQuerySales {
|
|
|
17488
17652
|
*/
|
|
17489
17653
|
getLicenseKEYs(query: any, projection?: object, sort?: object, limit?: number): Promise<unknown>;
|
|
17490
17654
|
/**
|
|
17491
|
-
|
|
17655
|
+
* Lấy về danh sách các ngân hàng (kèm logo) mà vietqr hỗ trợ tạo mã QR
|
|
17656
|
+
* @example:
|
|
17657
|
+
* this.vhQuerySales.vietqr_getBanks()
|
|
17658
|
+
.then((rsp:any)=>{
|
|
17659
|
+
if(rsp.vcode === 0){
|
|
17660
|
+
}
|
|
17661
|
+
}, error=>{
|
|
17662
|
+
console.log(error)
|
|
17663
|
+
})
|
|
17664
|
+
* @returns Promise => rsp ={vcode, msg, data(array)} / error
|
|
17665
|
+
* vcode == 0: success
|
|
17666
|
+
*/
|
|
17667
|
+
vietqr_getBanks(): Promise<unknown>;
|
|
17668
|
+
/**
|
|
17669
|
+
* Tạo mã QR cho Shop quét thanh toán vào tài khoản ngân hàng đã đăng ký Casso
|
|
17492
17670
|
* @example:
|
|
17493
17671
|
* this.vhQuerySales.vietqr_generateQR('0909925354', 'LE DUC HUY', '970422', 'compact2', '674fd94a9ace7267deb685fd', 99000)
|
|
17494
17672
|
.then((rsp:any)=>{
|
|
@@ -20646,7 +20824,7 @@ export declare class VhQueryDealer {
|
|
|
20646
20824
|
*/
|
|
20647
20825
|
vietqr_getBanks(): Promise<unknown>;
|
|
20648
20826
|
/**
|
|
20649
|
-
* Tạo mã QR cho
|
|
20827
|
+
* Tạo mã QR cho Shop quét thanh toán vào tài khoản ngân hàng đã đăng ký Casso
|
|
20650
20828
|
* @example:
|
|
20651
20829
|
* this.vhQueryDealer.vietqr_generateQR('0909925354', 'LE DUC HUY', '970422', 'compact2', '674fd94a9ace7267deb685fd', 99000)
|
|
20652
20830
|
.then((rsp:any)=>{
|