myxl-core 1.0.0 → 1.0.1

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.
Files changed (38) hide show
  1. package/dist/ciam.d.ts +2 -2
  2. package/dist/ciam.js +5 -5
  3. package/dist/device.d.ts +2 -2
  4. package/dist/device.js +5 -5
  5. package/dist/index.d.ts +2 -3
  6. package/dist/index.js +216 -142
  7. package/dist/lib/decoy.d.ts +7 -3
  8. package/dist/lib/decoy.js +7 -86
  9. package/dist/lib/payment.d.ts +2 -2
  10. package/dist/lib/utils.d.ts +1 -0
  11. package/dist/lib/utils.js +6 -0
  12. package/dist/payments/ewallet.d.ts +3 -11
  13. package/dist/payments/ewallet.js +155 -90
  14. package/dist/payments/index.d.ts +5 -1
  15. package/dist/payments/index.js +270 -94
  16. package/dist/payments/{balance.d.ts → method/balance.d.ts} +1 -1
  17. package/dist/payments/{balance.js → method/balance.js} +1 -1
  18. package/dist/payments/method/ewallet.d.ts +11 -0
  19. package/dist/payments/method/ewallet.js +373 -0
  20. package/dist/payments/method/index.d.ts +3 -0
  21. package/dist/payments/method/index.js +632 -0
  22. package/dist/payments/method/qris.d.ts +2 -0
  23. package/dist/payments/method/qris.js +378 -0
  24. package/dist/payments/pulsa-decoy-v2.d.ts +3 -0
  25. package/dist/payments/pulsa-decoy-v2.js +469 -0
  26. package/dist/payments/pulsa-decoy.d.ts +7 -0
  27. package/dist/payments/pulsa-decoy.js +464 -0
  28. package/dist/payments/pulsa.d.ts +2 -0
  29. package/dist/payments/pulsa.js +452 -0
  30. package/dist/payments/qris-decoy-v2.d.ts +2 -0
  31. package/dist/payments/qris-decoy-v2.js +442 -0
  32. package/dist/payments/qris-decoy.d.ts +4 -0
  33. package/dist/payments/qris-decoy.js +437 -0
  34. package/dist/payments/qris.d.ts +2 -2
  35. package/dist/payments/qris.js +147 -82
  36. package/package.json +41 -9
  37. package/dist/payments/decoy.d.ts +0 -1
  38. package/dist/payments/decoy.js +0 -6
package/dist/ciam.d.ts CHANGED
@@ -9,7 +9,7 @@ export type AuthToken = {
9
9
  session_state: string;
10
10
  scope: string;
11
11
  };
12
- export declare function getNewToken(refreshToken: string, axDeviceId: string, axFingerprint: string): Promise<AuthToken>;
12
+ export declare function refreshToken(refreshToken: string, axDeviceId: string, axFingerprint: string): Promise<AuthToken>;
13
13
  export type Profile = {
14
14
  age: number;
15
15
  alternate_phone_number: string;
@@ -254,6 +254,6 @@ export type MyPackagesResponse = {
254
254
  show_autobuy_banner: boolean;
255
255
  };
256
256
  };
257
- export declare function fetchMyPackages({ idToken }: {
257
+ export declare function getMyPackages({ idToken }: {
258
258
  idToken: string;
259
259
  }): Promise<MyPackagesResponse>;
package/dist/ciam.js CHANGED
@@ -256,7 +256,7 @@ init_utils();
256
256
  import axios2 from "axios";
257
257
  import { DateTime as DateTime2, FixedOffsetZone } from "luxon";
258
258
  import { v4 as uuidv42 } from "uuid";
259
- async function getNewToken(refreshToken, axDeviceId, axFingerprint) {
259
+ async function refreshToken(refreshToken2, axDeviceId, axFingerprint) {
260
260
  try {
261
261
  const url = `${BASE_CIAM_URL}/realms/xl-ciam/protocol/openid-connect/token`;
262
262
  const gmt7Zone = FixedOffsetZone.instance(420);
@@ -278,7 +278,7 @@ async function getNewToken(refreshToken, axDeviceId, axFingerprint) {
278
278
  };
279
279
  const data = new URLSearchParams({
280
280
  grant_type: "refresh_token",
281
- refresh_token: refreshToken
281
+ refresh_token: refreshToken2
282
282
  });
283
283
  const resp = await axios2.post(url, data.toString(), {
284
284
  headers,
@@ -331,7 +331,7 @@ async function checkQuota(msisdn) {
331
331
  const response = await axios2.get(url);
332
332
  return response.data;
333
333
  }
334
- async function fetchMyPackages({ idToken }) {
334
+ async function getMyPackages({ idToken }) {
335
335
  const path = "api/v8/packages/quota-details";
336
336
  const rawPayload = {
337
337
  is_enterprise: false,
@@ -341,11 +341,11 @@ async function fetchMyPackages({ idToken }) {
341
341
  return await sendApiRequest(path, rawPayload, idToken, "POST");
342
342
  }
343
343
  export {
344
+ refreshToken,
344
345
  getTieringInfo,
345
346
  getRedeemables,
346
347
  getProfile,
347
- getNewToken,
348
+ getMyPackages,
348
349
  getBalance,
349
- fetchMyPackages,
350
350
  checkQuota
351
351
  };
package/dist/device.d.ts CHANGED
@@ -9,14 +9,14 @@ export type DeviceInfo = {
9
9
  android_release: string;
10
10
  msisdn: string;
11
11
  };
12
- export declare function buildFingerprintPlain(dev: DeviceInfo): string;
12
+ export declare function buildFingerprintPlaintext(dev: DeviceInfo): string;
13
13
  export declare function axFingerprint(dev: DeviceInfo, secretKey32Ascii: string): string;
14
14
  /**
15
15
  * Equivalent to Python `load_ax_fp()`
16
16
  * - kalau file ada & isinya tidak kosong -> return isinya
17
17
  * - kalau tidak -> generate DeviceInfo random, encrypt, simpan, return
18
18
  */
19
- export declare function generateAxFp(params?: {
19
+ export declare function generateAxFingerprint(params?: {
20
20
  ip?: string;
21
21
  msisdn?: string;
22
22
  }): string;
package/dist/device.js CHANGED
@@ -57,7 +57,7 @@ import crypto from "crypto";
57
57
  function randint(min, max) {
58
58
  return Math.floor(Math.random() * (max - min + 1)) + min;
59
59
  }
60
- function buildFingerprintPlain(dev) {
60
+ function buildFingerprintPlaintext(dev) {
61
61
  return `${dev.manufacturer}|${dev.model}|${dev.lang}|${dev.resolution}|` + `${dev.tz_short}|${dev.ip}|${dev.font_scale}|Android ${dev.android_release}|${dev.msisdn}`;
62
62
  }
63
63
  function pkcs7Pad(buf, blockSize = 16) {
@@ -72,14 +72,14 @@ function axFingerprint(dev, secretKey32Ascii) {
72
72
  throw new Error(`AX_FP_KEY invalid length: got ${key.length} bytes. Expected 16/24/32 ASCII chars.`);
73
73
  }
74
74
  const iv = Buffer.alloc(16, 0);
75
- const pt = Buffer.from(buildFingerprintPlain(dev), "utf8");
75
+ const pt = Buffer.from(buildFingerprintPlaintext(dev), "utf8");
76
76
  const padded = pkcs7Pad(pt, 16);
77
77
  const cipher = crypto.createCipheriv(key.length === 16 ? "aes-128-cbc" : key.length === 24 ? "aes-192-cbc" : "aes-256-cbc", key, iv);
78
78
  cipher.setAutoPadding(false);
79
79
  const ct = Buffer.concat([cipher.update(padded), cipher.final()]);
80
80
  return ct.toString("base64");
81
81
  }
82
- function generateAxFp(params) {
82
+ function generateAxFingerprint(params) {
83
83
  const dev = {
84
84
  manufacturer: "samsung" + String(randint(1000, 9999)),
85
85
  model: "SM-N93" + String(randint(1000, 9999)),
@@ -101,7 +101,7 @@ function getAxDeviceId(axFp) {
101
101
  }
102
102
  export {
103
103
  getAxDeviceId,
104
- generateAxFp,
105
- buildFingerprintPlain,
104
+ generateAxFingerprint,
105
+ buildFingerprintPlaintext,
106
106
  axFingerprint
107
107
  };
package/dist/index.d.ts CHANGED
@@ -10,10 +10,9 @@ export * as Notification from "./notification";
10
10
  export * as Package from "./package";
11
11
  export * as Payments from "./payments";
12
12
  export * as Profile from "./profile";
13
- export * as Types from "./@types/payment";
13
+ export * as PaymentTypes from "./@types/payment";
14
14
  export * as Utils from "./lib/utils";
15
15
  export * as Verification from "./verification";
16
16
  export * as EncryptHelper from "./lib/encrypt-helper";
17
- export * as Payment from "./lib/payment";
17
+ export * as Settlement from "./lib/payment";
18
18
  export * as Decoy from "./lib/decoy";
19
- export * as PaymentsDecoy from "./payments/decoy";
package/dist/index.js CHANGED
@@ -225,6 +225,7 @@ __export(exports_utils, {
225
225
  unseal: () => unseal,
226
226
  tsGmt7WithoutColon: () => tsGmt7WithoutColon,
227
227
  sendApiRequest: () => sendApiRequest,
228
+ normalizePayment: () => normalizePayment,
228
229
  javaLikeTimestamp: () => javaLikeTimestamp,
229
230
  interceptPage: () => interceptPage,
230
231
  base64Encode: () => base64Encode
@@ -307,6 +308,11 @@ function unseal(getter, fallback) {
307
308
  return fallback;
308
309
  }
309
310
  }
311
+ var normalizePayment = (payment_for) => {
312
+ if (payment_for === "")
313
+ return "BUY_PACKAGE";
314
+ return payment_for;
315
+ };
310
316
  var init_utils = __esm(() => {
311
317
  init_config();
312
318
  init_encrypt();
@@ -437,18 +443,18 @@ init_config();
437
443
  init_utils();
438
444
  var exports_ciam = {};
439
445
  __export(exports_ciam, {
446
+ refreshToken: () => refreshToken,
440
447
  getTieringInfo: () => getTieringInfo,
441
448
  getRedeemables: () => getRedeemables,
442
449
  getProfile: () => getProfile,
443
- getNewToken: () => getNewToken,
450
+ getMyPackages: () => getMyPackages,
444
451
  getBalance: () => getBalance,
445
- fetchMyPackages: () => fetchMyPackages,
446
452
  checkQuota: () => checkQuota
447
453
  });
448
454
  import axios3 from "axios";
449
455
  import { DateTime as DateTime3, FixedOffsetZone as FixedOffsetZone2 } from "luxon";
450
456
  import { v4 as uuidv43 } from "uuid";
451
- async function getNewToken(refreshToken, axDeviceId, axFingerprint) {
457
+ async function refreshToken(refreshToken2, axDeviceId, axFingerprint) {
452
458
  try {
453
459
  const url = `${BASE_CIAM_URL}/realms/xl-ciam/protocol/openid-connect/token`;
454
460
  const gmt7Zone = FixedOffsetZone2.instance(420);
@@ -470,7 +476,7 @@ async function getNewToken(refreshToken, axDeviceId, axFingerprint) {
470
476
  };
471
477
  const data = new URLSearchParams({
472
478
  grant_type: "refresh_token",
473
- refresh_token: refreshToken
479
+ refresh_token: refreshToken2
474
480
  });
475
481
  const resp = await axios3.post(url, data.toString(), {
476
482
  headers,
@@ -523,7 +529,7 @@ async function checkQuota(msisdn) {
523
529
  const response = await axios3.get(url);
524
530
  return response.data;
525
531
  }
526
- async function fetchMyPackages({ idToken }) {
532
+ async function getMyPackages({ idToken }) {
527
533
  const path = "api/v8/packages/quota-details";
528
534
  const rawPayload = {
529
535
  is_enterprise: false,
@@ -566,15 +572,15 @@ init_config();
566
572
  var exports_device = {};
567
573
  __export(exports_device, {
568
574
  getAxDeviceId: () => getAxDeviceId,
569
- generateAxFp: () => generateAxFp,
570
- buildFingerprintPlain: () => buildFingerprintPlain,
575
+ generateAxFingerprint: () => generateAxFingerprint,
576
+ buildFingerprintPlaintext: () => buildFingerprintPlaintext,
571
577
  axFingerprint: () => axFingerprint
572
578
  });
573
579
  import crypto4 from "crypto";
574
580
  function randint(min, max) {
575
581
  return Math.floor(Math.random() * (max - min + 1)) + min;
576
582
  }
577
- function buildFingerprintPlain(dev) {
583
+ function buildFingerprintPlaintext(dev) {
578
584
  return `${dev.manufacturer}|${dev.model}|${dev.lang}|${dev.resolution}|` + `${dev.tz_short}|${dev.ip}|${dev.font_scale}|Android ${dev.android_release}|${dev.msisdn}`;
579
585
  }
580
586
  function pkcs7Pad2(buf, blockSize = 16) {
@@ -589,14 +595,14 @@ function axFingerprint(dev, secretKey32Ascii) {
589
595
  throw new Error(`AX_FP_KEY invalid length: got ${key.length} bytes. Expected 16/24/32 ASCII chars.`);
590
596
  }
591
597
  const iv = Buffer.alloc(16, 0);
592
- const pt = Buffer.from(buildFingerprintPlain(dev), "utf8");
598
+ const pt = Buffer.from(buildFingerprintPlaintext(dev), "utf8");
593
599
  const padded = pkcs7Pad2(pt, 16);
594
600
  const cipher = crypto4.createCipheriv(key.length === 16 ? "aes-128-cbc" : key.length === 24 ? "aes-192-cbc" : "aes-256-cbc", key, iv);
595
601
  cipher.setAutoPadding(false);
596
602
  const ct = Buffer.concat([cipher.update(padded), cipher.final()]);
597
603
  return ct.toString("base64");
598
604
  }
599
- function generateAxFp(params) {
605
+ function generateAxFingerprint(params) {
600
606
  const dev = {
601
607
  manufacturer: "samsung" + String(randint(1000, 9999)),
602
608
  model: "SM-N93" + String(randint(1000, 9999)),
@@ -913,13 +919,40 @@ async function getAddons({
913
919
  // src/payments/index.ts
914
920
  var exports_payments = {};
915
921
  __export(exports_payments, {
916
- settlementQris: () => settlementQris,
917
- settlementEWallet: () => settlementEWallet,
918
- settlementBalance: () => settlementBalance,
919
- EWalletProviderEnum: () => EWalletProviderEnum
922
+ payQrisWithDecoy: () => payQrisWithDecoy,
923
+ payQrisDecoyV2: () => payQrisDecoyV2,
924
+ payQris: () => payQris,
925
+ payPulsaWithDecoy: () => payPulsaWithDecoy,
926
+ payPulsaDecoyV2: () => payPulsaDecoyV2,
927
+ payPulsa: () => payPulsa,
928
+ payEwallet: () => payEwallet
920
929
  });
921
930
 
922
- // src/payments/balance.ts
931
+ // src/lib/payment.ts
932
+ init_utils();
933
+ var exports_payment = {};
934
+ __export(exports_payment, {
935
+ getTransactionDetail: () => getTransactionDetail
936
+ });
937
+ async function getTransactionDetail({
938
+ idToken,
939
+ transactionId
940
+ }) {
941
+ const path = "payments/api/v8/pending-detail";
942
+ const payload = {
943
+ transaction_id: transactionId,
944
+ is_enterprise: false,
945
+ lang: "en",
946
+ status: ""
947
+ };
948
+ const res = await sendApiRequest(path, payload, idToken, "POST");
949
+ return res.data;
950
+ }
951
+
952
+ // src/payments/ewallet.ts
953
+ init_utils();
954
+
955
+ // src/payments/method/balance.ts
923
956
  init_encrypt();
924
957
  init_utils();
925
958
  init_config();
@@ -1051,20 +1084,13 @@ async function settlementBalance({
1051
1084
  const decryptedXData = await decryptXData2(xdata, xtime);
1052
1085
  return decryptedXData;
1053
1086
  }
1054
- // src/payments/ewallet.ts
1087
+ // src/payments/method/ewallet.ts
1055
1088
  init_encrypt();
1056
1089
  init_utils();
1057
1090
  init_config();
1058
1091
  import axios5 from "axios";
1059
1092
  import { v4 as uuidv45 } from "uuid";
1060
1093
  import { DateTime as DateTime5 } from "luxon";
1061
- var EWalletProviderEnum;
1062
- ((EWalletProviderEnum2) => {
1063
- EWalletProviderEnum2["DANA"] = "DANA";
1064
- EWalletProviderEnum2["ShopeePay"] = "SHOPEEPAY";
1065
- EWalletProviderEnum2["GoPay"] = "GOPAY";
1066
- EWalletProviderEnum2["OVO"] = "OVO";
1067
- })(EWalletProviderEnum ||= {});
1068
1094
  async function settlementEWallet({
1069
1095
  idToken,
1070
1096
  accessToken,
@@ -1149,7 +1175,7 @@ async function settlementEWallet({
1149
1175
  const decryptedXData = await decryptXData2(resp.data.xdata, resp.data.xtime);
1150
1176
  return decryptedXData;
1151
1177
  }
1152
- // src/payments/qris.ts
1178
+ // src/payments/method/qris.ts
1153
1179
  init_encrypt();
1154
1180
  init_utils();
1155
1181
  init_config();
@@ -1253,6 +1279,161 @@ async function settlementQris({
1253
1279
  const decryptedXData = await decryptXData2(resp.data.xdata, resp.data.xtime);
1254
1280
  return decryptedXData;
1255
1281
  }
1282
+ // src/payments/ewallet.ts
1283
+ var providerOptions = [
1284
+ { value: "DANA" /* DANA */, label: "DANA" },
1285
+ { value: "SHOPEEPAY" /* ShopeePay */, label: "ShopeePay" },
1286
+ { value: "GOPAY" /* GoPay */, label: "GoPay" },
1287
+ { value: "OVO" /* OVO */, label: "OVO" }
1288
+ ];
1289
+ async function payEwallet(idToken, accessToken, pkg, overwriteAmount, walletNumber, paymentMethod) {
1290
+ const mainItem = {
1291
+ item_name: pkg.package_option.name,
1292
+ item_code: pkg.package_option.package_option_code,
1293
+ item_price: pkg.package_option.price,
1294
+ product_type: pkg.package_option.product_type,
1295
+ token_confirmation: pkg.token_confirmation,
1296
+ tax: 0
1297
+ };
1298
+ const finalOverwriteAmount = overwriteAmount ? Number(overwriteAmount) : null;
1299
+ const result = await settlementEWallet({
1300
+ idToken,
1301
+ accessToken,
1302
+ paymentFor: normalizePayment(pkg.package_family.payment_for),
1303
+ tokenConfirmation: mainItem.token_confirmation,
1304
+ overwriteAmount: finalOverwriteAmount,
1305
+ item: mainItem,
1306
+ items: [mainItem],
1307
+ walletNumber,
1308
+ paymentMethod
1309
+ });
1310
+ if (result.status === "SUCCESS") {
1311
+ const transaction = await getTransactionDetail({ idToken, transactionId: result.data.transaction_code });
1312
+ return transaction;
1313
+ }
1314
+ return result;
1315
+ }
1316
+ // src/payments/pulsa.ts
1317
+ init_utils();
1318
+ async function payPulsa(idToken, accessToken, pkg, overwriteAmount) {
1319
+ const mainItem = {
1320
+ item_name: pkg.package_option.name,
1321
+ item_code: pkg.package_option.package_option_code,
1322
+ item_price: pkg.package_option.price,
1323
+ product_type: pkg.package_option.product_type,
1324
+ token_confirmation: pkg.token_confirmation,
1325
+ tax: 0
1326
+ };
1327
+ const finalOverwriteAmount = overwriteAmount ? Number(overwriteAmount) : null;
1328
+ const result = await settlementBalance({
1329
+ idToken,
1330
+ accessToken,
1331
+ paymentFor: normalizePayment(pkg.package_family.payment_for),
1332
+ tokenConfirmation: mainItem.token_confirmation,
1333
+ overwriteAmount: finalOverwriteAmount,
1334
+ item: mainItem,
1335
+ items: [mainItem]
1336
+ });
1337
+ return result;
1338
+ }
1339
+ // src/payments/pulsa-decoy.ts
1340
+ init_utils();
1341
+ async function payPulsaWithDecoy(idToken, accessToken, pkg, useDecoyToken = false, decoyItem) {
1342
+ const mainItem = {
1343
+ item_name: pkg.package_option.name,
1344
+ item_code: pkg.package_option.package_option_code,
1345
+ item_price: pkg.package_option.price,
1346
+ product_type: pkg.package_option.product_type,
1347
+ token_confirmation: pkg.token_confirmation,
1348
+ tax: 0
1349
+ };
1350
+ const settle = (overwriteAmount) => settlementBalance({
1351
+ idToken,
1352
+ accessToken,
1353
+ paymentFor: normalizePayment(pkg.package_family.payment_for),
1354
+ tokenConfirmation: useDecoyToken ? decoyItem.token_confirmation : mainItem.token_confirmation,
1355
+ overwriteAmount,
1356
+ item: mainItem,
1357
+ items: [mainItem, decoyItem],
1358
+ ...useDecoyToken && { paymentTargetsMethodsOption: decoyItem.item_code }
1359
+ });
1360
+ let result = await settle(mainItem.item_price + decoyItem.item_price);
1361
+ if (result.status === "SUCCESS") {
1362
+ return result;
1363
+ }
1364
+ console.log(JSON.stringify(result, null, 2));
1365
+ if (result.message.includes("Bizz-err.Amount.Total")) {
1366
+ const match = result.message.match(/=\s*(\d+)/);
1367
+ result = await settle(Number(match ? match[1] : 0));
1368
+ if (result.status === "SUCCESS") {
1369
+ return result;
1370
+ }
1371
+ }
1372
+ return result;
1373
+ }
1374
+ // src/payments/pulsa-decoy-v2.ts
1375
+ async function payPulsaDecoyV2(idToken, accessToken, pkg, decoyItem) {
1376
+ await payPulsaWithDecoy(idToken, accessToken, pkg, true, decoyItem);
1377
+ }
1378
+ // src/payments/qris-decoy.ts
1379
+ async function payQrisWithDecoy(idToken, accessToken, pkg, overwriteAmount, decoyItem) {
1380
+ const mainItem = {
1381
+ item_name: pkg.package_option.name,
1382
+ item_code: pkg.package_option.package_option_code,
1383
+ item_price: pkg.package_option.price,
1384
+ product_type: pkg.package_option.product_type,
1385
+ token_confirmation: pkg.token_confirmation,
1386
+ tax: 0
1387
+ };
1388
+ const finalDecoyItem = { ...decoyItem, product_type: "" };
1389
+ const finalOverwriteAmount = overwriteAmount ? Number(overwriteAmount) : null;
1390
+ const result = await settlementQris({
1391
+ idToken,
1392
+ accessToken,
1393
+ paymentFor: "SHARE_PACKAGE",
1394
+ tokenConfirmation: finalDecoyItem.token_confirmation,
1395
+ overwriteAmount: finalOverwriteAmount ?? mainItem.item_price + finalDecoyItem.item_price,
1396
+ item: mainItem,
1397
+ items: [mainItem, finalDecoyItem],
1398
+ paymentTargetsMethodsOption: finalDecoyItem.item_code
1399
+ });
1400
+ if (result.status === "SUCCESS") {
1401
+ const transaction = await getTransactionDetail({ idToken, transactionId: result.data.transaction_code });
1402
+ return transaction;
1403
+ }
1404
+ return result;
1405
+ }
1406
+ // src/payments/qris-decoy-v2.ts
1407
+ async function payQrisDecoyV2(idToken, accessToken, pkg, overwriteAmount) {
1408
+ await payQrisWithDecoy(idToken, accessToken, pkg, overwriteAmount, {});
1409
+ }
1410
+ // src/payments/qris.ts
1411
+ init_utils();
1412
+ async function payQris(idToken, accessToken, pkg, overwriteAmount) {
1413
+ const mainItem = {
1414
+ item_name: pkg.package_option.name,
1415
+ item_code: pkg.package_option.package_option_code,
1416
+ item_price: pkg.package_option.price,
1417
+ product_type: pkg.package_option.product_type,
1418
+ token_confirmation: pkg.token_confirmation,
1419
+ tax: 0
1420
+ };
1421
+ const finalOverwriteAmount = overwriteAmount ? Number(overwriteAmount) : null;
1422
+ const result = await settlementQris({
1423
+ idToken,
1424
+ accessToken,
1425
+ paymentFor: normalizePayment(pkg.package_family.payment_for),
1426
+ tokenConfirmation: mainItem.token_confirmation,
1427
+ overwriteAmount: finalOverwriteAmount,
1428
+ item: mainItem,
1429
+ items: [mainItem]
1430
+ });
1431
+ if (result.status === "SUCCESS") {
1432
+ const transaction = await getTransactionDetail({ idToken, transactionId: result.data.transaction_code });
1433
+ return transaction;
1434
+ }
1435
+ return result;
1436
+ }
1256
1437
  // src/profile.ts
1257
1438
  init_utils();
1258
1439
  var exports_profile = {};
@@ -1269,8 +1450,8 @@ async function getPendingTransaction(idToken) {
1269
1450
  return res.data;
1270
1451
  }
1271
1452
  // src/@types/payment.ts
1272
- var exports_payment = {};
1273
- __export(exports_payment, {
1453
+ var exports_payment2 = {};
1454
+ __export(exports_payment2, {
1274
1455
  PaymentMethodEnum: () => PaymentMethodEnum
1275
1456
  });
1276
1457
  var PaymentMethodEnum;
@@ -1320,106 +1501,17 @@ async function checkDukcapil(msisdn, kk, nik) {
1320
1501
  // src/index.ts
1321
1502
  init_encrypt_helper();
1322
1503
 
1323
- // src/lib/payment.ts
1324
- init_utils();
1325
- var exports_payment2 = {};
1326
- __export(exports_payment2, {
1327
- getTransactionDetail: () => getTransactionDetail
1328
- });
1329
- async function getTransactionDetail({
1330
- idToken,
1331
- transactionId
1332
- }) {
1333
- const path = "payments/api/v8/pending-detail";
1334
- const payload = {
1335
- transaction_id: transactionId,
1336
- is_enterprise: false,
1337
- lang: "en",
1338
- status: ""
1339
- };
1340
- const res = await sendApiRequest(path, payload, idToken, "POST");
1341
- return res.data;
1342
- }
1343
1504
  // src/lib/decoy.ts
1344
1505
  var exports_decoy = {};
1345
1506
  __export(exports_decoy, {
1346
1507
  getDecoyName: () => getDecoyName,
1347
1508
  getDecoyData: () => getDecoyData,
1348
- decoyIsExits: () => decoyIsExits
1509
+ decoyExists: () => decoyExists
1349
1510
  });
1350
- // src/data/decoys/decoy-default-balance.json
1351
- var decoy_default_balance_default = {
1352
- family_name: "XL PASS",
1353
- family_code: "b0a20d74-0c54-4e3b-8f3f-01e7482e50bf",
1354
- is_enterprise: true,
1355
- migration_type: "NONE",
1356
- variant_code: "719d093f-6f8d-46a4-8390-6a0003a172ea",
1357
- option_name: "XL PASS 30 days",
1358
- order: 1,
1359
- price: 889750
1360
- };
1361
- // src/data/decoys/decoy-default-qris.json
1362
- var decoy_default_qris_default = {
1363
- family_name: "",
1364
- family_code: "580c1f94-7dc4-416e-96f6-8faf26567516",
1365
- is_enterprise: false,
1366
- migration_type: "NONE",
1367
- variant_code: "b50f954a-696e-46d0-8700-8e4d38521525",
1368
- option_name: "",
1369
- order: 27,
1370
- price: 1000
1371
- };
1372
- // src/data/decoys/decoy-default-qris0.json
1373
- var decoy_default_qris0_default = {
1374
- family_name: "Kuota Aplikasi BIZ 2GB",
1375
- family_code: "c6f2cd72-8b21-420a-b8d5-e0186afe5be6",
1376
- is_enterprise: true,
1377
- migration_type: "NONE",
1378
- variant_code: "b7cf278e-c989-4760-8a26-0a20c1a47a40",
1379
- option_name: "Vidio 2GB",
1380
- order: 11,
1381
- price: 0
1382
- };
1383
- // src/data/decoys/decoy-prio-balance.json
1384
- var decoy_prio_balance_default = {
1385
- family_name: "PRIO PASS",
1386
- family_code: "2512b72a-a3cd-4c70-a736-132cf2c1f0c0",
1387
- is_enterprise: null,
1388
- migration_type: null,
1389
- variant_code: "cff298bd-8ec8-4696-b689-12407d36be15",
1390
- option_name: "PRIO PASS 30 days",
1391
- order: 1,
1392
- price: 999000
1393
- };
1394
- // src/data/decoys/decoy-prio-qris.json
1395
- var decoy_prio_qris_default = {
1396
- family_name: "Conference",
1397
- family_code: "5dab52d5-6f02-4678-b72f-088396ceb113",
1398
- is_enterprise: true,
1399
- migration_type: "PRIOH_TO_PRIO",
1400
- variant_code: "bf84ad5b-87e9-4769-9bd2-2359535c05e4",
1401
- option_name: "Conference 2GB",
1402
- order: 1,
1403
- price: 2000
1404
- };
1405
- // src/data/decoys/decoy-prio-qris0.json
1406
- var decoy_prio_qris0_default = {
1407
- family_name: "Conference",
1408
- family_code: "5dab52d5-6f02-4678-b72f-088396ceb113",
1409
- is_enterprise: true,
1410
- migration_type: "PRIOH_TO_PRIO",
1411
- variant_code: "bf84ad5b-87e9-4769-9bd2-2359535c05e4",
1412
- option_name: "Conference 2GB",
1413
- order: 1,
1414
- price: 2000
1415
- };
1416
-
1417
- // src/lib/decoy.ts
1418
- var needPrioDecoys = ["PRIORITAS", "PRIOHYBRID", "GO"];
1511
+ var PRIO_SUBSCRIPTIONS = ["PRIORITAS", "PRIOHYBRID", "GO"];
1419
1512
  var getDecoyName = (paymentMethod) => {
1420
1513
  switch (paymentMethod) {
1421
1514
  case "BALANCE_DECOY" /* PulsaDecoy */:
1422
- return "balance";
1423
1515
  case "BALANCE_DECOY_V2" /* PulsaDecoyV2 */:
1424
1516
  return "balance";
1425
1517
  case "QRIS_DECOY" /* QRISDecoy */:
@@ -1430,7 +1522,7 @@ var getDecoyName = (paymentMethod) => {
1430
1522
  return "balance";
1431
1523
  }
1432
1524
  };
1433
- var decoyIsExits = (paymentMethod) => {
1525
+ var decoyExists = (paymentMethod) => {
1434
1526
  return [
1435
1527
  "BALANCE_DECOY" /* PulsaDecoy */,
1436
1528
  "BALANCE_DECOY_V2" /* PulsaDecoyV2 */,
@@ -1438,40 +1530,22 @@ var decoyIsExits = (paymentMethod) => {
1438
1530
  "QRIS_DECOY_V2" /* QRISDecoyV2 */
1439
1531
  ].includes(paymentMethod);
1440
1532
  };
1441
- var decoyMap = {
1442
- prio: {
1443
- balance: decoy_prio_balance_default,
1444
- qris: decoy_prio_qris_default,
1445
- qris0: decoy_prio_qris0_default
1446
- },
1447
- default: {
1448
- balance: decoy_default_balance_default,
1449
- qris: decoy_default_qris_default,
1450
- qris0: decoy_default_qris0_default
1451
- }
1452
- };
1453
1533
  var getDecoyData = ({
1454
1534
  subscriptionType,
1455
- decoy
1535
+ decoyType,
1536
+ decoyMap
1456
1537
  }) => {
1457
- const isPrio = needPrioDecoys.includes(subscriptionType);
1538
+ const isPrio = PRIO_SUBSCRIPTIONS.includes(subscriptionType);
1458
1539
  const group = isPrio ? "prio" : "default";
1459
- return decoyMap[group][decoy];
1540
+ return decoyMap[group][decoyType];
1460
1541
  };
1461
- // src/payments/decoy.ts
1462
- var exports_decoy2 = {};
1463
- __export(exports_decoy2, {
1464
- default: () => decoy_default
1465
- });
1466
- var decoy_default = undefined;
1467
1542
  export {
1468
1543
  exports_verification as Verification,
1469
1544
  exports_utils as Utils,
1470
- exports_payment as Types,
1545
+ exports_payment as Settlement,
1471
1546
  exports_profile as Profile,
1472
- exports_decoy2 as PaymentsDecoy,
1473
1547
  exports_payments as Payments,
1474
- exports_payment2 as Payment,
1548
+ exports_payment2 as PaymentTypes,
1475
1549
  exports_package as Package,
1476
1550
  exports_notification as Notification,
1477
1551
  exports_family_plan as FamilyPlan,
@@ -9,9 +9,13 @@ export type DecoyDataType = {
9
9
  order: number;
10
10
  price: number;
11
11
  };
12
+ type DecoyGroup = 'prio' | 'default';
13
+ type DecoyMap = Record<DecoyGroup, Record<DecoyType, DecoyDataType>>;
12
14
  export declare const getDecoyName: (paymentMethod: string) => DecoyType;
13
- export declare const decoyIsExits: (paymentMethod: string) => boolean;
14
- export declare const getDecoyData: ({ subscriptionType, decoy, }: {
15
+ export declare const decoyExists: (paymentMethod: string) => boolean;
16
+ export declare const getDecoyData: ({ subscriptionType, decoyType, decoyMap, }: {
15
17
  subscriptionType: string;
16
- decoy: DecoyType;
18
+ decoyType: DecoyType;
19
+ decoyMap: DecoyMap;
17
20
  }) => DecoyDataType;
21
+ export {};