@jayfong/x-server 2.4.3 → 2.6.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.
@@ -94,20 +94,52 @@ class PayService {
94
94
 
95
95
  verifyNotifyData(data) {
96
96
  try {
97
- var _this$alipaySdk;
97
+ if (!data || typeof data !== 'object') {
98
+ return false;
99
+ } // 支付宝
100
+ // https://opendocs.alipay.com/open/270/105902
98
101
 
99
- return !!data && typeof data === 'object' && ( // 支付宝
100
- data.passback_params === 'alipay' ? !!((_this$alipaySdk = this.alipaySdk) != null && _this$alipaySdk.checkNotifySign(data)) : // 微信支付
101
- data.resource ? JSON.parse(this.wepayDecrypt(data.resource)).attach === 'wepay' : false);
102
+
103
+ if (data.passback_params === 'alipay') {
104
+ var _this$alipaySdk;
105
+
106
+ if (!((_this$alipaySdk = this.alipaySdk) != null && _this$alipaySdk.checkNotifySign(data))) {
107
+ return false;
108
+ }
109
+
110
+ return {
111
+ channelOrderNo: data.trade_no
112
+ };
113
+ } // 微信支付
114
+ // https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter3_1_5.shtml
115
+
116
+
117
+ if (data.resource) {
118
+ const params = JSON.parse(this.wepayDecrypt(data.resource));
119
+
120
+ if (params.attach === 'wepay') {
121
+ return {
122
+ channelOrderNo: params.transaction_id
123
+ };
124
+ }
125
+
126
+ return false;
127
+ }
128
+
129
+ return false;
102
130
  } catch {
103
131
  return false;
104
132
  }
105
133
  }
106
134
 
107
135
  verifyNotifyDataOrFail(data, message) {
108
- if (!this.verifyNotifyData(data)) {
136
+ const res = this.verifyNotifyData(data);
137
+
138
+ if (!res) {
109
139
  throw new _http_error.HttpError.BadRequest(message);
110
140
  }
141
+
142
+ return res;
111
143
  }
112
144
 
113
145
  wepaySign(data) {
package/lib/_cjs/x.js CHANGED
@@ -13,6 +13,8 @@ var _path = _interopRequireDefault(require("path"));
13
13
 
14
14
  var _dispose = require("./services/dispose");
15
15
 
16
+ var _emoji = require("./services/emoji");
17
+
16
18
  var _log = require("./services/log");
17
19
 
18
20
  const env = JSON.parse(process.env.X_SERVER_ENVS || '{}');
@@ -33,4 +35,4 @@ _fsExtra.default.ensureDirSync(x.dataDir);
33
35
 
34
36
  x.register(new _dispose.DisposeService({
35
37
  disposeOnExit: true
36
- }), new _log.LogService());
38
+ }), new _log.LogService(), new _emoji.EmojiService());
@@ -0,0 +1,10 @@
1
+ import { BaseService } from './base';
2
+ export declare class EmojiService implements BaseService {
3
+ serviceName: string;
4
+ unify(text: string): string;
5
+ }
6
+ declare module '../x' {
7
+ interface X {
8
+ emoji: EmojiService;
9
+ }
10
+ }