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.
Files changed (164) hide show
  1. package/lowcode/Entry.js +1 -1
  2. package/lowcode/Entry.ts +1 -1
  3. package/lowcode/backend-manager/bg-blog.js +22 -37
  4. package/lowcode/backend-manager/bg-blog.ts +45 -34
  5. package/lowcode/backend-manager/bg-list-component.js +2 -2
  6. package/lowcode/backend-manager/bg-list-component.ts +2 -2
  7. package/lowcode/backend-manager/bg-widget.js +21 -0
  8. package/lowcode/backend-manager/bg-widget.ts +21 -0
  9. package/lowcode/cms-plugin/filter-options.js +3 -3
  10. package/lowcode/cms-plugin/filter-options.ts +1 -1
  11. package/lowcode/cms-plugin/pos-pages/models.ts +1 -0
  12. package/lowcode/cms-plugin/pos-pages/payment-page.js +74 -8
  13. package/lowcode/cms-plugin/pos-pages/payment-page.ts +98 -19
  14. package/lowcode/cms-plugin/product-service.js +2 -1
  15. package/lowcode/cms-plugin/product-service.ts +3 -2
  16. package/lowcode/cms-plugin/shopping-finance-setting.js +251 -6
  17. package/lowcode/cms-plugin/shopping-finance-setting.ts +291 -6
  18. package/lowcode/cms-plugin/shopping-order-manager.js +56 -46
  19. package/lowcode/cms-plugin/shopping-order-manager.ts +59 -47
  20. package/lowcode/cms-plugin/shopping-product-setting.js +10 -5
  21. package/lowcode/cms-plugin/shopping-product-setting.ts +14 -6
  22. package/lowcode/cms-plugin/shopping-setting-advance.js +21 -72
  23. package/lowcode/cms-plugin/shopping-setting-advance.ts +31 -98
  24. package/lowcode/css/editor.css +48 -16
  25. package/lowcode/css/front-end.css +16 -17
  26. package/lowcode/glitter-base/global/language.js +2 -0
  27. package/lowcode/glitter-base/global/language.ts +3 -0
  28. package/lowcode/glitter-base/global/shipment-config.js +4 -4
  29. package/lowcode/glitter-base/global/shipment-config.ts +1 -1
  30. package/lowcode/glitter-base/route/shopping.js +11 -0
  31. package/lowcode/glitter-base/route/shopping.ts +12 -0
  32. package/lowcode/official_view_component/form-widget/input-custom.js +0 -1
  33. package/lowcode/official_view_component/form-widget/input-custom.ts +0 -1
  34. package/lowcode/public-components/checkout/index.js +578 -780
  35. package/lowcode/public-components/checkout/index.ts +2457 -2652
  36. package/lowcode/public-components/headers/header-class.js +252 -324
  37. package/lowcode/public-components/headers/header-class.ts +389 -480
  38. package/lowcode/public-components/modules/cart-module.js +433 -0
  39. package/lowcode/public-components/modules/cart-module.ts +491 -0
  40. package/lowcode/public-components/modules/product-module.js +45 -0
  41. package/lowcode/public-components/modules/product-module.ts +58 -0
  42. package/lowcode/public-components/product/product-detail.js +178 -184
  43. package/lowcode/public-components/product/product-detail.ts +564 -579
  44. package/lowcode/public-components/user-manager/um-order.js +162 -32
  45. package/lowcode/public-components/user-manager/um-order.ts +181 -46
  46. package/lowcode/public-models/product.ts +1 -0
  47. package/package.json +1 -1
  48. package/src/Language.js +1 -0
  49. package/src/Language.js.map +1 -1
  50. package/src/Language.ts +3 -0
  51. package/src/api-public/controllers/article.js +33 -29
  52. package/src/api-public/controllers/article.js.map +1 -1
  53. package/src/api-public/controllers/article.ts +152 -146
  54. package/src/api-public/controllers/index.js +2 -0
  55. package/src/api-public/controllers/index.js.map +1 -1
  56. package/src/api-public/controllers/index.ts +2 -0
  57. package/src/api-public/controllers/shop.js +125 -47
  58. package/src/api-public/controllers/shop.js.map +1 -1
  59. package/src/api-public/controllers/shop.ts +148 -61
  60. package/src/api-public/controllers/user.js +51 -52
  61. package/src/api-public/controllers/user.js.map +1 -1
  62. package/src/api-public/controllers/user.ts +63 -52
  63. package/src/api-public/models/glitter-finance.js +2 -1
  64. package/src/api-public/models/glitter-finance.js.map +5 -1
  65. package/src/api-public/services/checkout-event.d.ts +1 -0
  66. package/src/api-public/services/checkout-event.js +38 -13
  67. package/src/api-public/services/checkout-event.js.map +1 -1
  68. package/src/api-public/services/checkout-event.ts +38 -10
  69. package/src/api-public/services/factories/payment-strategy-factory.d.ts +6 -0
  70. package/src/api-public/services/factories/payment-strategy-factory.js +49 -0
  71. package/src/api-public/services/factories/payment-strategy-factory.js.map +1 -0
  72. package/src/api-public/services/factories/payment-strategy-factory.ts +71 -0
  73. package/src/api-public/services/fb-service.js +4 -4
  74. package/src/api-public/services/fb-service.js.map +1 -1
  75. package/src/api-public/services/financial-service.d.ts +2 -1
  76. package/src/api-public/services/financial-service.js +48 -53
  77. package/src/api-public/services/financial-service.js.map +1 -1
  78. package/src/api-public/services/financial-service.ts +29 -38
  79. package/src/api-public/services/financial-serviceV2.d.ts +298 -0
  80. package/src/api-public/services/financial-serviceV2.js +1158 -0
  81. package/src/api-public/services/financial-serviceV2.js.map +1 -0
  82. package/src/api-public/services/financial-serviceV2.ts +1518 -0
  83. package/src/api-public/services/interface/payment-keys-interface.d.ts +37 -0
  84. package/src/api-public/services/interface/payment-keys-interface.js +3 -0
  85. package/src/api-public/services/interface/payment-keys-interface.js.map +1 -0
  86. package/src/api-public/services/interface/payment-keys-interface.ts +46 -0
  87. package/src/api-public/services/interface/payment-strategy-interface.d.ts +17 -0
  88. package/src/api-public/services/interface/payment-strategy-interface.js +3 -0
  89. package/src/api-public/services/interface/payment-strategy-interface.js.map +1 -0
  90. package/src/api-public/services/interface/payment-strategy-interface.ts +48 -0
  91. package/src/api-public/services/migrate-event/public-user-config.d.ts +5 -0
  92. package/src/api-public/services/migrate-event/public-user-config.js +81 -0
  93. package/src/api-public/services/migrate-event/public-user-config.js.map +1 -0
  94. package/src/api-public/services/migrate-event/public-user-config.ts +106 -0
  95. package/src/api-public/services/model/handlePaymentTransaction.js +0 -68
  96. package/src/api-public/services/model/handlePaymentTransaction.js.map +1 -1
  97. package/src/api-public/services/model/handlePaymentTransaction.ts +62 -54
  98. package/src/api-public/services/monitor.d.ts +1 -0
  99. package/src/api-public/services/payment-service.d.ts +12 -0
  100. package/src/api-public/services/payment-service.js +83 -0
  101. package/src/api-public/services/payment-service.js.map +1 -0
  102. package/src/api-public/services/payment-service.ts +112 -0
  103. package/src/api-public/services/shopping.d.ts +2 -1
  104. package/src/api-public/services/shopping.js +60 -23
  105. package/src/api-public/services/shopping.js.map +1 -1
  106. package/src/api-public/services/shopping.ts +88 -16
  107. package/src/api-public/services/strategies/ecpay-strategy.d.ts +8 -0
  108. package/src/api-public/services/strategies/ecpay-strategy.js +26 -0
  109. package/src/api-public/services/strategies/ecpay-strategy.js.map +1 -0
  110. package/src/api-public/services/strategies/ecpay-strategy.ts +30 -0
  111. package/src/api-public/services/strategies/ezpay-strategy.d.ts +8 -0
  112. package/src/api-public/services/strategies/ezpay-strategy.js +26 -0
  113. package/src/api-public/services/strategies/ezpay-strategy.js.map +1 -0
  114. package/src/api-public/services/strategies/ezpay-strategy.ts +31 -0
  115. package/src/api-public/services/strategies/jkopay-strategy.d.ts +8 -0
  116. package/src/api-public/services/strategies/jkopay-strategy.js +32 -0
  117. package/src/api-public/services/strategies/jkopay-strategy.js.map +1 -0
  118. package/src/api-public/services/strategies/jkopay-strategy.ts +36 -0
  119. package/src/api-public/services/strategies/linepay-strategy.d.ts +8 -0
  120. package/src/api-public/services/strategies/linepay-strategy.js +32 -0
  121. package/src/api-public/services/strategies/linepay-strategy.js.map +1 -0
  122. package/src/api-public/services/strategies/linepay-strategy.ts +35 -0
  123. package/src/api-public/services/strategies/paynow-strategy.d.ts +8 -0
  124. package/src/api-public/services/strategies/paynow-strategy.js +26 -0
  125. package/src/api-public/services/strategies/paynow-strategy.js.map +1 -0
  126. package/src/api-public/services/strategies/paynow-strategy.ts +29 -0
  127. package/src/api-public/services/strategies/paypal-strategy.d.ts +8 -0
  128. package/src/api-public/services/strategies/paypal-strategy.js +28 -0
  129. package/src/api-public/services/strategies/paypal-strategy.js.map +1 -0
  130. package/src/api-public/services/strategies/paypal-strategy.ts +31 -0
  131. package/src/api-public/services/updated-table-checked.d.ts +1 -0
  132. package/src/api-public/services/updated-table-checked.js +37 -15
  133. package/src/api-public/services/updated-table-checked.js.map +1 -1
  134. package/src/api-public/services/updated-table-checked.ts +56 -36
  135. package/src/api-public/utils/ut-permission.d.ts +1 -0
  136. package/src/app-project/serverless/src/index.js +17 -7
  137. package/src/app-project/serverless/src/index.js.map +1 -1
  138. package/src/app-project/serverless/src/modules/CryptoJS.js +17 -7
  139. package/src/app-project/serverless/src/modules/CryptoJS.js.map +1 -1
  140. package/src/app-project/serverless/src/modules/ssh.js +17 -7
  141. package/src/app-project/serverless/src/modules/ssh.js.map +1 -1
  142. package/src/config.d.ts +1 -1
  143. package/src/modules/AWSLib.js +3 -2
  144. package/src/modules/AWSLib.js.map +1 -1
  145. package/src/modules/CryptoJS.js +17 -7
  146. package/src/modules/CryptoJS.js.map +1 -1
  147. package/src/modules/database.d.ts +1 -1
  148. package/src/modules/redis.d.ts +1 -1
  149. package/src/modules/ssh.js +17 -7
  150. package/src/modules/ssh.js.map +1 -1
  151. package/src/modules/tool.d.ts +4 -4
  152. package/src/modules/tool.js +2 -1
  153. package/src/modules/tool.js.map +1 -1
  154. package/src/run.js +2 -1
  155. package/src/run.js.map +1 -1
  156. package/src/services/create-instance.js +4 -3
  157. package/src/services/create-instance.js.map +1 -1
  158. package/src/services/saas-table-check.js +2 -2
  159. package/src/services/saas-table-check.js.map +5 -1
  160. package/src/services/tool.js +3 -2
  161. package/src/services/tool.js.map +1 -1
  162. package/vp00rqhw1r.json +1 -0
  163. package/src/api-public/services/product-migrate.d.ts +0 -8
  164. package/src/api-public/services/product-migrate.js.map +0 -1
@@ -35,7 +35,11 @@ import { UtTimer } from '../utils/ut-timer.js';
35
35
  import { AutoFcm } from '../../public-config-initial/auto-fcm.js';
36
36
  import PaymentTransaction from './model/handlePaymentTransaction.js';
37
37
  import { Language, LanguageLocation } from '../../Language.js';
38
+ import { PaymentStrategyFactory } from './factories/payment-strategy-factory.js';
39
+ import { IPaymentStrategy } from './interface/payment-strategy-interface.js';
40
+ import { PaymentService } from './payment-service.js';
38
41
  import { CartItem, CheckoutEvent } from './checkout-event.js';
42
+ import { onlinePayArray } from '../models/glitter-finance';
39
43
 
40
44
  type BindItem = {
41
45
  id: string;
@@ -188,6 +192,15 @@ interface orderVoucherData {
188
192
  targetList: string[];
189
193
  }
190
194
 
195
+ interface KeyData {
196
+ HASH_IV: string;
197
+ HASH_KEY: string;
198
+ ActionURL: string;
199
+ NotifyURL: string;
200
+ ReturnURL: string;
201
+ MERCHANT_ID: string;
202
+ }
203
+
191
204
  class OrderDetail {
192
205
  subtotal: number;
193
206
  shipment: number;
@@ -2041,13 +2054,8 @@ export class Shopping {
2041
2054
  }
2042
2055
  })();
2043
2056
 
2044
- let kd = keyData[orderData.customer_info.payment_select] ?? {
2045
- ReturnURL: '',
2046
- NotifyURL: '',
2047
- };
2048
2057
  //現在是new一個新的版本
2049
- //todo 新增一個fake單號 直接做付款的動作 同時做訂單上的更新把這個付款單號記錄下來
2050
- const newOrderID = Date.now();
2058
+ const newOrderID = 'repay'+Date.now();
2051
2059
  const carData: Cart = {
2052
2060
  orderID: `${newOrderID}`,
2053
2061
  discount: orderData.discount ?? 0,
@@ -2094,17 +2102,33 @@ export class Shopping {
2094
2102
  fbp: sqlData.fbp as string,
2095
2103
  editRecord: [],
2096
2104
  };
2097
- await OrderEvent.insertOrder({
2098
- cartData: orderData,
2099
- status: 0,
2100
- app: this.app,
2101
- });
2102
- const result = await new PaymentTransaction(this.app, orderData.customer_info.payment_select).processPayment(
2103
- carData,
2104
- return_url
2105
- );
2105
+ // 紀錄新舊訂單
2106
+ await redis.setValue(newOrderID , `${orderData.orderID}`)
2107
+ //把我的所有付款方式初始化好
2108
+ const strategyFactory = new PaymentStrategyFactory(keyData);
2109
+
2110
+ const allPaymentStrategies: Map<string, IPaymentStrategy> = strategyFactory.createStrategyRegistry();
2111
+ const appName = this.app;
2112
+ const paymentService = new PaymentService(allPaymentStrategies, appName , carData.customer_info.payment_select);
2113
+
2114
+ try {
2115
+ const paymentResult = await paymentService.processPayment(carData, return_url , carData.customer_info.payment_select!);
2116
+ console.log("Controller 收到 Payment Result:", paymentResult);
2117
+ return paymentResult;
2118
+
2119
+ } catch(error) {
2120
+ console.error("Controller 捕獲到錯誤:", error);
2121
+ // 回應錯誤給前端
2122
+ }
2106
2123
 
2107
- return result;
2124
+
2125
+
2126
+ // const result = await new PaymentTransaction(this.app, orderData.customer_info.payment_select as string).processPayment(
2127
+ // carData,
2128
+ // return_url
2129
+ // );
2130
+
2131
+ // return result;
2108
2132
  }
2109
2133
 
2110
2134
  // return result
@@ -4945,6 +4969,53 @@ export class Shopping {
4945
4969
  }
4946
4970
  }
4947
4971
 
4972
+ async removeLogisticGroup(group_key: string) {
4973
+ try {
4974
+ const getProducts = await db.query(
4975
+ `SELECT * FROM \`${this.app}\`.t_manager_post
4976
+ WHERE JSON_CONTAINS(JSON_EXTRACT(content, '$.designated_logistics.group'), JSON_QUOTE(?))`,
4977
+ [group_key]
4978
+ );
4979
+
4980
+ const chunk = 10;
4981
+ const chunkLength = Math.ceil(getProducts.length / chunk);
4982
+
4983
+ for (let i = 0; i < chunkLength; i++) {
4984
+ const promisesArray = getProducts.slice(i * chunk, (i + 1) * chunk);
4985
+
4986
+ setTimeout(async () => {
4987
+ await Promise.all(
4988
+ promisesArray.map(async (product: any) => {
4989
+ product.content.designated_logistics.group = product.content.designated_logistics.group.filter(
4990
+ (item: string) => {
4991
+ return item !== group_key;
4992
+ }
4993
+ );
4994
+
4995
+ if (product.content.designated_logistics.group.length === 0) {
4996
+ delete product.content.designated_logistics.group;
4997
+ product.content.designated_logistics.type = 'all';
4998
+ }
4999
+
5000
+ // 更新商品
5001
+ await db.query(`UPDATE \`${this.app}\`.\`t_manager_post\` SET ? WHERE id = ?`, [
5002
+ {
5003
+ content: JSON.stringify(product.content),
5004
+ },
5005
+ product.id,
5006
+ ]);
5007
+ })
5008
+ );
5009
+ }, 200);
5010
+ }
5011
+
5012
+ return true;
5013
+ } catch (e) {
5014
+ console.error(e);
5015
+ throw exception.BadRequestError('BAD_REQUEST', 'removeLogisticGroup Error:' + e, null);
5016
+ }
5017
+ }
5018
+
4948
5019
  async updateCollectionFromUpdateProduct(collection: string[]) {
4949
5020
  collection = Array.from(
4950
5021
  new Set(
@@ -5859,3 +5930,4 @@ export class Shopping {
5859
5930
  }
5860
5931
  }
5861
5932
  }
5933
+
@@ -0,0 +1,8 @@
1
+ import { IPaymentStrategy, PaymentConfig, PaymentResult } from '../interface/payment-strategy-interface.js';
2
+ import { Cart } from '../shopping.js';
3
+ import { EcEzPayKeyData } from '../interface/payment-keys-interface';
4
+ export declare class EcPayStrategy implements IPaymentStrategy {
5
+ private readonly keys;
6
+ constructor(keys: EcEzPayKeyData);
7
+ initiatePayment(orderData: Cart, config: PaymentConfig): Promise<PaymentResult>;
8
+ }
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EcPayStrategy = void 0;
4
+ const financial_serviceV2_js_1 = require("../financial-serviceV2.js");
5
+ class EcPayStrategy {
6
+ constructor(keys) {
7
+ this.keys = keys;
8
+ }
9
+ async initiatePayment(orderData, config) {
10
+ const ecPayConfig = {
11
+ HASH_IV: this.keys.HASH_IV,
12
+ HASH_KEY: this.keys.HASH_KEY,
13
+ ActionURL: this.keys.ActionURL,
14
+ NotifyURL: `${config.domain}/api-public/v1/ec/notify?g-app=${config.app}&type=ecPay`,
15
+ ReturnURL: `${config.domain}/api-public/v1/ec/redirect?g-app=${config.app}&return=${config.id}`,
16
+ MERCHANT_ID: this.keys.MERCHANT_ID,
17
+ TYPE: 'ecPay',
18
+ };
19
+ console.log("ecPayConfig -- ", ecPayConfig);
20
+ const ecpayInstance = new financial_serviceV2_js_1.EcPayV2(config.app, ecPayConfig);
21
+ const formHtml = await ecpayInstance.executePayment(orderData);
22
+ return { form: formHtml };
23
+ }
24
+ }
25
+ exports.EcPayStrategy = EcPayStrategy;
26
+ //# sourceMappingURL=ecpay-strategy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ecpay-strategy.js","sourceRoot":"","sources":["ecpay-strategy.ts"],"names":[],"mappings":";;;AAEA,sEAA6D;AAG7D,MAAa,aAAa;IAIxB,YAAY,IAAoB;QAC9B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;IACD,KAAK,CAAC,eAAe,CAAC,SAAe,EAAE,MAAqB;QAC1D,MAAM,WAAW,GAAW;YAC1B,OAAO,EAAE,IAAI,CAAC,IAAI,CAAC,OAAO;YAC1B,QAAQ,EAAE,IAAI,CAAC,IAAI,CAAC,QAAQ;YAC5B,SAAS,EAAE,IAAI,CAAC,IAAI,CAAC,SAAS;YAC9B,SAAS,EAAE,GAAG,MAAM,CAAC,MAAM,kCAAkC,MAAM,CAAC,GAAG,aAAa;YACpF,SAAS,EAAE,GAAG,MAAM,CAAC,MAAM,oCAAoC,MAAM,CAAC,GAAG,WAAW,MAAM,CAAC,EAAE,EAAE;YAC/F,WAAW,EAAE,IAAI,CAAC,IAAI,CAAC,WAAW;YAClC,IAAI,EAAE,OAAO;SACd,CAAC;QACF,OAAO,CAAC,GAAG,CAAC,iBAAiB,EAAG,WAAW,CAAC,CAAC;QAC7C,MAAM,aAAa,GAAG,IAAI,gCAAO,CAAC,MAAM,CAAC,GAAG,EAAE,WAAW,CAAC,CAAC;QAG3D,MAAM,QAAQ,GAAG,MAAM,aAAa,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC;QAC/D,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;IAC5B,CAAC;CACF;AAxBD,sCAwBC"}
@@ -0,0 +1,30 @@
1
+ import { IPaymentStrategy, PaymentConfig, PaymentResult } from '../interface/payment-strategy-interface.js';
2
+ import { Cart } from '../shopping.js';
3
+ import { EcPayV2, KeyData } from '../financial-serviceV2.js';
4
+ import { EcEzPayKeyData } from '../interface/payment-keys-interface';
5
+
6
+ export class EcPayStrategy implements IPaymentStrategy {
7
+ private readonly keys: EcEzPayKeyData; // 持有 EcPay 專屬金鑰
8
+
9
+ //測試信用卡 4311-9511-1111-1111 驗證碼隨便
10
+ constructor(keys: EcEzPayKeyData) {
11
+ this.keys = keys;
12
+ }
13
+ async initiatePayment(orderData: Cart, config: PaymentConfig): Promise<PaymentResult> {
14
+ const ecPayConfig:KeyData = {
15
+ HASH_IV: this.keys.HASH_IV,
16
+ HASH_KEY: this.keys.HASH_KEY,
17
+ ActionURL: this.keys.ActionURL,
18
+ NotifyURL: `${config.domain}/api-public/v1/ec/notify?g-app=${config.app}&type=ecPay`,
19
+ ReturnURL: `${config.domain}/api-public/v1/ec/redirect?g-app=${config.app}&return=${config.id}`,
20
+ MERCHANT_ID: this.keys.MERCHANT_ID,
21
+ TYPE: 'ecPay' ,
22
+ };
23
+ console.log("ecPayConfig -- " , ecPayConfig);
24
+ const ecpayInstance = new EcPayV2(config.app, ecPayConfig);
25
+ // 注意:原始的 createOrderPage 可能需要更完整的 orderData,這裡直接傳入
26
+ // 您可能需要根據 EcPay 類別的實際需要調整傳遞給 createOrderPage 的參數
27
+ const formHtml = await ecpayInstance.executePayment(orderData);
28
+ return { form: formHtml };
29
+ }
30
+ }
@@ -0,0 +1,8 @@
1
+ import { IPaymentStrategy, PaymentConfig, PaymentResult } from '../interface/payment-strategy-interface.js';
2
+ import { Cart } from '../shopping.js';
3
+ import { EcEzPayKeyData } from '../interface/payment-keys-interface';
4
+ export declare class EzPayStrategy implements IPaymentStrategy {
5
+ private readonly keys;
6
+ constructor(keys: EcEzPayKeyData);
7
+ initiatePayment(orderData: Cart, config: PaymentConfig): Promise<PaymentResult>;
8
+ }
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EzPayStrategy = void 0;
4
+ const financial_serviceV2_js_1 = require("../financial-serviceV2.js");
5
+ class EzPayStrategy {
6
+ constructor(keys) {
7
+ this.keys = keys;
8
+ }
9
+ async initiatePayment(orderData, config) {
10
+ const ezPayConfig = {
11
+ HASH_IV: this.keys.HASH_IV,
12
+ HASH_KEY: this.keys.HASH_KEY,
13
+ ActionURL: this.keys.ActionURL,
14
+ NotifyURL: `${config.domain}/api-public/v1/ec/notify?g-app=${config.app}&type=newWebPay`,
15
+ ReturnURL: `${config.domain}/api-public/v1/ec/redirect?g-app=${config.app}&return=${config.id}`,
16
+ MERCHANT_ID: this.keys.MERCHANT_ID,
17
+ TYPE: 'newWebPay',
18
+ };
19
+ const ezpayInstance = new financial_serviceV2_js_1.EzPayV2(config.app, ezPayConfig);
20
+ console.log('ezPayConfig -- ', ezPayConfig);
21
+ const formHtml = await ezpayInstance.executePayment(orderData);
22
+ return { form: formHtml };
23
+ }
24
+ }
25
+ exports.EzPayStrategy = EzPayStrategy;
26
+ //# sourceMappingURL=ezpay-strategy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ezpay-strategy.js","sourceRoot":"","sources":["ezpay-strategy.ts"],"names":[],"mappings":";;;AAEA,sEAA8D;AAI9D,MAAa,aAAa;IAIxB,YAAY,IAAoB;QAC9B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;IACD,KAAK,CAAC,eAAe,CAAC,SAAe,EAAE,MAAqB;QAC1D,MAAM,WAAW,GAAW;YAC1B,OAAO,EAAE,IAAI,CAAC,IAAI,CAAC,OAAO;YAC1B,QAAQ,EAAE,IAAI,CAAC,IAAI,CAAC,QAAQ;YAC5B,SAAS,EAAE,IAAI,CAAC,IAAI,CAAC,SAAS;YAC9B,SAAS,EAAE,GAAG,MAAM,CAAC,MAAM,kCAAkC,MAAM,CAAC,GAAG,iBAAiB;YACxF,SAAS,EAAE,GAAG,MAAM,CAAC,MAAM,oCAAoC,MAAM,CAAC,GAAG,WAAW,MAAM,CAAC,EAAE,EAAE;YAC/F,WAAW,EAAE,IAAI,CAAC,IAAI,CAAC,WAAW;YAClC,IAAI,EAAE,WAAW;SAClB,CAAC;QACF,MAAM,aAAa,GAAG,IAAI,gCAAO,CAAC,MAAM,CAAC,GAAG,EAAE,WAAW,CAAC,CAAC;QAC3D,OAAO,CAAC,GAAG,CACT,iBAAiB,EACjB,WAAW,CAAE,CAAC;QAChB,MAAM,QAAQ,GAAG,MAAM,aAAa,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC;QAC/D,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;IAC5B,CAAC;CACF;AAxBD,sCAwBC"}
@@ -0,0 +1,31 @@
1
+ import { IPaymentStrategy, PaymentConfig, PaymentResult } from '../interface/payment-strategy-interface.js';
2
+ import { Cart } from '../shopping.js';
3
+ import { EzPayV2, KeyData } from '../financial-serviceV2.js';
4
+ import { EcEzPayKeyData } from '../interface/payment-keys-interface';
5
+ //藍新金流
6
+ //測試信用卡 4000 2211 1111 1111 驗證碼123
7
+ export class EzPayStrategy implements IPaymentStrategy {
8
+ private readonly keys: EcEzPayKeyData;
9
+
10
+ // **** 建構子接收 EcPayKeyData ****
11
+ constructor(keys: EcEzPayKeyData) {
12
+ this.keys = keys;
13
+ }
14
+ async initiatePayment(orderData: Cart, config: PaymentConfig): Promise<PaymentResult> {
15
+ const ezPayConfig:KeyData = {
16
+ HASH_IV: this.keys.HASH_IV,
17
+ HASH_KEY: this.keys.HASH_KEY,
18
+ ActionURL: this.keys.ActionURL,
19
+ NotifyURL: `${config.domain}/api-public/v1/ec/notify?g-app=${config.app}&type=newWebPay`,
20
+ ReturnURL: `${config.domain}/api-public/v1/ec/redirect?g-app=${config.app}&return=${config.id}`,
21
+ MERCHANT_ID: this.keys.MERCHANT_ID,
22
+ TYPE: 'newWebPay' ,
23
+ };
24
+ const ezpayInstance = new EzPayV2(config.app, ezPayConfig);
25
+ console.log(
26
+ 'ezPayConfig -- ',
27
+ ezPayConfig,);
28
+ const formHtml = await ezpayInstance.executePayment(orderData);
29
+ return { form: formHtml };
30
+ }
31
+ }
@@ -0,0 +1,8 @@
1
+ import { IPaymentStrategy, PaymentConfig, PaymentResult } from '../interface/payment-strategy-interface.js';
2
+ import { Cart } from '../shopping.js';
3
+ import { JkoPayKeyData } from '../interface/payment-keys-interface';
4
+ export declare class JkoPayStrategy implements IPaymentStrategy {
5
+ private readonly keys;
6
+ constructor(keys: JkoPayKeyData);
7
+ initiatePayment(orderData: Cart, config: PaymentConfig): Promise<PaymentResult>;
8
+ }
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.JkoPayStrategy = void 0;
4
+ const financial_serviceV2_js_1 = require("../financial-serviceV2.js");
5
+ class JkoPayStrategy {
6
+ constructor(keys) {
7
+ this.keys = keys;
8
+ }
9
+ async initiatePayment(orderData, config) {
10
+ const jkoPayConfig = {
11
+ ReturnURL: `${process.env.DOMAIN}/api-public/v1/ec/redirect?g-app=${config.app}&return=${config.id}&type=jkopay`,
12
+ NotifyURL: `${process.env.DOMAIN}/api-public/v1/ec/notify?g-app=${config.app}&type=jkopay`,
13
+ API_KEY: this.keys.API_KEY,
14
+ SECRET_KEY: this.keys.SECRET_KEY,
15
+ STORE_ID: this.keys.STORE_ID,
16
+ TYPE: 'jkopay',
17
+ };
18
+ const jkoPayInstance = new financial_serviceV2_js_1.JKOV2(config.app, {
19
+ API_KEY: jkoPayConfig.API_KEY,
20
+ NotifyURL: jkoPayConfig.NotifyURL,
21
+ ReturnURL: jkoPayConfig.ReturnURL,
22
+ SECRET_KEY: jkoPayConfig.SECRET_KEY,
23
+ STORE_ID: jkoPayConfig.STORE_ID,
24
+ });
25
+ const returnData = await jkoPayInstance.executePayment(orderData);
26
+ return {
27
+ responseData: returnData,
28
+ };
29
+ }
30
+ }
31
+ exports.JkoPayStrategy = JkoPayStrategy;
32
+ //# sourceMappingURL=jkopay-strategy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jkopay-strategy.js","sourceRoot":"","sources":["jkopay-strategy.ts"],"names":[],"mappings":";;;AAEA,sEAAyF;AAGzF,MAAa,cAAc;IAIzB,YAAY,IAAmB;QAC7B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;IACD,KAAK,CAAC,eAAe,CAAC,SAAe,EAAE,MAAqB;QAC1D,MAAM,YAAY,GAAG;YACnB,SAAS,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,oCAAoC,MAAM,CAAC,GAAG,WAAW,MAAM,CAAC,EAAE,cAAc;YAChH,SAAS,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,kCAAkC,MAAM,CAAC,GAAG,cAAc;YAC1F,OAAO,EAAE,IAAI,CAAC,IAAI,CAAC,OAAiB;YACpC,UAAU,EAAE,IAAI,CAAC,IAAI,CAAC,UAAoB;YAC1C,QAAQ,EAAC,IAAI,CAAC,IAAI,CAAC,QAAQ;YAC3B,IAAI,EAAE,QAAQ;SACf,CAAC;QAEF,MAAM,cAAc,GAAG,IAAI,8BAAK,CAAC,MAAM,CAAC,GAAG,EAAE;YAC3C,OAAO,EAAE,YAAY,CAAC,OAAO;YAC7B,SAAS,EAAE,YAAY,CAAC,SAAS;YACjC,SAAS,EAAE,YAAY,CAAC,SAAS;YACjC,UAAU,EAAE,YAAY,CAAC,UAAU;YACnC,QAAQ,EAAE,YAAY,CAAC,QAAQ;SAChC,CAAC,CAAC;QAEH,MAAM,UAAU,GAAG,MAAM,cAAc,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC;QAClE,OAAO;YACL,YAAY,EAAE,UAAU;SACzB,CAAC;IACJ,CAAC;CACF;AA9BD,wCA8BC"}
@@ -0,0 +1,36 @@
1
+ import { IPaymentStrategy, PaymentConfig, PaymentResult } from '../interface/payment-strategy-interface.js';
2
+ import { Cart } from '../shopping.js';
3
+ import { EcPayV2, JKOV2, KeyData, LinePayV2, PayPalV2 } from '../financial-serviceV2.js';
4
+ import { JkoPayKeyData } from '../interface/payment-keys-interface';
5
+
6
+ export class JkoPayStrategy implements IPaymentStrategy {
7
+ private readonly keys: JkoPayKeyData; // 持有 EcPay 專屬金鑰
8
+
9
+ // **** 建構子接收 EcPayKeyData ****
10
+ constructor(keys: JkoPayKeyData) {
11
+ this.keys = keys;
12
+ }
13
+ async initiatePayment(orderData: Cart, config: PaymentConfig): Promise<PaymentResult> {
14
+ const jkoPayConfig = {
15
+ ReturnURL: `${process.env.DOMAIN}/api-public/v1/ec/redirect?g-app=${config.app}&return=${config.id}&type=jkopay`,
16
+ NotifyURL: `${process.env.DOMAIN}/api-public/v1/ec/notify?g-app=${config.app}&type=jkopay`,
17
+ API_KEY: this.keys.API_KEY as string,
18
+ SECRET_KEY: this.keys.SECRET_KEY as string,
19
+ STORE_ID:this.keys.STORE_ID,
20
+ TYPE: 'jkopay',
21
+ };
22
+
23
+ const jkoPayInstance = new JKOV2(config.app, {
24
+ API_KEY: jkoPayConfig.API_KEY,
25
+ NotifyURL: jkoPayConfig.NotifyURL,
26
+ ReturnURL: jkoPayConfig.ReturnURL,
27
+ SECRET_KEY: jkoPayConfig.SECRET_KEY,
28
+ STORE_ID: jkoPayConfig.STORE_ID,
29
+ });
30
+
31
+ const returnData = await jkoPayInstance.executePayment(orderData);
32
+ return {
33
+ responseData: returnData,
34
+ };
35
+ }
36
+ }
@@ -0,0 +1,8 @@
1
+ import { IPaymentStrategy, PaymentConfig, PaymentResult } from '../interface/payment-strategy-interface.js';
2
+ import { Cart } from '../shopping.js';
3
+ import { LinePayKeyData } from '../interface/payment-keys-interface';
4
+ export declare class LinePayStrategy implements IPaymentStrategy {
5
+ private readonly keys;
6
+ constructor(keys: LinePayKeyData);
7
+ initiatePayment(orderData: Cart, config: PaymentConfig): Promise<PaymentResult>;
8
+ }
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LinePayStrategy = void 0;
4
+ const financial_serviceV2_js_1 = require("../financial-serviceV2.js");
5
+ class LinePayStrategy {
6
+ constructor(keys) {
7
+ this.keys = keys;
8
+ }
9
+ async initiatePayment(orderData, config) {
10
+ var _a, _b, _c;
11
+ const linePayConfig = {
12
+ ReturnURL: `${process.env.DOMAIN}/api-public/v1/ec/repay_redirect?g-app=${config.app}&return=${config.id}&type=LinePay`,
13
+ NotifyURL: `${process.env.DOMAIN}/api-public/v1/ec/notify?g-app=${config.app}&type=LinePay`,
14
+ LinePay_CLIENT_ID: this.keys.CLIENT_ID,
15
+ LinePay_SECRET: this.keys.SECRET,
16
+ TYPE: 'line_pay',
17
+ BETA: (_c = (_b = (_a = this.keys) === null || _a === void 0 ? void 0 : _a.BETA) === null || _b === void 0 ? void 0 : _b.toString()) !== null && _c !== void 0 ? _c : 'false',
18
+ };
19
+ const linePayInstance = new financial_serviceV2_js_1.LinePayV2(config.app, {
20
+ BETA: linePayConfig.BETA,
21
+ LinePay_CLIENT_ID: linePayConfig.LinePay_CLIENT_ID,
22
+ LinePay_SECRET: linePayConfig.LinePay_SECRET,
23
+ ReturnURL: linePayConfig.ReturnURL,
24
+ });
25
+ const returnData = await linePayInstance.executePayment(orderData);
26
+ return {
27
+ responseData: returnData,
28
+ };
29
+ }
30
+ }
31
+ exports.LinePayStrategy = LinePayStrategy;
32
+ //# sourceMappingURL=linepay-strategy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"linepay-strategy.js","sourceRoot":"","sources":["linepay-strategy.ts"],"names":[],"mappings":";;;AAEA,sEAAkF;AAGlF,MAAa,eAAe;IAI1B,YAAY,IAAoB;QAC9B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;IACD,KAAK,CAAC,eAAe,CAAC,SAAe,EAAE,MAAqB;;QAC1D,MAAM,aAAa,GAAG;YACpB,SAAS,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,0CAA0C,MAAM,CAAC,GAAG,WAAW,MAAM,CAAC,EAAE,eAAe;YACvH,SAAS,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,kCAAkC,MAAM,CAAC,GAAG,eAAe;YAC3F,iBAAiB,EAAE,IAAI,CAAC,IAAI,CAAC,SAAmB;YAChD,cAAc,EAAE,IAAI,CAAC,IAAI,CAAC,MAAgB;YAC1C,IAAI,EAAE,UAAU;YAChB,IAAI,EAAE,MAAA,MAAA,MAAA,IAAI,CAAC,IAAI,0CAAE,IAAI,0CAAE,QAAQ,EAAE,mCAAI,OAAO;SAC7C,CAAC;QACF,MAAM,eAAe,GAAG,IAAI,kCAAS,CAAC,MAAM,CAAC,GAAG,EAAE;YAChD,IAAI,EAAE,aAAa,CAAC,IAAI;YACxB,iBAAiB,EAAE,aAAa,CAAC,iBAAiB;YAClD,cAAc,EAAE,aAAa,CAAC,cAAc;YAC5C,SAAS,EAAE,aAAa,CAAC,SAAS;SAEnC,CAAC,CAAC;QAEH,MAAM,UAAU,GAAG,MAAM,eAAe,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC;QACnE,OAAO;YACL,YAAY,EAAE,UAAU;SACzB,CAAC;IACJ,CAAC;CACF;AA7BD,0CA6BC"}
@@ -0,0 +1,35 @@
1
+ import { IPaymentStrategy, PaymentConfig, PaymentResult } from '../interface/payment-strategy-interface.js';
2
+ import { Cart } from '../shopping.js';
3
+ import { EcPayV2, KeyData, LinePayV2, PayPalV2 } from '../financial-serviceV2.js';
4
+ import { EcEzPayKeyData, LinePayKeyData } from '../interface/payment-keys-interface';
5
+
6
+ export class LinePayStrategy implements IPaymentStrategy {
7
+ private readonly keys: LinePayKeyData; // 持有 EcPay 專屬金鑰
8
+
9
+ // **** 建構子接收 EcPayKeyData ****
10
+ constructor(keys: LinePayKeyData) {
11
+ this.keys = keys;
12
+ }
13
+ async initiatePayment(orderData: Cart, config: PaymentConfig): Promise<PaymentResult> {
14
+ const linePayConfig = {
15
+ ReturnURL: `${process.env.DOMAIN}/api-public/v1/ec/repay_redirect?g-app=${config.app}&return=${config.id}&type=LinePay`,
16
+ NotifyURL: `${process.env.DOMAIN}/api-public/v1/ec/notify?g-app=${config.app}&type=LinePay`,
17
+ LinePay_CLIENT_ID: this.keys.CLIENT_ID as string,
18
+ LinePay_SECRET: this.keys.SECRET as string,
19
+ TYPE: 'line_pay',
20
+ BETA: this.keys?.BETA?.toString() ?? 'false',
21
+ };
22
+ const linePayInstance = new LinePayV2(config.app, {
23
+ BETA: linePayConfig.BETA,
24
+ LinePay_CLIENT_ID: linePayConfig.LinePay_CLIENT_ID,
25
+ LinePay_SECRET: linePayConfig.LinePay_SECRET,
26
+ ReturnURL: linePayConfig.ReturnURL,
27
+
28
+ });
29
+
30
+ const returnData = await linePayInstance.executePayment(orderData);
31
+ return {
32
+ responseData: returnData,
33
+ };
34
+ }
35
+ }
@@ -0,0 +1,8 @@
1
+ import { IPaymentStrategy, PaymentConfig, PaymentResult } from '../interface/payment-strategy-interface.js';
2
+ import { Cart } from '../shopping.js';
3
+ import { PayNowKeyData } from '../interface/payment-keys-interface';
4
+ export declare class PayNowStrategy implements IPaymentStrategy {
5
+ private readonly keys;
6
+ constructor(keys: PayNowKeyData);
7
+ initiatePayment(orderData: Cart, config: PaymentConfig): Promise<PaymentResult>;
8
+ }
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PayNowStrategy = void 0;
4
+ const financial_serviceV2_js_1 = require("../financial-serviceV2.js");
5
+ class PayNowStrategy {
6
+ constructor(keys) {
7
+ this.keys = keys;
8
+ }
9
+ async initiatePayment(orderData, config) {
10
+ const payNowConfig = {
11
+ ReturnURL: `${process.env.DOMAIN}/api-public/v1/ec/redirect?g-app=${config.app}&return=${config.id}&type=paynow&paynow=true`,
12
+ NotifyURL: `${process.env.DOMAIN}/api-public/v1/ec/notify?g-app=${config.app}&paynow=true&type=paynow`,
13
+ PrivateKey: this.keys.PrivateKey,
14
+ PublicKey: this.keys.PublicKey,
15
+ BETA: this.keys.BETA,
16
+ TYPE: 'paynow',
17
+ };
18
+ const payNowInstance = new financial_serviceV2_js_1.PayNowV2(config.app, payNowConfig);
19
+ const returnData = await payNowInstance.executePayment(orderData);
20
+ return {
21
+ responseData: returnData,
22
+ };
23
+ }
24
+ }
25
+ exports.PayNowStrategy = PayNowStrategy;
26
+ //# sourceMappingURL=paynow-strategy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"paynow-strategy.js","sourceRoot":"","sources":["paynow-strategy.ts"],"names":[],"mappings":";;;AAEA,sEAAmG;AAGnG,MAAa,cAAc;IAIzB,YAAY,IAAmB;QAC7B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;IACD,KAAK,CAAC,eAAe,CAAC,SAAe,EAAE,MAAqB;QAC1D,MAAM,YAAY,GAAG;YACnB,SAAS,EAAG,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,oCAAoC,MAAM,CAAC,GAAG,WAAW,MAAM,CAAC,EAAE,0BAA0B;YAC7H,SAAS,EAAG,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,kCAAkC,MAAM,CAAC,GAAG,0BAA0B;YAEvG,UAAU,EAAC,IAAI,CAAC,IAAI,CAAC,UAAU;YAC/B,SAAS,EAAC,IAAI,CAAC,IAAI,CAAC,SAAS;YAC7B,IAAI,EAAC,IAAI,CAAC,IAAI,CAAC,IAAI;YACnB,IAAI,EAAE,QAAQ;SACf,CAAC;QACF,MAAM,cAAc,GAAG,IAAI,iCAAQ,CAAC,MAAM,CAAC,GAAG,EAAE,YAAY,CAAC,CAAC;QAC9D,MAAM,UAAU,GAAG,MAAM,cAAc,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC;QAClE,OAAO;YACL,YAAY,EAAE,UAAU;SACzB,CAAC;IACJ,CAAC;CACF;AAvBD,wCAuBC"}
@@ -0,0 +1,29 @@
1
+ import { IPaymentStrategy, PaymentConfig, PaymentResult } from '../interface/payment-strategy-interface.js';
2
+ import { Cart } from '../shopping.js';
3
+ import { EcPayV2, JKOV2, KeyData, LinePayV2, PayNowV2, PayPalV2 } from '../financial-serviceV2.js';
4
+ import { JkoPayKeyData, PayNowKeyData } from '../interface/payment-keys-interface';
5
+
6
+ export class PayNowStrategy implements IPaymentStrategy {
7
+ private readonly keys: PayNowKeyData; // 持有 EcPay 專屬金鑰
8
+
9
+ // **** 建構子接收 EcPayKeyData ****
10
+ constructor(keys: PayNowKeyData) {
11
+ this.keys = keys;
12
+ }
13
+ async initiatePayment(orderData: Cart, config: PaymentConfig): Promise<PaymentResult> {
14
+ const payNowConfig = {
15
+ ReturnURL : `${process.env.DOMAIN}/api-public/v1/ec/redirect?g-app=${config.app}&return=${config.id}&type=paynow&paynow=true`,
16
+ NotifyURL : `${process.env.DOMAIN}/api-public/v1/ec/notify?g-app=${config.app}&paynow=true&type=paynow`,
17
+
18
+ PrivateKey:this.keys.PrivateKey,
19
+ PublicKey:this.keys.PublicKey,
20
+ BETA:this.keys.BETA,
21
+ TYPE: 'paynow',
22
+ };
23
+ const payNowInstance = new PayNowV2(config.app, payNowConfig);
24
+ const returnData = await payNowInstance.executePayment(orderData);
25
+ return {
26
+ responseData: returnData,
27
+ };
28
+ }
29
+ }
@@ -0,0 +1,8 @@
1
+ import { IPaymentStrategy, PaymentConfig, PaymentResult } from '../interface/payment-strategy-interface.js';
2
+ import { Cart } from '../shopping.js';
3
+ import { PayPalKeyData } from '../interface/payment-keys-interface';
4
+ export declare class PayPalStrategy implements IPaymentStrategy {
5
+ private readonly keys;
6
+ constructor(keys: PayPalKeyData);
7
+ initiatePayment(orderData: Cart, config: PaymentConfig): Promise<PaymentResult>;
8
+ }
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PayPalStrategy = void 0;
4
+ const financial_serviceV2_js_1 = require("../financial-serviceV2.js");
5
+ class PayPalStrategy {
6
+ constructor(keys) {
7
+ this.keys = keys;
8
+ }
9
+ async initiatePayment(orderData, config) {
10
+ var _a, _b, _c;
11
+ const payPalConfig = {
12
+ NotifyURL: `${config.domain}/api-public/v1/ec/notify?g-app=${config.app}&type=PayPal`,
13
+ ReturnURL: `${config.domain}/api-public/v1/ec/redirect?g-app=${config.app}&return=${config.id}`,
14
+ PAYPAL_CLIENT_ID: this.keys.PAYPAL_CLIENT_ID,
15
+ PAYPAL_SECRET: this.keys.PAYPAL_SECRET,
16
+ TYPE: 'PayPal',
17
+ BETA: (_c = (_b = (_a = this.keys) === null || _a === void 0 ? void 0 : _a.BETA) === null || _b === void 0 ? void 0 : _b.toString()) !== null && _c !== void 0 ? _c : 'false',
18
+ };
19
+ const payPalInstance = new financial_serviceV2_js_1.PayPalV2(config.app, payPalConfig);
20
+ const returnData = await payPalInstance.checkout(orderData);
21
+ return {
22
+ orderId: returnData.orderId,
23
+ approveLink: returnData.approveLink,
24
+ };
25
+ }
26
+ }
27
+ exports.PayPalStrategy = PayPalStrategy;
28
+ //# sourceMappingURL=paypal-strategy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"paypal-strategy.js","sourceRoot":"","sources":["paypal-strategy.ts"],"names":[],"mappings":";;;AAEA,sEAAuE;AAGvE,MAAa,cAAc;IAIzB,YAAY,IAAmB;QAC7B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;IACD,KAAK,CAAC,eAAe,CAAC,SAAe,EAAE,MAAqB;;QAC1D,MAAM,YAAY,GAAG;YACnB,SAAS,EAAE,GAAG,MAAM,CAAC,MAAM,kCAAkC,MAAM,CAAC,GAAG,cAAc;YACrF,SAAS,EAAE,GAAG,MAAM,CAAC,MAAM,oCAAoC,MAAM,CAAC,GAAG,WAAW,MAAM,CAAC,EAAE,EAAE;YAC/F,gBAAgB,EAAE,IAAI,CAAC,IAAI,CAAC,gBAA0B;YACtD,aAAa,EAAE,IAAI,CAAC,IAAI,CAAC,aAAuB;YAChD,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,MAAA,MAAA,MAAA,IAAI,CAAC,IAAI,0CAAE,IAAI,0CAAE,QAAQ,EAAE,mCAAK,OAAO;SAC9C,CAAC;QAEF,MAAM,cAAc,GAAG,IAAI,iCAAQ,CAAC,MAAM,CAAC,GAAG,EAAG,YAAY,CAAC,CAAC;QAE/D,MAAM,UAAU,GAAG,MAAM,cAAc,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;QAC5D,OAAO;YACL,OAAO,EAAE,UAAU,CAAC,OAAO;YAC3B,WAAW,EAAE,UAAU,CAAC,WAAW;SACpC,CAAC;IACJ,CAAC;CACF;AAzBD,wCAyBC"}
@@ -0,0 +1,31 @@
1
+ import { IPaymentStrategy, PaymentConfig, PaymentResult } from '../interface/payment-strategy-interface.js';
2
+ import { Cart } from '../shopping.js';
3
+ import { EcPayV2, KeyData, PayPalV2 } from '../financial-serviceV2.js';
4
+ import { PayPalKeyData } from '../interface/payment-keys-interface';
5
+
6
+ export class PayPalStrategy implements IPaymentStrategy {
7
+ private readonly keys: PayPalKeyData;
8
+
9
+ // **** 建構子接收 EcPayKeyData ****
10
+ constructor(keys: PayPalKeyData) {
11
+ this.keys = keys;
12
+ }
13
+ async initiatePayment(orderData: Cart, config: PaymentConfig): Promise<PaymentResult> {
14
+ const payPalConfig = {
15
+ NotifyURL: `${config.domain}/api-public/v1/ec/notify?g-app=${config.app}&type=PayPal`,
16
+ ReturnURL: `${config.domain}/api-public/v1/ec/redirect?g-app=${config.app}&return=${config.id}`,
17
+ PAYPAL_CLIENT_ID: this.keys.PAYPAL_CLIENT_ID as string,
18
+ PAYPAL_SECRET: this.keys.PAYPAL_SECRET as string,
19
+ TYPE: 'PayPal',
20
+ BETA: this.keys?.BETA?.toString() ?? 'false',
21
+ };
22
+
23
+ const payPalInstance = new PayPalV2(config.app , payPalConfig);
24
+
25
+ const returnData = await payPalInstance.checkout(orderData);
26
+ return {
27
+ orderId: returnData.orderId,
28
+ approveLink: returnData.approveLink,
29
+ };
30
+ }
31
+ }
@@ -5,6 +5,7 @@ export declare class UpdatedTableChecked {
5
5
  table_name: string;
6
6
  last_version: string[];
7
7
  new_version: string;
8
+ beta?: boolean;
8
9
  event: string | (() => Promise<any>);
9
10
  }): Promise<void>;
10
11
  }