ts-glitter 21.0.4 → 21.0.6
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/lowcode/Entry.js +1 -1
- package/lowcode/Entry.ts +1 -1
- package/lowcode/backend-manager/bg-blog.js +22 -37
- package/lowcode/backend-manager/bg-blog.ts +45 -34
- package/lowcode/backend-manager/bg-list-component.js +2 -2
- package/lowcode/backend-manager/bg-list-component.ts +2 -2
- package/lowcode/backend-manager/bg-widget.js +21 -0
- package/lowcode/backend-manager/bg-widget.ts +21 -0
- package/lowcode/cms-plugin/filter-options.js +3 -3
- package/lowcode/cms-plugin/filter-options.ts +1 -1
- package/lowcode/cms-plugin/pos-pages/models.ts +1 -0
- package/lowcode/cms-plugin/pos-pages/payment-page.js +74 -8
- package/lowcode/cms-plugin/pos-pages/payment-page.ts +98 -19
- package/lowcode/cms-plugin/product-service.js +2 -1
- package/lowcode/cms-plugin/product-service.ts +3 -2
- package/lowcode/cms-plugin/shopping-finance-setting.js +251 -6
- package/lowcode/cms-plugin/shopping-finance-setting.ts +291 -6
- package/lowcode/cms-plugin/shopping-order-manager.js +56 -46
- package/lowcode/cms-plugin/shopping-order-manager.ts +59 -47
- package/lowcode/cms-plugin/shopping-product-setting.js +10 -5
- package/lowcode/cms-plugin/shopping-product-setting.ts +14 -6
- package/lowcode/cms-plugin/shopping-setting-advance.js +21 -72
- package/lowcode/cms-plugin/shopping-setting-advance.ts +31 -98
- package/lowcode/css/editor.css +48 -16
- package/lowcode/css/front-end.css +16 -17
- package/lowcode/glitter-base/global/language.js +2 -0
- package/lowcode/glitter-base/global/language.ts +3 -0
- package/lowcode/glitter-base/global/shipment-config.js +4 -4
- package/lowcode/glitter-base/global/shipment-config.ts +1 -1
- package/lowcode/glitter-base/route/shopping.js +11 -0
- package/lowcode/glitter-base/route/shopping.ts +12 -0
- package/lowcode/official_view_component/form-widget/input-custom.js +0 -1
- package/lowcode/official_view_component/form-widget/input-custom.ts +0 -1
- package/lowcode/public-components/checkout/index.js +578 -780
- package/lowcode/public-components/checkout/index.ts +2457 -2652
- package/lowcode/public-components/headers/header-class.js +252 -324
- package/lowcode/public-components/headers/header-class.ts +389 -480
- package/lowcode/public-components/modules/cart-module.js +433 -0
- package/lowcode/public-components/modules/cart-module.ts +491 -0
- package/lowcode/public-components/modules/product-module.js +45 -0
- package/lowcode/public-components/modules/product-module.ts +58 -0
- package/lowcode/public-components/product/product-detail.js +178 -184
- package/lowcode/public-components/product/product-detail.ts +564 -579
- package/lowcode/public-components/user-manager/um-order.js +162 -32
- package/lowcode/public-components/user-manager/um-order.ts +181 -46
- package/lowcode/public-models/product.ts +1 -0
- package/package.json +1 -1
- package/src/Language.js +1 -0
- package/src/Language.js.map +1 -1
- package/src/Language.ts +3 -0
- package/src/api-public/controllers/article.js +33 -29
- package/src/api-public/controllers/article.js.map +1 -1
- package/src/api-public/controllers/article.ts +152 -146
- package/src/api-public/controllers/index.js +2 -0
- package/src/api-public/controllers/index.js.map +1 -1
- package/src/api-public/controllers/index.ts +2 -0
- package/src/api-public/controllers/shop.js +125 -47
- package/src/api-public/controllers/shop.js.map +1 -1
- package/src/api-public/controllers/shop.ts +148 -61
- package/src/api-public/controllers/user.js +51 -52
- package/src/api-public/controllers/user.js.map +1 -1
- package/src/api-public/controllers/user.ts +63 -52
- package/src/api-public/models/glitter-finance.js +2 -1
- package/src/api-public/models/glitter-finance.js.map +5 -1
- package/src/api-public/services/checkout-event.d.ts +1 -0
- package/src/api-public/services/checkout-event.js +38 -13
- package/src/api-public/services/checkout-event.js.map +1 -1
- package/src/api-public/services/checkout-event.ts +38 -10
- package/src/api-public/services/factories/payment-strategy-factory.d.ts +6 -0
- package/src/api-public/services/factories/payment-strategy-factory.js +49 -0
- package/src/api-public/services/factories/payment-strategy-factory.js.map +1 -0
- package/src/api-public/services/factories/payment-strategy-factory.ts +71 -0
- package/src/api-public/services/fb-service.js +4 -4
- package/src/api-public/services/fb-service.js.map +1 -1
- package/src/api-public/services/financial-service.d.ts +2 -1
- package/src/api-public/services/financial-service.js +48 -53
- package/src/api-public/services/financial-service.js.map +1 -1
- package/src/api-public/services/financial-service.ts +29 -38
- package/src/api-public/services/financial-serviceV2.d.ts +298 -0
- package/src/api-public/services/financial-serviceV2.js +1158 -0
- package/src/api-public/services/financial-serviceV2.js.map +1 -0
- package/src/api-public/services/financial-serviceV2.ts +1518 -0
- package/src/api-public/services/interface/payment-keys-interface.d.ts +37 -0
- package/src/api-public/services/interface/payment-keys-interface.js +3 -0
- package/src/api-public/services/interface/payment-keys-interface.js.map +1 -0
- package/src/api-public/services/interface/payment-keys-interface.ts +46 -0
- package/src/api-public/services/interface/payment-strategy-interface.d.ts +17 -0
- package/src/api-public/services/interface/payment-strategy-interface.js +3 -0
- package/src/api-public/services/interface/payment-strategy-interface.js.map +1 -0
- package/src/api-public/services/interface/payment-strategy-interface.ts +48 -0
- package/src/api-public/services/migrate-event/public-user-config.d.ts +5 -0
- package/src/api-public/services/migrate-event/public-user-config.js +81 -0
- package/src/api-public/services/migrate-event/public-user-config.js.map +1 -0
- package/src/api-public/services/migrate-event/public-user-config.ts +106 -0
- package/src/api-public/services/model/handlePaymentTransaction.js +0 -68
- package/src/api-public/services/model/handlePaymentTransaction.js.map +1 -1
- package/src/api-public/services/model/handlePaymentTransaction.ts +62 -54
- package/src/api-public/services/monitor.d.ts +1 -0
- package/src/api-public/services/payment-service.d.ts +12 -0
- package/src/api-public/services/payment-service.js +83 -0
- package/src/api-public/services/payment-service.js.map +1 -0
- package/src/api-public/services/payment-service.ts +112 -0
- package/src/api-public/services/shopping.d.ts +2 -1
- package/src/api-public/services/shopping.js +60 -23
- package/src/api-public/services/shopping.js.map +1 -1
- package/src/api-public/services/shopping.ts +88 -16
- package/src/api-public/services/strategies/ecpay-strategy.d.ts +8 -0
- package/src/api-public/services/strategies/ecpay-strategy.js +26 -0
- package/src/api-public/services/strategies/ecpay-strategy.js.map +1 -0
- package/src/api-public/services/strategies/ecpay-strategy.ts +30 -0
- package/src/api-public/services/strategies/ezpay-strategy.d.ts +8 -0
- package/src/api-public/services/strategies/ezpay-strategy.js +26 -0
- package/src/api-public/services/strategies/ezpay-strategy.js.map +1 -0
- package/src/api-public/services/strategies/ezpay-strategy.ts +31 -0
- package/src/api-public/services/strategies/jkopay-strategy.d.ts +8 -0
- package/src/api-public/services/strategies/jkopay-strategy.js +32 -0
- package/src/api-public/services/strategies/jkopay-strategy.js.map +1 -0
- package/src/api-public/services/strategies/jkopay-strategy.ts +36 -0
- package/src/api-public/services/strategies/linepay-strategy.d.ts +8 -0
- package/src/api-public/services/strategies/linepay-strategy.js +32 -0
- package/src/api-public/services/strategies/linepay-strategy.js.map +1 -0
- package/src/api-public/services/strategies/linepay-strategy.ts +35 -0
- package/src/api-public/services/strategies/paynow-strategy.d.ts +8 -0
- package/src/api-public/services/strategies/paynow-strategy.js +26 -0
- package/src/api-public/services/strategies/paynow-strategy.js.map +1 -0
- package/src/api-public/services/strategies/paynow-strategy.ts +29 -0
- package/src/api-public/services/strategies/paypal-strategy.d.ts +8 -0
- package/src/api-public/services/strategies/paypal-strategy.js +28 -0
- package/src/api-public/services/strategies/paypal-strategy.js.map +1 -0
- package/src/api-public/services/strategies/paypal-strategy.ts +31 -0
- package/src/api-public/services/updated-table-checked.d.ts +1 -0
- package/src/api-public/services/updated-table-checked.js +37 -15
- package/src/api-public/services/updated-table-checked.js.map +1 -1
- package/src/api-public/services/updated-table-checked.ts +56 -36
- package/src/api-public/utils/ut-permission.d.ts +1 -0
- package/src/app-project/serverless/src/index.js +17 -7
- package/src/app-project/serverless/src/index.js.map +1 -1
- package/src/app-project/serverless/src/modules/CryptoJS.js +17 -7
- package/src/app-project/serverless/src/modules/CryptoJS.js.map +1 -1
- package/src/app-project/serverless/src/modules/ssh.js +17 -7
- package/src/app-project/serverless/src/modules/ssh.js.map +1 -1
- package/src/config.d.ts +1 -1
- package/src/modules/AWSLib.js +3 -2
- package/src/modules/AWSLib.js.map +1 -1
- package/src/modules/CryptoJS.js +17 -7
- package/src/modules/CryptoJS.js.map +1 -1
- package/src/modules/database.d.ts +1 -1
- package/src/modules/redis.d.ts +1 -1
- package/src/modules/ssh.js +17 -7
- package/src/modules/ssh.js.map +1 -1
- package/src/modules/tool.d.ts +4 -4
- package/src/modules/tool.js +2 -1
- package/src/modules/tool.js.map +1 -1
- package/src/run.js +2 -1
- package/src/run.js.map +1 -1
- package/src/services/create-instance.js +4 -3
- package/src/services/create-instance.js.map +1 -1
- package/src/services/saas-table-check.js +2 -2
- package/src/services/saas-table-check.js.map +5 -1
- package/src/services/tool.js +3 -2
- package/src/services/tool.js.map +1 -1
- package/vp00rqhw1r.json +1 -0
- package/src/api-public/services/product-migrate.d.ts +0 -8
- package/src/api-public/services/product-migrate.js.map +0 -1
|
@@ -40,6 +40,7 @@ export type CartItem = {
|
|
|
40
40
|
rebate: number;
|
|
41
41
|
designated_logistics: {
|
|
42
42
|
type: 'all' | 'designated';
|
|
43
|
+
group: string[];
|
|
43
44
|
list: string[];
|
|
44
45
|
};
|
|
45
46
|
deduction_log?: {
|
|
@@ -338,7 +339,7 @@ export class CheckoutEvent {
|
|
|
338
339
|
shipment_setting.custom_delivery = shipment_setting.custom_delivery
|
|
339
340
|
? await Promise.all(
|
|
340
341
|
shipment_setting.custom_delivery.map(async (form: any) => {
|
|
341
|
-
const config = await
|
|
342
|
+
const config = await userClass.getConfigV2({
|
|
342
343
|
user_id: 'manager',
|
|
343
344
|
key: `form_delivery_${form.id}`,
|
|
344
345
|
});
|
|
@@ -464,7 +465,7 @@ export class CheckoutEvent {
|
|
|
464
465
|
}
|
|
465
466
|
}
|
|
466
467
|
|
|
467
|
-
const store_info = await
|
|
468
|
+
const store_info = await userClass.getConfigV2({ key: 'store-information', user_id: 'manager' });
|
|
468
469
|
|
|
469
470
|
data.line_items = await Promise.all(
|
|
470
471
|
data.line_items.map(async item => {
|
|
@@ -509,14 +510,31 @@ export class CheckoutEvent {
|
|
|
509
510
|
}
|
|
510
511
|
|
|
511
512
|
if (variant && item.count > 0) {
|
|
513
|
+
const sale_price= (()=>{
|
|
514
|
+
//POS允許自訂價格
|
|
515
|
+
if(checkOutType === 'POS' && (item as any).custom_price){
|
|
516
|
+
return (item as any).custom_price
|
|
517
|
+
}else{
|
|
518
|
+
return variant.sale_price;
|
|
519
|
+
}
|
|
520
|
+
})()
|
|
521
|
+
const origin_price= (()=>{
|
|
522
|
+
//POS如果有自訂價格,則比較金額改成和原售價相比
|
|
523
|
+
if(checkOutType === 'POS' && (item as any).custom_price){
|
|
524
|
+
return variant.sale_price;
|
|
525
|
+
}else{
|
|
526
|
+
return variant.origin_price;
|
|
527
|
+
}
|
|
528
|
+
})()
|
|
512
529
|
Object.assign(item, {
|
|
513
530
|
specs: content.specs,
|
|
514
531
|
language_data: content.language_data,
|
|
515
532
|
product_category: content.product_category,
|
|
516
533
|
preview_image: variant.preview_image || content.preview_image[0],
|
|
517
534
|
title: content.title,
|
|
518
|
-
sale_price:
|
|
519
|
-
|
|
535
|
+
sale_price:sale_price,
|
|
536
|
+
variant_sale_price: variant.sale_price,
|
|
537
|
+
origin_price: origin_price,
|
|
520
538
|
collection: content.collection,
|
|
521
539
|
sku: variant.sku,
|
|
522
540
|
stock: variant.stock,
|
|
@@ -577,7 +595,7 @@ export class CheckoutEvent {
|
|
|
577
595
|
if (content.productType.giveaway) {
|
|
578
596
|
variant.sale_price = 0;
|
|
579
597
|
} else {
|
|
580
|
-
carData.total +=
|
|
598
|
+
carData.total += sale_price * item.count;
|
|
581
599
|
}
|
|
582
600
|
}
|
|
583
601
|
}
|
|
@@ -942,20 +960,30 @@ export class CheckoutEvent {
|
|
|
942
960
|
|
|
943
961
|
const excludedValuesByTotal = new Set(['UNIMARTC2C', 'FAMIC2C', 'HILIFEC2C', 'OKMARTC2C']);
|
|
944
962
|
const excludedValuesByWeight = new Set(['normal', 'black_cat']);
|
|
963
|
+
const logisticsGroupResult = await userClass.getConfig({ key: 'logistics_group', user_id: 'manager' });
|
|
964
|
+
const logisticsGroup = logisticsGroupResult[0]?.value ?? [];
|
|
945
965
|
|
|
946
966
|
const isExcludedByTotal = (dd: any) => {
|
|
947
967
|
return carData.total > 20000 && excludedValuesByTotal.has(dd.value);
|
|
948
968
|
};
|
|
969
|
+
|
|
949
970
|
const isExcludedByWeight = (dd: any) => {
|
|
950
971
|
return carData.goodsWeight > 20 && excludedValuesByWeight.has(dd.value);
|
|
951
972
|
};
|
|
973
|
+
|
|
952
974
|
const isIncludedInDesignatedLogistics = (dd: any) => {
|
|
953
975
|
return carData.lineItems.every(item => {
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
)
|
|
976
|
+
if (item.designated_logistics === undefined || item.designated_logistics.type === 'all') {
|
|
977
|
+
return true;
|
|
978
|
+
}
|
|
979
|
+
|
|
980
|
+
for (const group of logisticsGroup) {
|
|
981
|
+
if (item.designated_logistics.group.includes(group.key) && group.list.includes(dd.value)) {
|
|
982
|
+
return true;
|
|
983
|
+
}
|
|
984
|
+
}
|
|
985
|
+
|
|
986
|
+
return false;
|
|
959
987
|
});
|
|
960
988
|
};
|
|
961
989
|
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PaymentStrategyFactory = void 0;
|
|
4
|
+
const ecpay_strategy_js_1 = require("../strategies/ecpay-strategy.js");
|
|
5
|
+
const ezpay_strategy_js_1 = require("../strategies/ezpay-strategy.js");
|
|
6
|
+
const paypal_strategy_js_1 = require("../strategies/paypal-strategy.js");
|
|
7
|
+
const linepay_strategy_js_1 = require("../strategies/linepay-strategy.js");
|
|
8
|
+
const jkopay_strategy_1 = require("../strategies/jkopay-strategy");
|
|
9
|
+
const paynow_strategy_1 = require("../strategies/paynow-strategy");
|
|
10
|
+
const paymentStrategyConfigurations = [
|
|
11
|
+
{ key: 'ecPay', strategyClass: ecpay_strategy_js_1.EcPayStrategy },
|
|
12
|
+
{ key: 'newWebPay', strategyClass: ezpay_strategy_js_1.EzPayStrategy },
|
|
13
|
+
{ key: 'paypal', strategyClass: paypal_strategy_js_1.PayPalStrategy },
|
|
14
|
+
{ key: 'line_pay', strategyClass: linepay_strategy_js_1.LinePayStrategy },
|
|
15
|
+
{ key: 'jkopay', strategyClass: jkopay_strategy_1.JkoPayStrategy },
|
|
16
|
+
{ key: 'paynow', strategyClass: paynow_strategy_1.PayNowStrategy },
|
|
17
|
+
];
|
|
18
|
+
class PaymentStrategyFactory {
|
|
19
|
+
constructor(loadedKeyData) {
|
|
20
|
+
if (!loadedKeyData) {
|
|
21
|
+
throw new Error("KeyData must be provided to PaymentStrategyFactory");
|
|
22
|
+
}
|
|
23
|
+
this.allKeyData = loadedKeyData;
|
|
24
|
+
}
|
|
25
|
+
createStrategyRegistry() {
|
|
26
|
+
const strategies = new Map();
|
|
27
|
+
paymentStrategyConfigurations.forEach(config => {
|
|
28
|
+
const specificKeyData = this.allKeyData[config.key];
|
|
29
|
+
if (specificKeyData) {
|
|
30
|
+
try {
|
|
31
|
+
const strategyInstance = new config.strategyClass(specificKeyData);
|
|
32
|
+
strategies.set(config.key, strategyInstance);
|
|
33
|
+
console.log(`Strategy registered for key: ${config.key}`);
|
|
34
|
+
}
|
|
35
|
+
catch (error) {
|
|
36
|
+
console.error(`Error instantiating strategy for key '${config.key}':`, error);
|
|
37
|
+
console.warn(`Strategy for '${config.key}' will not be available.`);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
console.warn(`Key data for '${config.key}' not found in provided configuration. Strategy not available.`);
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
console.log(`PaymentStrategyFactory: Registry created with ${strategies.size} strategies.`);
|
|
45
|
+
return strategies;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
exports.PaymentStrategyFactory = PaymentStrategyFactory;
|
|
49
|
+
//# sourceMappingURL=payment-strategy-factory.js.map
|
|
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AAgC,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC;gBAC5D,CAAC;gBAAC,OAAO,KAAK,EAAE,CAAC;oBAEf,OAAO,CAAC,KAAK,CAAC,yCAAyC,MAAM,CAAC,GAAG,IAAI,EAAE,KAAK,CAAC,CAAC;oBAC9E,OAAO,CAAC,IAAI,CAAC,iBAAiB,MAAM,CAAC,GAAG,0BAA0B,CAAC,CAAC;gBACtE,CAAC;YACH,CAAC;iBAAM,CAAC;gBAEN,OAAO,CAAC,IAAI,CAAC,iBAAiB,MAAM,CAAC,GAAG,gEAAgE,CAAC,CAAC;YAC5G,CAAC;QACH,CAAC,CAAC,CAAC;QASH,OAAO,CAAC,GAAG,CAAC,iDAAiD,UAAU,CAAC,IAAI,cAAc,CAAC,CAAC;QAC5F,OAAO,UAAU,CAAC;IACpB,CAAC;CAGF;AA9CD,wDA8CC"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { IPaymentStrategy } from '../interface/payment-strategy-interface.js';
|
|
2
|
+
import { EcPayStrategy } from '../strategies/ecpay-strategy.js';
|
|
3
|
+
import { EzPayStrategy } from '../strategies/ezpay-strategy.js';
|
|
4
|
+
import { PayPalStrategy } from '../strategies/paypal-strategy.js';
|
|
5
|
+
import { LinePayStrategy } from '../strategies/linepay-strategy.js';
|
|
6
|
+
import { JkoPayStrategy } from '../strategies/jkopay-strategy';
|
|
7
|
+
import { EcEzPayKeyData } from '../interface/payment-keys-interface';
|
|
8
|
+
import { PayNowStrategy } from '../strategies/paynow-strategy';
|
|
9
|
+
// 定義每個策略設定項目的型別
|
|
10
|
+
interface StrategyConfigEntry {
|
|
11
|
+
key: string;
|
|
12
|
+
strategyClass: new (keys: any) => IPaymentStrategy;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const paymentStrategyConfigurations: StrategyConfigEntry[] = [
|
|
16
|
+
{ key: 'ecPay', strategyClass: EcPayStrategy },
|
|
17
|
+
{ key: 'newWebPay', strategyClass: EzPayStrategy },
|
|
18
|
+
{ key: 'paypal', strategyClass: PayPalStrategy },
|
|
19
|
+
{ key: 'line_pay', strategyClass: LinePayStrategy },
|
|
20
|
+
{ key: 'jkopay', strategyClass: JkoPayStrategy },
|
|
21
|
+
{ key: 'paynow', strategyClass: PayNowStrategy },
|
|
22
|
+
];
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
export class PaymentStrategyFactory {
|
|
26
|
+
// 如果策略的創建需要依賴,可以注入到工廠的建構子
|
|
27
|
+
private allKeyData: Record<string, any>;
|
|
28
|
+
constructor(loadedKeyData: Record<string, any>) {
|
|
29
|
+
if (!loadedKeyData) {
|
|
30
|
+
throw new Error("KeyData must be provided to PaymentStrategyFactory");
|
|
31
|
+
}
|
|
32
|
+
this.allKeyData = loadedKeyData;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
public createStrategyRegistry(): Map<string, IPaymentStrategy> {
|
|
36
|
+
const strategies = new Map<string, IPaymentStrategy>();
|
|
37
|
+
|
|
38
|
+
// **** 使用迴圈處理 strategyConfigs ****
|
|
39
|
+
paymentStrategyConfigurations.forEach(config => {
|
|
40
|
+
// 從 allKeyData 中獲取該策略所需的特定金鑰物件
|
|
41
|
+
const specificKeyData = this.allKeyData[config.key];
|
|
42
|
+
|
|
43
|
+
if (specificKeyData) {
|
|
44
|
+
try {
|
|
45
|
+
const strategyInstance = new config.strategyClass(specificKeyData);
|
|
46
|
+
strategies.set(config.key, strategyInstance);
|
|
47
|
+
console.log(`Strategy registered for key: ${config.key}`);
|
|
48
|
+
} catch (error) {
|
|
49
|
+
// 捕捉並記錄實例化過程中可能發生的錯誤
|
|
50
|
+
console.error(`Error instantiating strategy for key '${config.key}':`, error);
|
|
51
|
+
console.warn(`Strategy for '${config.key}' will not be available.`);
|
|
52
|
+
}
|
|
53
|
+
} else {
|
|
54
|
+
// 如果在 allKeyData 中找不到對應的金鑰資料,則發出警告
|
|
55
|
+
console.warn(`Key data for '${config.key}' not found in provided configuration. Strategy not available.`);
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
//
|
|
59
|
+
// strategies.set('newWebPay', new EzPayStrategy());
|
|
60
|
+
// strategies.set('paypal', new PayPalStrategy());
|
|
61
|
+
// strategies.set('line_pay', new LinePayStrategy());
|
|
62
|
+
// strategies.set('jkopay', new JkoPayStrategy());
|
|
63
|
+
// strategies.set('paynow', new PayNowStrategy(/* ... */));
|
|
64
|
+
// strategies.set('off_line', new OfflineStrategy(/* ... */)); // 線下也視為一種策略
|
|
65
|
+
|
|
66
|
+
console.log(`PaymentStrategyFactory: Registry created with ${strategies.size} strategies.`);
|
|
67
|
+
return strategies;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
}
|
|
@@ -3,10 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.FacebookService = void 0;
|
|
7
|
-
exports.getFacebookPages = getFacebookPages;
|
|
8
|
-
exports.getFacebookPagePicture = getFacebookPagePicture;
|
|
9
|
-
exports.getFacebookPageLiveVideo = getFacebookPageLiveVideo;
|
|
6
|
+
exports.getFacebookPageLiveVideo = exports.getFacebookPagePicture = exports.getFacebookPages = exports.FacebookService = void 0;
|
|
10
7
|
const database_js_1 = __importDefault(require("../../modules/database.js"));
|
|
11
8
|
const process_1 = __importDefault(require("process"));
|
|
12
9
|
const private_config_js_1 = require("../../services/private_config.js");
|
|
@@ -151,6 +148,7 @@ async function getFacebookPages(accessToken) {
|
|
|
151
148
|
throw error;
|
|
152
149
|
}
|
|
153
150
|
}
|
|
151
|
+
exports.getFacebookPages = getFacebookPages;
|
|
154
152
|
async function getFacebookPagePicture(id) {
|
|
155
153
|
const url = `https://graph.facebook.com/v22.0/${id}/picture`;
|
|
156
154
|
try {
|
|
@@ -165,6 +163,7 @@ async function getFacebookPagePicture(id) {
|
|
|
165
163
|
throw error;
|
|
166
164
|
}
|
|
167
165
|
}
|
|
166
|
+
exports.getFacebookPagePicture = getFacebookPagePicture;
|
|
168
167
|
async function getFacebookPageLiveVideo(id, accessToken) {
|
|
169
168
|
const url = `https://graph.facebook.com/v22.0/${id}/live_videos?fields=id,status,broadcast_start_time,title&access_token=${accessToken}&broadcast_status=["LIVE"]`;
|
|
170
169
|
try {
|
|
@@ -180,4 +179,5 @@ async function getFacebookPageLiveVideo(id, accessToken) {
|
|
|
180
179
|
throw error;
|
|
181
180
|
}
|
|
182
181
|
}
|
|
182
|
+
exports.getFacebookPageLiveVideo = getFacebookPageLiveVideo;
|
|
183
183
|
//# sourceMappingURL=fb-service.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fb-service.js","sourceRoot":"","sources":["fb-service.ts"],"names":[],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"fb-service.js","sourceRoot":"","sources":["fb-service.ts"],"names":[],"mappings":";;;;;;AAEA,4EAA2C;AAY3C,sDAA8B;AAC9B,wEAAkE;AAElE,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;AAqC7B,MAAa,eAAe;IAM1B,YAAY,GAAW,EAAE,KAAa;QACpC,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;IAQD,KAAK,CAAC,QAAQ,CAAC,GAAqB;QAClC,MAAM,SAAS,GAAG,iBAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC;QAChD,MAAM,aAAa,GAAG,iBAAO,CAAC,GAAG,CAAC,qBAAqB,CAAC;QACxD,MAAM,YAAY,GAAG,yDAAyD,CAAC;QAE/E,MAAM,SAAS,GAAG,iEAAiE,SAAS,iBAAiB,YAAY,kBAAkB,aAAa,SAAS,GAAG,CAAC,IAAI,EAAE,CAAC;QAE5K,KAAK,CAAC,SAAS,CAAC;aACb,IAAI,CAAC,QAAQ,CAAC,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AC,EAAU;IACrD,MAAM,GAAG,GAAG,oCAAoC,EAAE,UAAU,CAAC;IAC7D,IAAI,CAAC;QAEH,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,CAAC,CAAC;QAElC,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;YACjB,MAAM,IAAI,KAAK,CAAC,sBAAsB,QAAQ,CAAC,UAAU,EAAE,CAAC,CAAC;QAC/D,CAAC;QAGD,OAAO,QAAQ,CAAC,GAAG,CAAC;IACtB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QAEf,OAAO,CAAC,KAAK,CAAC,gBAAgB,EAAE,KAAK,CAAC,CAAC;QACvC,MAAM,KAAK,CAAC;IACd,CAAC;AAEH,CAAC;AAlBD,wDAkBC;AAEM,KAAK,UAAU,wBAAwB,CAAC,EAAU,EAAG,WAAmB;IAG7E,MAAM,GAAG,GAAG,oCAAoC,EAAE,yEAAyE,WAAW,4BAA4B,CAAC;IACnK,IAAI,CAAC;QAEH,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,CAAC,CAAC;QAGlC,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;YACjB,MAAM,IAAI,KAAK,CAAC,sBAAsB,QAAQ,CAAC,UAAU,EAAE,CAAC,CAAC;QAC/D,CAAC;QACD,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;QAEnC,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QAEf,OAAO,CAAC,KAAK,CAAC,gBAAgB,EAAE,KAAK,CAAC,CAAC;QACvC,MAAM,KAAK,CAAC;IACd,CAAC;AAEH,CAAC;AArBD,4DAqBC"}
|
|
@@ -208,8 +208,8 @@ export declare class PayNow {
|
|
|
208
208
|
constructor(appName: string, keyData: any);
|
|
209
209
|
executePaymentIntent(transactionId: string, secret: string, paymentNo: string): Promise<any>;
|
|
210
210
|
bindKey(): Promise<{
|
|
211
|
-
public_key: string;
|
|
212
211
|
private_key: string;
|
|
212
|
+
public_key: string;
|
|
213
213
|
}>;
|
|
214
214
|
confirmAndCaptureOrder(transactionId?: string): Promise<any>;
|
|
215
215
|
createOrder(orderData: {
|
|
@@ -228,6 +228,7 @@ export declare class PayNow {
|
|
|
228
228
|
user_email: string;
|
|
229
229
|
method: string;
|
|
230
230
|
}): Promise<{
|
|
231
|
+
returnUrl: string | undefined;
|
|
231
232
|
data: any;
|
|
232
233
|
publicKey: string;
|
|
233
234
|
BETA: string;
|
|
@@ -12,6 +12,7 @@ const redis_1 = __importDefault(require("../../modules/redis"));
|
|
|
12
12
|
const process_1 = __importDefault(require("process"));
|
|
13
13
|
const order_event_js_1 = require("./order-event.js");
|
|
14
14
|
const private_config_js_1 = require("../../services/private_config.js");
|
|
15
|
+
const node_console_1 = __importDefault(require("node:console"));
|
|
15
16
|
const html = String.raw;
|
|
16
17
|
class FinancialService {
|
|
17
18
|
constructor(appName, keyData) {
|
|
@@ -76,6 +77,11 @@ class EzPay {
|
|
|
76
77
|
return EzPay.aesDecrypt(data, this.keyData.HASH_KEY, this.keyData.HASH_IV);
|
|
77
78
|
}
|
|
78
79
|
async createOrderPage(orderData) {
|
|
80
|
+
await order_event_js_1.OrderEvent.insertOrder({
|
|
81
|
+
cartData: orderData,
|
|
82
|
+
status: 0,
|
|
83
|
+
app: this.appName,
|
|
84
|
+
});
|
|
79
85
|
const params = {
|
|
80
86
|
MerchantID: this.keyData.MERCHANT_ID,
|
|
81
87
|
RespondType: 'JSON',
|
|
@@ -124,11 +130,6 @@ class EzPay {
|
|
|
124
130
|
}
|
|
125
131
|
});
|
|
126
132
|
}
|
|
127
|
-
await order_event_js_1.OrderEvent.insertOrder({
|
|
128
|
-
cartData: orderData,
|
|
129
|
-
status: 0,
|
|
130
|
-
app: this.appName,
|
|
131
|
-
});
|
|
132
133
|
const qs = FinancialService.JsonToQueryString(params);
|
|
133
134
|
const tradeInfo = FinancialService.aesEncrypt(qs, this.keyData.HASH_KEY, this.keyData.HASH_IV);
|
|
134
135
|
const tradeSha = crypto_1.default
|
|
@@ -200,7 +201,7 @@ EzPay.aesDecrypt = (data, key, iv, input = 'hex', output = 'utf-8', method = 'ae
|
|
|
200
201
|
decrypted += decipher.final(output);
|
|
201
202
|
}
|
|
202
203
|
catch (e) {
|
|
203
|
-
e instanceof Error &&
|
|
204
|
+
e instanceof Error && node_console_1.default.error(e.message);
|
|
204
205
|
}
|
|
205
206
|
return decrypted;
|
|
206
207
|
};
|
|
@@ -241,6 +242,11 @@ class EcPay {
|
|
|
241
242
|
return sha256Hash.toUpperCase();
|
|
242
243
|
}
|
|
243
244
|
async createOrderPage(orderData) {
|
|
245
|
+
await order_event_js_1.OrderEvent.insertOrder({
|
|
246
|
+
cartData: orderData,
|
|
247
|
+
status: 0,
|
|
248
|
+
app: this.appName,
|
|
249
|
+
});
|
|
244
250
|
const params = {
|
|
245
251
|
MerchantTradeNo: orderData.orderID,
|
|
246
252
|
MerchantTradeDate: (0, moment_timezone_1.default)().tz('Asia/Taipei').format('YYYY/MM/DD HH:mm:ss'),
|
|
@@ -298,12 +304,7 @@ class EcPay {
|
|
|
298
304
|
};
|
|
299
305
|
const chkSum = EcPay.generateCheckMacValue(params, this.keyData.HASH_KEY, this.keyData.HASH_IV);
|
|
300
306
|
orderData.CheckMacValue = chkSum;
|
|
301
|
-
|
|
302
|
-
cartData: orderData,
|
|
303
|
-
status: 0,
|
|
304
|
-
app: this.appName,
|
|
305
|
-
});
|
|
306
|
-
console.log(`params-is=>`, params);
|
|
307
|
+
node_console_1.default.log(`params-is=>`, params);
|
|
307
308
|
return html `
|
|
308
309
|
<form id="_form_aiochk" action="${this.keyData.ActionURL}" method="post">
|
|
309
310
|
<input type="hidden" name="MerchantTradeNo" id="MerchantTradeNo" value="${params.MerchantTradeNo}" />
|
|
@@ -352,7 +353,7 @@ class EcPay {
|
|
|
352
353
|
resolve(response.data.RtnValue);
|
|
353
354
|
})
|
|
354
355
|
.catch((error) => {
|
|
355
|
-
|
|
356
|
+
node_console_1.default.log(error);
|
|
356
357
|
resolve({});
|
|
357
358
|
});
|
|
358
359
|
});
|
|
@@ -394,7 +395,7 @@ class EcPay {
|
|
|
394
395
|
resolve(paramsObject);
|
|
395
396
|
})
|
|
396
397
|
.catch((error) => {
|
|
397
|
-
|
|
398
|
+
node_console_1.default.log(error);
|
|
398
399
|
resolve({
|
|
399
400
|
TradeStatus: '10200095',
|
|
400
401
|
});
|
|
@@ -432,7 +433,7 @@ class EcPay {
|
|
|
432
433
|
resolve(paramsObject);
|
|
433
434
|
})
|
|
434
435
|
.catch((error) => {
|
|
435
|
-
|
|
436
|
+
node_console_1.default.log(error);
|
|
436
437
|
resolve({
|
|
437
438
|
RtnCode: `-1`,
|
|
438
439
|
});
|
|
@@ -525,8 +526,8 @@ class PayPal {
|
|
|
525
526
|
constructor(appName, keyData) {
|
|
526
527
|
this.keyData = keyData;
|
|
527
528
|
this.appName = appName;
|
|
528
|
-
this.PAYPAL_CLIENT_ID = keyData.PAYPAL_CLIENT_ID;
|
|
529
|
-
this.PAYPAL_SECRET = keyData.PAYPAL_SECRET;
|
|
529
|
+
this.PAYPAL_CLIENT_ID = keyData.BETA == 'true' ? "ATz7uJryxmGA2SmR5PxQ_IFXFYKeWd_R1SIzsr_bDrJQMYgRR5z_TXEnjcBh2P4DQDDYnLdHu0aNfugX" : keyData.PAYPAL_CLIENT_ID;
|
|
530
|
+
this.PAYPAL_SECRET = keyData.BETA == 'true' ? "ENb25ujfYB0GBzv6GvzDW2a7gx-KgsVZwxOBqF0WSH3Zr7SU1BBdI8KQ_XRpcgcjj8VWTOWwo83NxK5d" : keyData.PAYPAL_SECRET;
|
|
530
531
|
this.PAYPAL_BASE_URL = keyData.BETA == 'true' ? 'https://api-m.sandbox.paypal.com' : 'https://api-m.paypal.com';
|
|
531
532
|
}
|
|
532
533
|
async getAccessToken() {
|
|
@@ -547,11 +548,13 @@ class PayPal {
|
|
|
547
548
|
grant_type: 'client_credentials',
|
|
548
549
|
}).toString(),
|
|
549
550
|
};
|
|
551
|
+
node_console_1.default.log("this.PAYPAL_CLIENT_ID -- ", this.PAYPAL_CLIENT_ID);
|
|
552
|
+
node_console_1.default.log("this.PAYPAL_SECRET -- ", this.PAYPAL_SECRET);
|
|
550
553
|
const response = await axios_1.default.request(config);
|
|
551
554
|
return response.data.access_token;
|
|
552
555
|
}
|
|
553
556
|
catch (error) {
|
|
554
|
-
|
|
557
|
+
node_console_1.default.error('Error fetching access token:', ((_a = error.response) === null || _a === void 0 ? void 0 : _a.data) || error.message);
|
|
555
558
|
throw new Error('Failed to retrieve PayPal access token.');
|
|
556
559
|
}
|
|
557
560
|
}
|
|
@@ -627,7 +630,7 @@ class PayPal {
|
|
|
627
630
|
return response.data;
|
|
628
631
|
}
|
|
629
632
|
catch (error) {
|
|
630
|
-
|
|
633
|
+
node_console_1.default.error('Error creating order:', ((_a = error.response) === null || _a === void 0 ? void 0 : _a.data) || error.message);
|
|
631
634
|
throw new Error('Failed to create PayPal order.');
|
|
632
635
|
}
|
|
633
636
|
}
|
|
@@ -658,7 +661,7 @@ class PayPal {
|
|
|
658
661
|
}
|
|
659
662
|
}
|
|
660
663
|
catch (error) {
|
|
661
|
-
|
|
664
|
+
node_console_1.default.error('Error fetching order details:', ((_a = error.response) === null || _a === void 0 ? void 0 : _a.data) || error.message);
|
|
662
665
|
throw error;
|
|
663
666
|
}
|
|
664
667
|
}
|
|
@@ -683,7 +686,7 @@ class PayPal {
|
|
|
683
686
|
return response.data;
|
|
684
687
|
}
|
|
685
688
|
catch (error) {
|
|
686
|
-
|
|
689
|
+
node_console_1.default.error('Error capturing payment:', ((_a = error.response) === null || _a === void 0 ? void 0 : _a.data) || error.message);
|
|
687
690
|
throw error;
|
|
688
691
|
}
|
|
689
692
|
}
|
|
@@ -692,11 +695,11 @@ class PayPal {
|
|
|
692
695
|
const accessToken = await this.getAccessToken();
|
|
693
696
|
const order = await this.getOrderDetails(orderId, accessToken);
|
|
694
697
|
const captureResult = await this.capturePayment(order.id, accessToken);
|
|
695
|
-
|
|
698
|
+
node_console_1.default.log('Payment process completed successfully.');
|
|
696
699
|
return captureResult;
|
|
697
700
|
}
|
|
698
701
|
catch (error) {
|
|
699
|
-
|
|
702
|
+
node_console_1.default.error('Error during order confirmation or payment capture:', error.message);
|
|
700
703
|
throw error;
|
|
701
704
|
}
|
|
702
705
|
}
|
|
@@ -732,17 +735,11 @@ class LinePay {
|
|
|
732
735
|
},
|
|
733
736
|
data: body,
|
|
734
737
|
};
|
|
735
|
-
console.log(`line-conform->
|
|
736
|
-
URL:${url}
|
|
737
|
-
X-LINE-ChannelId:${this.LinePay_CLIENT_ID}
|
|
738
|
-
LinePay_SECRET:${this.LinePay_SECRET}
|
|
739
|
-
`);
|
|
740
738
|
try {
|
|
741
|
-
|
|
742
|
-
return response;
|
|
739
|
+
return await axios_1.default.request(config);
|
|
743
740
|
}
|
|
744
741
|
catch (error) {
|
|
745
|
-
|
|
742
|
+
node_console_1.default.error('Error linePay:', ((_a = error.response) === null || _a === void 0 ? void 0 : _a.data.data) || error.message);
|
|
746
743
|
throw error;
|
|
747
744
|
}
|
|
748
745
|
}
|
|
@@ -826,18 +823,18 @@ class LinePay {
|
|
|
826
823
|
status: 0,
|
|
827
824
|
app: this.appName,
|
|
828
825
|
});
|
|
829
|
-
|
|
826
|
+
node_console_1.default.log(`response.data===>`, response.data);
|
|
830
827
|
await redis_1.default.setValue('linepay' + orderData.orderID, response.data.info.transactionId);
|
|
831
828
|
if (response.data.returnCode === '0000') {
|
|
832
829
|
return response.data;
|
|
833
830
|
}
|
|
834
831
|
else {
|
|
835
|
-
|
|
832
|
+
node_console_1.default.log(' Line Pay Error: ', response.data.returnCode, response.data.returnMessage);
|
|
836
833
|
return response.data;
|
|
837
834
|
}
|
|
838
835
|
}
|
|
839
836
|
catch (error) {
|
|
840
|
-
|
|
837
|
+
node_console_1.default.error('Error linePay:', ((_b = error.response) === null || _b === void 0 ? void 0 : _b.data) || error.message);
|
|
841
838
|
throw error;
|
|
842
839
|
}
|
|
843
840
|
}
|
|
@@ -887,12 +884,15 @@ class PayNow {
|
|
|
887
884
|
return response.data;
|
|
888
885
|
}
|
|
889
886
|
catch (error) {
|
|
890
|
-
|
|
887
|
+
node_console_1.default.error('Error paynow:', ((_a = error.response) === null || _a === void 0 ? void 0 : _a.data.data) || error.message);
|
|
891
888
|
throw error;
|
|
892
889
|
}
|
|
893
890
|
}
|
|
894
891
|
async bindKey() {
|
|
895
892
|
var _a;
|
|
893
|
+
if (this.keyData.BETA == 'true') {
|
|
894
|
+
return { private_key: 'bES1o13CUQJhZzcOkkq2BRoSa8a4f0Kv', public_key: 'sm22610RIIwOTz4STCFf0dF22G067lnd' };
|
|
895
|
+
}
|
|
896
896
|
const keyData = (await private_config_js_1.Private_config.getConfig({
|
|
897
897
|
appName: this.appName,
|
|
898
898
|
key: 'glitter_finance',
|
|
@@ -951,7 +951,7 @@ class PayNow {
|
|
|
951
951
|
return response.data;
|
|
952
952
|
}
|
|
953
953
|
catch (error) {
|
|
954
|
-
|
|
954
|
+
node_console_1.default.error('Error paynow:', ((_a = error.response) === null || _a === void 0 ? void 0 : _a.data.data) || error.message);
|
|
955
955
|
throw error;
|
|
956
956
|
}
|
|
957
957
|
}
|
|
@@ -966,15 +966,9 @@ class PayNow {
|
|
|
966
966
|
allowedPaymentMethods: ['CreditCard'],
|
|
967
967
|
expireDays: 3,
|
|
968
968
|
});
|
|
969
|
-
|
|
969
|
+
node_console_1.default.log(`webhook=>`, this.keyData.NotifyURL + `&orderID=${orderData.orderID}`);
|
|
970
970
|
const url = `${this.BASE_URL}/api/v1/payment-intents`;
|
|
971
|
-
const key_ =
|
|
972
|
-
? {
|
|
973
|
-
private_key: 'bES1o13CUQJhZzcOkkq2BRoSa8a4f0Kv',
|
|
974
|
-
public_key: 'sm22610RIIwOTz4STCFf0dF22G067lnd',
|
|
975
|
-
}
|
|
976
|
-
: await this.bindKey();
|
|
977
|
-
console.log(`key_===>`, key_);
|
|
971
|
+
const key_ = await this.bindKey();
|
|
978
972
|
const config = {
|
|
979
973
|
method: 'post',
|
|
980
974
|
maxBodyLength: Infinity,
|
|
@@ -995,13 +989,14 @@ class PayNow {
|
|
|
995
989
|
});
|
|
996
990
|
await redis_1.default.setValue('paynow' + orderData.orderID, response.data.result.id);
|
|
997
991
|
return {
|
|
992
|
+
returnUrl: this.keyData.ReturnURL,
|
|
998
993
|
data: response.data,
|
|
999
994
|
publicKey: key_.public_key,
|
|
1000
995
|
BETA: this.keyData.BETA,
|
|
1001
996
|
};
|
|
1002
997
|
}
|
|
1003
998
|
catch (error) {
|
|
1004
|
-
|
|
999
|
+
node_console_1.default.error('Error payNow:', ((_a = error.response) === null || _a === void 0 ? void 0 : _a.data) || error.message);
|
|
1005
1000
|
throw error;
|
|
1006
1001
|
}
|
|
1007
1002
|
}
|
|
@@ -1032,7 +1027,7 @@ class JKO {
|
|
|
1032
1027
|
return response.data.result_object;
|
|
1033
1028
|
}
|
|
1034
1029
|
catch (error) {
|
|
1035
|
-
|
|
1030
|
+
node_console_1.default.error('Error paynow:', ((_a = error.response) === null || _a === void 0 ? void 0 : _a.data.data) || error.message);
|
|
1036
1031
|
throw error;
|
|
1037
1032
|
}
|
|
1038
1033
|
}
|
|
@@ -1073,7 +1068,7 @@ class JKO {
|
|
|
1073
1068
|
return response.data;
|
|
1074
1069
|
}
|
|
1075
1070
|
catch (error) {
|
|
1076
|
-
|
|
1071
|
+
node_console_1.default.error('Error jkoPay:', ((_a = error.response) === null || _a === void 0 ? void 0 : _a.data) || error.message);
|
|
1077
1072
|
throw error;
|
|
1078
1073
|
}
|
|
1079
1074
|
}
|
|
@@ -1084,20 +1079,20 @@ class JKO {
|
|
|
1084
1079
|
});
|
|
1085
1080
|
const apiKey = '689c57cd9d5b5ec80f5d5451d18fe24cfe855d21b25c7ff30bcd07829a902f7a';
|
|
1086
1081
|
const secretKey = '8ec78345a13e3d376452d9c89c66b543ef1516c0ef1a05f0adf654c37ac8edac';
|
|
1087
|
-
|
|
1082
|
+
node_console_1.default.log('payload -- ', payload);
|
|
1088
1083
|
const digest = crypto_1.default.createHmac('sha256', secretKey).update(payload, 'utf8').digest('hex');
|
|
1089
1084
|
const headers = {
|
|
1090
1085
|
'api-key': apiKey,
|
|
1091
1086
|
digest: digest,
|
|
1092
1087
|
'Content-Type': 'application/json',
|
|
1093
1088
|
};
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1089
|
+
node_console_1.default.log('API Key:', apiKey);
|
|
1090
|
+
node_console_1.default.log('Digest:', digest);
|
|
1091
|
+
node_console_1.default.log('Headers:', headers);
|
|
1097
1092
|
}
|
|
1098
1093
|
generateDigest(data, apiSecret) {
|
|
1099
|
-
|
|
1100
|
-
|
|
1094
|
+
node_console_1.default.log('data --', data);
|
|
1095
|
+
node_console_1.default.log('apiSecret -- ', apiSecret);
|
|
1101
1096
|
const hmac = crypto_1.default.createHmac('sha256', apiSecret);
|
|
1102
1097
|
hmac.update(data);
|
|
1103
1098
|
return hmac.digest('hex');
|