cgserver 6.2.11 → 6.3.0

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.
@@ -2,11 +2,13 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.GAlipayTool = void 0;
4
4
  const alipay_sdk_1 = require("alipay-sdk");
5
+ const aliUtil = require("alipay-sdk/lib/util");
5
6
  const AliPayUtil_1 = require("alipay_sdk2/AliPayUtil");
6
7
  const fs = require("fs");
7
8
  const FrameworkConfig_1 = require("../Config/FrameworkConfig");
8
9
  const form_1 = require("alipay-sdk/lib/form");
9
10
  const Log_1 = require("../Logic/Log");
11
+ const cgserver_1 = require("../cgserver");
10
12
  exports.GAlipayTool = null;
11
13
  class AlipayTool {
12
14
  _alipaySdk = null;
@@ -66,6 +68,46 @@ class AlipayTool {
66
68
  });
67
69
  }
68
70
  }
71
+ /**
72
+ * charset:"utf-8",method:"alipay.trade.app.pay",sign_type:"RSA2,version:"1.0"
73
+ * @param out_trade_no
74
+ * @param total_amount
75
+ * @param subject
76
+ * @param body
77
+ * @param timeout_express
78
+ * @param product_code
79
+ * @returns
80
+ */
81
+ _buildOrderParams(out_trade_no, total_amount, subject = "1", body = "我是测试数据", timeout_express = "30m", product_code = "QUICK_MSECURITY_PAY") {
82
+ let order_params = {
83
+ app_id: this._cfg.app_id,
84
+ biz_content: JSON.stringify({
85
+ timeout_express: timeout_express,
86
+ product_code: product_code,
87
+ total_amount: total_amount + "",
88
+ subject: encodeURIComponent(subject),
89
+ body: encodeURIComponent(body),
90
+ out_trade_no: out_trade_no
91
+ }),
92
+ charset: "utf-8",
93
+ method: "alipay.trade.app.pay",
94
+ sign_type: "RSA2",
95
+ timestamp: cgserver_1.core.format(Date.now(), "yyyy-MM-dd hh:mm::ss"),
96
+ version: "1.0"
97
+ };
98
+ return order_params;
99
+ }
100
+ _sign(order_params) {
101
+ let sign = aliUtil.sign("alipay.trade.app.pay", order_params, this._alipaySdk.config);
102
+ return sign;
103
+ }
104
+ getOrderInfo(out_trade_no, total_amount, subject = "1", body = "我是测试数据") {
105
+ let order_params = this._buildOrderParams(out_trade_no, total_amount, subject, body);
106
+ let sign = this._sign(order_params);
107
+ let { url, execParams } = this._alipaySdk["formatUrl"]("", sign);
108
+ const order_info = (url + '&biz_content=' + encodeURIComponent(execParams.biz_content)).substring(1);
109
+ return order_info;
110
+ }
69
111
  /**
70
112
  *
71
113
  * @param title
@@ -17,6 +17,27 @@ declare class AlipayTool {
17
17
  notify_url: string;
18
18
  };
19
19
  init(): boolean;
20
+ /**
21
+ * charset:"utf-8",method:"alipay.trade.app.pay",sign_type:"RSA2,version:"1.0"
22
+ * @param out_trade_no
23
+ * @param total_amount
24
+ * @param subject
25
+ * @param body
26
+ * @param timeout_express
27
+ * @param product_code
28
+ * @returns
29
+ */
30
+ protected _buildOrderParams(out_trade_no: string, total_amount: number, subject?: string, body?: string, timeout_express?: string, product_code?: string): {
31
+ app_id: string;
32
+ biz_content: string;
33
+ charset: string;
34
+ method: string;
35
+ sign_type: string;
36
+ timestamp: any;
37
+ version: string;
38
+ };
39
+ protected _sign(order_params: any): any;
40
+ getOrderInfo(out_trade_no: string, total_amount: number, subject?: string, body?: string): string;
20
41
  /**
21
42
  *
22
43
  * @param title
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cgserver",
3
- "version": "6.2.11",
3
+ "version": "6.3.0",
4
4
  "author": "trojan",
5
5
  "type": "commonjs",
6
6
  "description": "free for all.Websocket or Http",
@@ -46,7 +46,6 @@
46
46
  "@types/underscore": "^1.11.3",
47
47
  "@types/urlencode": "^1.1.2",
48
48
  "@types/websocket": "^1.0.4",
49
- "alipay_sdk2": "^1.1.6",
50
49
  "alipay-sdk": "^3.1.7",
51
50
  "colors": "^1.4.0",
52
51
  "cookie-parser": "^1.4.5",