oak-pay-business 3.1.0 → 3.1.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.
@@ -83,8 +83,8 @@ const checkers = [
83
83
  }
84
84
  switch (type) {
85
85
  case 'web': {
86
- const { wechat } = config;
87
- if (!wechat?.appId) {
86
+ const { wechatPay } = config;
87
+ if (!wechatPay?.appId) {
88
88
  throw new OakInputIllegalException('wpProduct', ['applicationId'], 'error::wpProduct.NoWechatInfoOnApp', 'oak-pay-business');
89
89
  }
90
90
  break;
@@ -29,6 +29,10 @@ export type WebConfig = {
29
29
  domain?: string;
30
30
  enable?: boolean;
31
31
  };
32
+ wechatPay?: {
33
+ appId: string;
34
+ appSecret: string;
35
+ };
32
36
  passport?: Passport[];
33
37
  location: {
34
38
  protocol: "http:" | "https:";
@@ -36,14 +40,12 @@ export type WebConfig = {
36
40
  port: string;
37
41
  };
38
42
  };
39
- export type WechatPublicTemplateMsgsConfig = Record<string, string>;
40
43
  export type WechatPublicConfig = {
41
44
  type: "wechatPublic";
42
45
  isService: boolean;
43
46
  appId: string;
44
47
  appSecret: string;
45
48
  originalId?: string;
46
- templateMsgs?: WechatPublicTemplateMsgsConfig;
47
49
  server?: {
48
50
  url?: string;
49
51
  token: string;
@@ -181,6 +181,7 @@ export default class AliPay extends AliPayDebug {
181
181
  const out_trade_no = compressTo32(pay.id);
182
182
  // 支付宝金额单位为元,需要转换
183
183
  const totalAmount = ToYuan(pay.price);
184
+ const timeoutAt = Date.now() + PREPAY_TIMEOUT;
184
185
  switch (this.apProduct.type) {
185
186
  case 'native': {
186
187
  const method = this.apProduct.config?.prepayMethod || 'GET';
@@ -196,6 +197,7 @@ export default class AliPay extends AliPayDebug {
196
197
  notify_url: payNotifyUrl,
197
198
  qr_pay_mode: qrPayMode,
198
199
  qrcode_width: qrCodeWidth,
200
+ time_expire: dayJs(timeoutAt).format('YYYY-MM-DD HH:mm:ss'),
199
201
  },
200
202
  notify_url: payNotifyUrl,
201
203
  needEncrypt: this.needEncrypt,
@@ -217,7 +219,7 @@ export default class AliPay extends AliPayDebug {
217
219
  }
218
220
  }
219
221
  // pay加一个过期时间,到期自动close
220
- data.timeoutAt = Date.now() + PREPAY_TIMEOUT;
222
+ data.timeoutAt = timeoutAt + 1000 * 60;
221
223
  }
222
224
  async getState(pay) {
223
225
  const outTradeNo = compressTo32(pay.id);
@@ -280,10 +282,6 @@ export default class AliPay extends AliPayDebug {
280
282
  this.analyzeResult(result);
281
283
  }
282
284
  catch (e) {
283
- // 在电脑网站下单时,系统首先生成URL;用户扫码后才会创建交易订单。若未完成扫码而订单过期到了直接关闭,提示'交易不存在'。
284
- if (e.code === 'ACQ.TRADE_NOT_EXIST') {
285
- return;
286
- }
287
285
  throw e;
288
286
  }
289
287
  }
@@ -81,9 +81,9 @@ const PayClazzEntityDict = {
81
81
  assert(wpProduct.enabled && wpProduct.wpAccount?.enabled);
82
82
  switch (type) {
83
83
  case 'web': {
84
- const { wechat } = config;
85
- assert(wechat);
86
- const appId = wechat.appId;
84
+ const { wechatPay } = config;
85
+ assert(wechatPay);
86
+ const appId = wechatPay.appId;
87
87
  return new WechatPay(wpProduct, appId);
88
88
  }
89
89
  case 'wechatMp': {
@@ -86,8 +86,8 @@ const checkers = [
86
86
  }
87
87
  switch (type) {
88
88
  case 'web': {
89
- const { wechat } = config;
90
- if (!wechat?.appId) {
89
+ const { wechatPay } = config;
90
+ if (!wechatPay?.appId) {
91
91
  throw new types_1.OakInputIllegalException('wpProduct', ['applicationId'], 'error::wpProduct.NoWechatInfoOnApp', 'oak-pay-business');
92
92
  }
93
93
  break;
@@ -29,6 +29,10 @@ export type WebConfig = {
29
29
  domain?: string;
30
30
  enable?: boolean;
31
31
  };
32
+ wechatPay?: {
33
+ appId: string;
34
+ appSecret: string;
35
+ };
32
36
  passport?: Passport[];
33
37
  location: {
34
38
  protocol: "http:" | "https:";
@@ -36,14 +40,12 @@ export type WebConfig = {
36
40
  port: string;
37
41
  };
38
42
  };
39
- export type WechatPublicTemplateMsgsConfig = Record<string, string>;
40
43
  export type WechatPublicConfig = {
41
44
  type: "wechatPublic";
42
45
  isService: boolean;
43
46
  appId: string;
44
47
  appSecret: string;
45
48
  originalId?: string;
46
- templateMsgs?: WechatPublicTemplateMsgsConfig;
47
49
  server?: {
48
50
  url?: string;
49
51
  token: string;
@@ -6,6 +6,6 @@ import { BRC } from '../types/RuntimeCxt';
6
6
  * @param context
7
7
  * @param refunds
8
8
  */
9
- export declare function updateWithdrawState(context: BRC, id: string): Promise<0 | 1>;
9
+ export declare function updateWithdrawState(context: BRC, id: string): Promise<1 | 0>;
10
10
  declare const triggers: Trigger<EntityDict, 'withdraw', BRC>[];
11
11
  export default triggers;
@@ -184,6 +184,7 @@ class AliPay extends AliPay_debug_1.default {
184
184
  const out_trade_no = (0, uuid_1.compressTo32)(pay.id);
185
185
  // 支付宝金额单位为元,需要转换
186
186
  const totalAmount = (0, money_1.ToYuan)(pay.price);
187
+ const timeoutAt = Date.now() + PREPAY_TIMEOUT;
187
188
  switch (this.apProduct.type) {
188
189
  case 'native': {
189
190
  const method = this.apProduct.config?.prepayMethod || 'GET';
@@ -199,6 +200,7 @@ class AliPay extends AliPay_debug_1.default {
199
200
  notify_url: payNotifyUrl,
200
201
  qr_pay_mode: qrPayMode,
201
202
  qrcode_width: qrCodeWidth,
203
+ time_expire: (0, dayjs_1.default)(timeoutAt).format('YYYY-MM-DD HH:mm:ss'),
202
204
  },
203
205
  notify_url: payNotifyUrl,
204
206
  needEncrypt: this.needEncrypt,
@@ -220,7 +222,7 @@ class AliPay extends AliPay_debug_1.default {
220
222
  }
221
223
  }
222
224
  // pay加一个过期时间,到期自动close
223
- data.timeoutAt = Date.now() + PREPAY_TIMEOUT;
225
+ data.timeoutAt = timeoutAt + 1000 * 60;
224
226
  }
225
227
  async getState(pay) {
226
228
  const outTradeNo = (0, uuid_1.compressTo32)(pay.id);
@@ -283,10 +285,6 @@ class AliPay extends AliPay_debug_1.default {
283
285
  this.analyzeResult(result);
284
286
  }
285
287
  catch (e) {
286
- // 在电脑网站下单时,系统首先生成URL;用户扫码后才会创建交易订单。若未完成扫码而订单过期到了直接关闭,提示'交易不存在'。
287
- if (e.code === 'ACQ.TRADE_NOT_EXIST') {
288
- return;
289
- }
290
288
  throw e;
291
289
  }
292
290
  }
@@ -87,9 +87,9 @@ const PayClazzEntityDict = {
87
87
  (0, assert_1.default)(wpProduct.enabled && wpProduct.wpAccount?.enabled);
88
88
  switch (type) {
89
89
  case 'web': {
90
- const { wechat } = config;
91
- (0, assert_1.default)(wechat);
92
- const appId = wechat.appId;
90
+ const { wechatPay } = config;
91
+ (0, assert_1.default)(wechatPay);
92
+ const appId = wechatPay.appId;
93
93
  return new WechatPay_1.default(wpProduct, appId);
94
94
  }
95
95
  case 'wechatMp': {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oak-pay-business",
3
- "version": "3.1.0",
3
+ "version": "3.1.1",
4
4
  "description": "",
5
5
  "files": [
6
6
  "lib/**/*",
@@ -31,10 +31,10 @@
31
31
  "alipay-sdk": "^4.14.0",
32
32
  "classnames": "^2.3.1",
33
33
  "dayjs": "^1.11.5",
34
- "oak-domain": "^5.1.26",
35
- "oak-external-sdk": "^2.3.8",
36
- "oak-frontend-base": "^5.3.33",
37
- "oak-general-business": "~5.7.6",
34
+ "oak-domain": "^5.1.27",
35
+ "oak-external-sdk": "^2.3.9",
36
+ "oak-frontend-base": "^5.3.34",
37
+ "oak-general-business": "~5.7.7",
38
38
  "react-markdown": "^9.0.3",
39
39
  "wechat-pay-nodejs": "^0.2.3"
40
40
  },