oak-pay-business 1.0.6 → 1.0.8

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 (55) hide show
  1. package/es/checkers/application.d.ts +5 -0
  2. package/es/checkers/application.js +31 -0
  3. package/es/checkers/index.js +2 -0
  4. package/es/components/AbstractComponents.d.ts +1 -0
  5. package/es/components/account/detail/index.js +2 -2
  6. package/es/components/pay/detail/index.d.ts +2 -1
  7. package/es/components/pay/detail/index.js +39 -3
  8. package/es/components/pay/detail/index.xml +12 -4
  9. package/es/components/pay/detail/locales/zh-CN.json +3 -1
  10. package/es/components/payConfig/system/index.js +14 -0
  11. package/es/components/payConfig/system/web.pc.d.ts +1 -0
  12. package/es/components/payConfig/system/web.pc.js +16 -16
  13. package/es/components/payConfig/upsert/index.d.ts +2 -0
  14. package/es/components/payConfig/upsert/index.js +23 -23
  15. package/es/components/payConfig/upsert/wechatPay/index.d.ts +3 -0
  16. package/es/components/payConfig/upsert/wechatPay/index.js +20 -2
  17. package/es/components/payConfig/upsert/wechatPay/locales/zh-CN.json +10 -4
  18. package/es/data/i18n.js +13 -5
  19. package/es/types/Exception.d.ts +11 -1
  20. package/es/types/Exception.js +27 -4
  21. package/es/types/PayClazz.d.ts +6 -6
  22. package/es/types/PayConfig.d.ts +3 -0
  23. package/es/utils/pay.d.ts +5 -0
  24. package/es/utils/pay.js +63 -0
  25. package/es/utils/payClazz/Account.d.ts +8 -9
  26. package/es/utils/payClazz/Account.js +3 -3
  27. package/es/utils/payClazz/Offline.d.ts +6 -7
  28. package/es/utils/payClazz/Offline.js +4 -4
  29. package/es/utils/payClazz/WechatPay/WechatPay.d.ts +12 -8
  30. package/es/utils/payClazz/WechatPay/WechatPay.debug.d.ts +8 -9
  31. package/es/utils/payClazz/WechatPay/WechatPay.debug.js +7 -7
  32. package/es/utils/payClazz/WechatPay/WechatPay.js +234 -9
  33. package/es/utils/payClazz/WechatPay/index.d.ts +2 -1
  34. package/es/watchers/pay.js +4 -5
  35. package/lib/checkers/application.d.ts +5 -0
  36. package/lib/checkers/application.js +33 -0
  37. package/lib/checkers/index.js +2 -0
  38. package/lib/data/i18n.js +13 -5
  39. package/lib/types/Exception.d.ts +11 -1
  40. package/lib/types/Exception.js +29 -5
  41. package/lib/types/PayClazz.d.ts +6 -6
  42. package/lib/types/PayConfig.d.ts +3 -0
  43. package/lib/utils/pay.d.ts +5 -0
  44. package/lib/utils/pay.js +66 -1
  45. package/lib/utils/payClazz/Account.d.ts +8 -9
  46. package/lib/utils/payClazz/Account.js +3 -3
  47. package/lib/utils/payClazz/Offline.d.ts +6 -7
  48. package/lib/utils/payClazz/Offline.js +4 -4
  49. package/lib/utils/payClazz/WechatPay/WechatPay.d.ts +12 -8
  50. package/lib/utils/payClazz/WechatPay/WechatPay.debug.d.ts +8 -9
  51. package/lib/utils/payClazz/WechatPay/WechatPay.debug.js +7 -7
  52. package/lib/utils/payClazz/WechatPay/WechatPay.js +235 -9
  53. package/lib/utils/payClazz/WechatPay/index.d.ts +2 -1
  54. package/lib/watchers/pay.js +4 -5
  55. package/package.json +15 -16
@@ -0,0 +1,5 @@
1
+ import { Checker } from 'oak-domain/lib/types/Auth';
2
+ import { EntityDict } from '../oak-app-domain';
3
+ import { RuntimeCxt } from '../types/RuntimeCxt';
4
+ declare const checkers: Checker<EntityDict, 'application', RuntimeCxt>[];
5
+ export default checkers;
@@ -0,0 +1,31 @@
1
+ import { PAY_CHANNEL_WECHAT_APP_NAME, PAY_CHANNEL_WECHAT_H5_NAME, PAY_CHANNEL_WECHAT_JS_NAME, PAY_CHANNEL_WECHAT_MP_NAME, PAY_CHANNEL_WECHAT_NATIVE_NAME } from '../types/PayConfig';
2
+ import { OakInputIllegalException } from 'oak-domain/lib/types';
3
+ const checkers = [
4
+ {
5
+ type: 'data',
6
+ entity: 'application',
7
+ action: 'update',
8
+ checker: (data, context) => {
9
+ const { payConfig } = (data || {});
10
+ if (payConfig) {
11
+ const wechatPayConfigs = payConfig.filter(ele => [
12
+ PAY_CHANNEL_WECHAT_APP_NAME,
13
+ PAY_CHANNEL_WECHAT_H5_NAME,
14
+ PAY_CHANNEL_WECHAT_JS_NAME,
15
+ PAY_CHANNEL_WECHAT_MP_NAME,
16
+ PAY_CHANNEL_WECHAT_NATIVE_NAME
17
+ ].includes(ele.channel));
18
+ if (wechatPayConfigs) {
19
+ wechatPayConfigs.forEach((config) => {
20
+ const { apiV3Key } = config;
21
+ if (apiV3Key?.length && apiV3Key.length !== 32) {
22
+ throw new OakInputIllegalException('appliation', ['payConfig'], 'apiV3Key长度只能是32位');
23
+ }
24
+ });
25
+ }
26
+ }
27
+ return 1;
28
+ }
29
+ }
30
+ ];
31
+ export default checkers;
@@ -1,9 +1,11 @@
1
1
  import aoCheckers from './accountOper';
2
2
  import payCheckers from './pay';
3
3
  import orderCheckers from './order';
4
+ import applicationCheckers from './application';
4
5
  const checkers = [
5
6
  ...aoCheckers,
6
7
  ...payCheckers,
7
8
  ...orderCheckers,
9
+ ...applicationCheckers,
8
10
  ];
9
11
  export default checkers;
@@ -28,6 +28,7 @@ declare const List: <T extends keyof EntityDict>(props: ReactComponentProps<Enti
28
28
  scrollToFirstRowOnChange?: boolean | undefined;
29
29
  }) | undefined;
30
30
  locale?: any;
31
+ opWidth?: number | undefined;
31
32
  }>) => React.ReactElement;
32
33
  declare const ListPro: <T extends keyof EntityDict>(props: {
33
34
  title?: any;
@@ -175,12 +175,12 @@ export default OakComponent({
175
175
  ready() {
176
176
  const { oakId } = this.props;
177
177
  assert(typeof oakId === 'string');
178
- this.subDataEvents([`${DATA_SUBSCRIBER_KEYS.accountNumberChanged}-${oakId}`]);
178
+ this.subDataEvents([`${DATA_SUBSCRIBER_KEYS.accountNumberChanged}-${oakId}`], 'opb-c-account-detail');
179
179
  },
180
180
  detached() {
181
181
  const { oakId } = this.props;
182
182
  assert(typeof oakId === 'string');
183
- this.unsubDataEvents([`${DATA_SUBSCRIBER_KEYS.accountNumberChanged}-${oakId}`]);
183
+ this.unsubDataEvents([`${DATA_SUBSCRIBER_KEYS.accountNumberChanged}-${oakId}`], 'opb-c-account-detail');
184
184
  }
185
185
  }
186
186
  });
@@ -1,4 +1,5 @@
1
- declare const _default: (props: import("oak-frontend-base").ReactComponentProps<import("../../../oak-app-domain").EntityDict, "pay", false, {
1
+ import { EntityDict } from "../../../oak-app-domain";
2
+ declare const _default: (props: import("oak-frontend-base").ReactComponentProps<EntityDict, "pay", false, {
2
3
  onClose: () => void;
3
4
  }>) => React.ReactElement;
4
5
  export default _default;
@@ -48,6 +48,12 @@ export default OakComponent({
48
48
  const iState = data?.iState;
49
49
  const iStateColor = iState && this.features.style.getColor('pay', 'iState', iState);
50
50
  const payConfig = this.features.pay.getPayConfigs();
51
+ const startPayable = data?.iState === 'paying' && data?.meta && data?.channel && [
52
+ PAY_CHANNEL_WECHAT_APP_NAME,
53
+ PAY_CHANNEL_WECHAT_MP_NAME,
54
+ PAY_CHANNEL_WECHAT_H5_NAME,
55
+ PAY_CHANNEL_WECHAT_JS_NAME
56
+ ].includes(data.channel);
51
57
  return {
52
58
  type: data?.orderId ? 'order' : 'account',
53
59
  pay: data,
@@ -55,7 +61,7 @@ export default OakComponent({
55
61
  iStateColor,
56
62
  payConfig,
57
63
  closable: !!(data?.["#oakLegalActions"]?.includes('close')),
58
- startPayable: false,
64
+ startPayable,
59
65
  metaUpdatable: !!(data?.["#oakLegalActions"]?.find(ele => typeof ele === 'object'
60
66
  && ele.action === 'update'
61
67
  && ele.attrs?.includes('meta'))),
@@ -112,18 +118,48 @@ export default OakComponent({
112
118
  },
113
119
  goBack() {
114
120
  this.navigateBack();
121
+ },
122
+ async startPay() {
123
+ const { pay } = this.state;
124
+ const { iState, channel, meta } = pay;
125
+ switch (channel) {
126
+ case PAY_CHANNEL_WECHAT_MP_NAME: {
127
+ const { prepayMeta } = meta;
128
+ if (prepayMeta) {
129
+ const result = await wx.requestPayment(prepayMeta);
130
+ console.log(result);
131
+ }
132
+ else {
133
+ this.setMessage({
134
+ type: 'warning',
135
+ content: '没有预支付数据,可能是在开发环境,请检查',
136
+ });
137
+ }
138
+ break;
139
+ }
140
+ default: {
141
+ assert('尚未实现');
142
+ }
143
+ }
115
144
  }
116
145
  },
117
146
  lifetimes: {
118
147
  ready() {
119
148
  const { oakId } = this.props;
120
149
  assert(typeof oakId === 'string');
121
- this.subDataEvents([`${DATA_SUBSCRIBER_KEYS.payStateChanged}-${oakId}`]);
150
+ this.subDataEvents([`${DATA_SUBSCRIBER_KEYS.payStateChanged}-${oakId}`], 'opb-c-pay-detail');
122
151
  },
123
152
  detached() {
124
153
  const { oakId } = this.props;
125
154
  assert(typeof oakId === 'string');
126
- this.unsubDataEvents([`${DATA_SUBSCRIBER_KEYS.payStateChanged}-${oakId}`]);
155
+ this.unsubDataEvents([`${DATA_SUBSCRIBER_KEYS.payStateChanged}-${oakId}`], 'opb-c-pay-detail');
156
+ }
157
+ },
158
+ listeners: {
159
+ startPayable(prev, next) {
160
+ if (next.startPayable) {
161
+ this.startPay();
162
+ }
127
163
  }
128
164
  }
129
165
  });
@@ -85,7 +85,18 @@
85
85
  </view>
86
86
  <view class="padding" />
87
87
  <view class="btn-container">
88
- <block wx:if="{{oakExecutable === true}}">
88
+ <block wx:if="{{startPayable}}">
89
+ <view class="btn">
90
+ <l-button
91
+ type="default"
92
+ size="long"
93
+ bind:lintap="startPay"
94
+ >
95
+ {{t('wechatPay')}}
96
+ </l-button>
97
+ </view>
98
+ </block>
99
+ <block wx:elif="{{oakExecutable === true}}">
89
100
  <view class="btn">
90
101
  <l-button
91
102
  type="default"
@@ -124,9 +135,6 @@
124
135
  bind:lincancel="cancelCloseMp"
125
136
  bind:lintap="cancelCloseMp"
126
137
  />
127
- </block>
128
- <block wx:elif="{{startPayable}}">
129
-
130
138
  </block>
131
139
  <block wx:else>
132
140
  <view class="btn">
@@ -28,5 +28,7 @@
28
28
  "order": "订单支付",
29
29
  "account": "帐户充值"
30
30
  },
31
- "success": "支付成功"
31
+ "success": "支付成功",
32
+ "pay": "支付",
33
+ "wechatPay": "微信支付"
32
34
  }
@@ -1,3 +1,4 @@
1
+ import { composeServerUrl } from 'oak-general-business/es/utils/domain';
1
2
  export default OakComponent({
2
3
  entity: 'system',
3
4
  isList: false,
@@ -13,12 +14,25 @@ export default OakComponent({
13
14
  type: 1,
14
15
  },
15
16
  },
17
+ domain$system: {
18
+ $entity: 'domain',
19
+ data: {
20
+ id: 1,
21
+ protocol: 1,
22
+ url: 1,
23
+ apiPath: 1,
24
+ port: 1,
25
+ },
26
+ },
16
27
  },
17
28
  formData({ data, features }) {
18
29
  const operation = this.state.oakFullpath && this.features.runningTree.getOperations(this.state.oakFullpath);
30
+ const domain = data && data.domain$system[0];
31
+ const serverUrl = domain && composeServerUrl(domain);
19
32
  return {
20
33
  operation: operation && operation[0].operation,
21
34
  system: data,
35
+ serverUrl,
22
36
  };
23
37
  },
24
38
  });
@@ -15,4 +15,5 @@ export declare function registerApplicationPayChannel(type: EntityDict['applicat
15
15
  export default function render(props: WebComponentProps<EntityDict, 'system', false, {
16
16
  system: RowWithActions<EntityDict, 'system'>;
17
17
  operation?: EntityDict['system']['Update'];
18
+ serverUrl?: string;
18
19
  }>): React.JSX.Element | null;
@@ -27,7 +27,7 @@ export function registerApplicationPayChannel(type, channel) {
27
27
  }
28
28
  }
29
29
  export default function render(props) {
30
- const { system, oakFullpath, operation, oakDirty } = props.data;
30
+ const { system, oakFullpath, operation, oakDirty, serverUrl, oakExecutable } = props.data;
31
31
  const { t, update, setMessage, execute } = props.methods;
32
32
  const defaultApplicationPayChannelDict = {
33
33
  web: AppTypeToPayChannelDict.web.map(ele => [t(`payChannel::internal.${ele}`), ele]),
@@ -37,23 +37,23 @@ export default function render(props) {
37
37
  const [key, setKey] = useState('');
38
38
  if (system && oakFullpath) {
39
39
  const { payConfig, application$system: applications } = system;
40
- return (<div className={Styles.container}>
41
- <Row justify="end" style={{ marginBottom: 12 }}>
42
- <Button type="primary" disabled={!oakDirty} onClick={() => execute()}>
43
- {t('common::action.save')}
44
- </Button>
45
- </Row>
40
+ return (<div className={Styles.container}>
41
+ <Row justify="end" style={{ marginBottom: 12 }}>
42
+ <Button type="primary" disabled={!oakDirty && oakExecutable !== true} onClick={() => execute()}>
43
+ {t('common::action.save')}
44
+ </Button>
45
+ </Row>
46
46
  <Tabs tabPosition="left" items={[
47
47
  {
48
- label: (<div className={Styles.systemLabel}>
49
- {t('system')}
48
+ label: (<div className={Styles.systemLabel}>
49
+ {t('system')}
50
50
  </div>),
51
51
  key: 'system',
52
- children: (<PayConfigUpsert key="system" config={payConfig} update={(config) => update({ payConfig: config })} channels={SystemPayChannels.concat([[t('payChannel::internal.ACCOUNT'), 'ACCOUNT'], [t('payChannel::internal.OFFLINE'), 'OFFLINE']])} t={t}/>),
52
+ children: (<PayConfigUpsert key="system" serverUrl={serverUrl} config={payConfig} update={(config) => update({ payConfig: config })} channels={SystemPayChannels.concat([[t('payChannel::internal.ACCOUNT'), 'ACCOUNT'], [t('payChannel::internal.OFFLINE'), 'OFFLINE']])} t={t}/>),
53
53
  },
54
54
  {
55
- label: (<div className={Styles.padding}>
56
- {t('appsBelow')}
55
+ label: (<div className={Styles.padding}>
56
+ {t('appsBelow')}
57
57
  </div>),
58
58
  disabled: true,
59
59
  key: 'padding',
@@ -62,10 +62,10 @@ export default function render(props) {
62
62
  const { type, id, payConfig: appPayConfig } = app;
63
63
  return {
64
64
  key: id,
65
- label: (<div>
66
- {app.name}
65
+ label: (<div>
66
+ {app.name}
67
67
  </div>),
68
- children: (<PayConfigUpsert key={id} config={appPayConfig} update={(config) => update({
68
+ children: (<PayConfigUpsert key={id} serverUrl={serverUrl} config={appPayConfig} update={(config) => update({
69
69
  application$system: {
70
70
  id: generateNewId(),
71
71
  action: 'update',
@@ -95,7 +95,7 @@ export default function render(props) {
95
95
  }
96
96
  }
97
97
  setKey(activeKey);
98
- }}/>
98
+ }}/>
99
99
  </div>);
100
100
  }
101
101
  return null;
@@ -4,11 +4,13 @@ type FC<T extends ConfigBase> = React.FC<{
4
4
  config: T;
5
5
  update: (config: Omit<T, 'channel'>) => void;
6
6
  t: (k: string) => string;
7
+ extra: any;
7
8
  }>;
8
9
  export declare function registerPayConfigComponent<T extends ConfigBase>(channel: string, C: FC<T>): void;
9
10
  export default function Upsert(props: {
10
11
  config?: PayConfig | null;
11
12
  channels: [string, string][];
13
+ serverUrl?: string;
12
14
  update: (config: PayConfig) => void;
13
15
  t: (k: string) => string;
14
16
  }): React.JSX.Element;
@@ -20,21 +20,21 @@ export function registerPayConfigComponent(channel, C) {
20
20
  PayConfigComponentsDict[channel] = C;
21
21
  }
22
22
  export default function Upsert(props) {
23
- const { config, channels, update, t } = props;
23
+ const { serverUrl, config, channels, update, t } = props;
24
24
  const [open, setOpen] = useState(false);
25
- const AddButton = (<Button onClick={() => setOpen(true)} disabled={open}>
26
- {t('common::action.add')}
25
+ const AddButton = (<Button onClick={() => setOpen(true)} disabled={open}>
26
+ {t('common::action.add')}
27
27
  </Button>);
28
- let C = (<>
29
- <Alert message={t('tips')} type="warning"/>
30
- <div className={classnames(Styles.empty, Styles.container)}>
31
- {AddButton}
32
- </div>
28
+ let C = (<>
29
+ <Alert message={t('tips')} type="warning"/>
30
+ <div className={classnames(Styles.empty, Styles.container)}>
31
+ {AddButton}
32
+ </div>
33
33
  </>);
34
34
  const availableChannels = channels.filter((ele) => !config?.find(ele2 => ele2.channel === ele[1]));
35
35
  if (config && config.length > 0) {
36
- C = (<div className={Styles.container}>
37
- <Space direction="vertical" size={16} style={{ width: '100%' }}>
36
+ C = (<div className={Styles.container}>
37
+ <Space direction="vertical" size={16} style={{ width: '100%' }}>
38
38
  {config.map((cf, idx) => {
39
39
  const { channel } = cf;
40
40
  const C = PayConfigComponentsDict[channel];
@@ -44,26 +44,26 @@ export default function Upsert(props) {
44
44
  }} key={idx} extra={<Button icon={<CloseOutlined />} type="text" onClick={() => {
45
45
  config.splice(idx, 1);
46
46
  update(config);
47
- }}/>}>
48
- <C config={cf} update={(cf2) => {
47
+ }}/>}>
48
+ <C extra={{ serverUrl }} config={cf} update={(cf2) => {
49
49
  config.splice(idx, 1, {
50
50
  channel,
51
51
  ...cf2,
52
52
  });
53
53
  update(config);
54
- }} t={t}/>
54
+ }} t={t}/>
55
55
  </Card>);
56
- })}
57
- </Space>
58
- {availableChannels.length > 0 && <div style={{ marginTop: 24, alignSelf: 'flex-end' }}>
59
- {AddButton}
60
- </div>}
56
+ })}
57
+ </Space>
58
+ {availableChannels.length > 0 && <div style={{ marginTop: 24, alignSelf: 'flex-end' }}>
59
+ {AddButton}
60
+ </div>}
61
61
  </div>);
62
62
  }
63
63
  // 还没有配置config
64
- return (<>
65
- {C}
66
- <Modal open={open} onCancel={() => setOpen(false)} title={t('pickChannel')} onOk={() => { }} footer={null} destroyOnClose={true}>
64
+ return (<>
65
+ {C}
66
+ <Modal open={open} onCancel={() => setOpen(false)} title={t('pickChannel')} onOk={() => { }} footer={null} destroyOnClose={true}>
67
67
  <Select style={{ width: 240 }} options={availableChannels.map(ele => ({
68
68
  label: ele[0],
69
69
  value: ele[1],
@@ -80,7 +80,7 @@ export default function Upsert(props) {
80
80
  }]);
81
81
  }
82
82
  setOpen(false);
83
- }}/>
84
- </Modal>
83
+ }}/>
84
+ </Modal>
85
85
  </>);
86
86
  }
@@ -4,4 +4,7 @@ export default function WechatPay(props: {
4
4
  config: WechatPayConfig;
5
5
  update: (config: Omit<WechatPayConfig, 'channel'>) => void;
6
6
  t: (k: string) => string;
7
+ extra: {
8
+ serverUrl: string;
9
+ };
7
10
  }): React.JSX.Element;
@@ -1,8 +1,8 @@
1
1
  import React from 'react';
2
2
  import { Form, Input, InputNumber } from 'antd';
3
3
  export default function WechatPay(props) {
4
- const { config, update, t } = props;
5
- return (<Form labelCol={{ span: 6 }} wrapperCol={{ span: 12 }} layout="horizontal" style={{ minWidth: 600 }}>
4
+ const { config, update, t, extra: { serverUrl } } = props;
5
+ return (<Form labelCol={{ span: 3 }} wrapperCol={{ span: 18 }} layout="horizontal" style={{ minWidth: 600 }}>
6
6
  <Form.Item label="mchId">
7
7
  <Input value={config.mchId} onChange={({ currentTarget }) => {
8
8
  config.mchId = currentTarget.value;
@@ -19,6 +19,24 @@ export default function WechatPay(props) {
19
19
  <Input value={config.publicKeyFilePath} placeholder={t('placeholder.publicKeyFilePath')} onChange={({ currentTarget }) => {
20
20
  config.publicKeyFilePath = currentTarget.value;
21
21
  update(config);
22
+ }}/>
23
+ </Form.Item>
24
+ <Form.Item label={t('label.payNotifyUrl')}>
25
+ <Input prefix={`${serverUrl}/endpoint`} suffix='/${payId}' value={config.payNotifyUrl} placeholder={t('placeholder.payNotifyUrl')} onChange={({ currentTarget }) => {
26
+ config.payNotifyUrl = currentTarget.value;
27
+ update(config);
28
+ }}/>
29
+ </Form.Item>
30
+ <Form.Item label={t('label.refundNotifyUrl')}>
31
+ <Input prefix={`${serverUrl}/endpoint`} suffix='/${refundId}' value={config.refundNotifyUrl} placeholder={t('placeholder.refundNotifyUrl')} onChange={({ currentTarget }) => {
32
+ config.refundNotifyUrl = currentTarget.value;
33
+ update(config);
34
+ }}/>
35
+ </Form.Item>
36
+ <Form.Item label={t('label.apiV3Key')}>
37
+ <Input value={config.apiV3Key} placeholder={t('placeholder.apiV3Key')} onChange={({ currentTarget }) => {
38
+ config.apiV3Key = currentTarget.value;
39
+ update(config);
22
40
  }}/>
23
41
  </Form.Item>
24
42
  <Form.Item label={t('label.lossRatio')} help={t('placeholder.lossRatio')}>
@@ -2,11 +2,17 @@
2
2
  "label": {
3
3
  "privateKeyFilePath": "私钥文件路径",
4
4
  "publicKeyFilePath": "公钥文件路径",
5
- "lossRatio": "手续费比例"
5
+ "payNotifyUrl": "支付回调URL",
6
+ "refundNotifyUrl": "退款回调URL",
7
+ "lossRatio": "手续费比例",
8
+ "apiV3Key": "apiV3Key"
6
9
  },
7
10
  "placeholder": {
8
- "privateKeyFilePath": "服务器上存放微信支付帐户私钥文件的路径,注意访问权限",
9
- "publicKeyFilePath": "服务器上存放微信支付帐户公钥文件的路径,注意访问权限",
10
- "lossRatio": "填百分比(0.6就代表千分之六)"
11
+ "privateKeyFilePath": "服务器上存放apiclient_key.pem的路径,注意访问权限",
12
+ "publicKeyFilePath": "服务器上存放apiclient_cert.pem的路径,注意访问权限",
13
+ "lossRatio": "填百分比(0.6就代表千分之六)",
14
+ "payNotifyUrl": "endpoint",
15
+ "refundNotifyUrl": "endpoint",
16
+ "apiV3Key": "需要登录商户后台获取"
11
17
  }
12
18
  }
package/es/data/i18n.js CHANGED
@@ -118,7 +118,9 @@ const i18ns = [
118
118
  "order": "订单支付",
119
119
  "account": "帐户充值"
120
120
  },
121
- "success": "支付成功"
121
+ "success": "支付成功",
122
+ "pay": "支付",
123
+ "wechatPay": "微信支付"
122
124
  }
123
125
  },
124
126
  {
@@ -217,12 +219,18 @@ const i18ns = [
217
219
  "label": {
218
220
  "privateKeyFilePath": "私钥文件路径",
219
221
  "publicKeyFilePath": "公钥文件路径",
220
- "lossRatio": "手续费比例"
222
+ "payNotifyUrl": "支付回调URL",
223
+ "refundNotifyUrl": "退款回调URL",
224
+ "lossRatio": "手续费比例",
225
+ "apiV3Key": "apiV3Key"
221
226
  },
222
227
  "placeholder": {
223
- "privateKeyFilePath": "服务器上存放微信支付帐户私钥文件的路径,注意访问权限",
224
- "publicKeyFilePath": "服务器上存放微信支付帐户公钥文件的路径,注意访问权限",
225
- "lossRatio": "填百分比(0.6就代表千分之六)"
228
+ "privateKeyFilePath": "服务器上存放apiclient_key.pem的路径,注意访问权限",
229
+ "publicKeyFilePath": "服务器上存放apiclient_cert.pem的路径,注意访问权限",
230
+ "lossRatio": "填百分比(0.6就代表千分之六)",
231
+ "payNotifyUrl": "endpoint",
232
+ "refundNotifyUrl": "endpoint",
233
+ "apiV3Key": "需要登录商户后台获取"
226
234
  }
227
235
  }
228
236
  },
@@ -1,3 +1,13 @@
1
- import { OakException } from 'oak-domain/lib/types';
1
+ import { OakException, OpRecord } from 'oak-domain/lib/types';
2
2
  import { EntityDict } from '../oak-app-domain/index';
3
+ export declare class ExternalPrePayException<ED extends EntityDict> extends OakException<ED> {
4
+ reason: any;
5
+ constructor(reason: any, message?: string);
6
+ getSerialData(): {
7
+ reason: any;
8
+ name: string;
9
+ message: string;
10
+ opRecords: OpRecord<ED>[];
11
+ };
12
+ }
3
13
  export declare function makeException<ED extends EntityDict>(msg: string | object): OakException<ED> | undefined;
@@ -1,14 +1,37 @@
1
+ import { OakException } from 'oak-domain/lib/types';
1
2
  import makeDepedentException from './DependentExceptions';
3
+ export class ExternalPrePayException extends OakException {
4
+ reason;
5
+ constructor(reason, message) {
6
+ super(message || '调用外部支付预下单接口失败');
7
+ this.reason = reason;
8
+ }
9
+ getSerialData() {
10
+ const data = super.getSerialData();
11
+ return {
12
+ ...data,
13
+ reason: this.reason,
14
+ };
15
+ }
16
+ }
2
17
  export function makeException(msg) {
3
18
  const data = typeof msg === 'string' ? JSON.parse(msg) : msg;
4
- const exception = makeDepedentException(data);
19
+ let exception = makeDepedentException(data);
5
20
  if (exception) {
6
21
  return exception;
7
22
  }
8
- /* const { name, message } = data;
23
+ const { name, message } = data;
9
24
  switch (name) {
25
+ case 'ExternalPrePayException': {
26
+ exception = new ExternalPrePayException(data.reason, message);
27
+ break;
28
+ }
10
29
  default: {
11
- throw new OakException(`不可解读的exception信息「${msg}」`);
30
+ break;
12
31
  }
13
- } */
32
+ }
33
+ if (exception) {
34
+ exception.setOpRecords(data.opRecords);
35
+ }
36
+ return exception;
14
37
  }
@@ -3,14 +3,14 @@ import { BRC } from '../types/RuntimeCxt';
3
3
  type IState = EntityDict['pay']['OpSchema']['iState'];
4
4
  export default interface PayClazz {
5
5
  channel: string;
6
- prepay(pay: EntityDict['pay']['OpSchema'], data: EntityDict['pay']['Update']['data'], context: BRC): Promise<void>;
7
- getState(pay: EntityDict['pay']['OpSchema']): Promise<IState>;
6
+ prepay(pay: EntityDict['pay']['Schema'], data: EntityDict['pay']['Update']['data'], context: BRC): Promise<void>;
7
+ getState(pay: EntityDict['pay']['OpSchema']): Promise<[IState, EntityDict['pay']['Update']['data']]>;
8
8
  close(pay: EntityDict['pay']['OpSchema']): Promise<void>;
9
- decodeNotification(params: Record<string, string>, body: any): Promise<Array<{
9
+ decodePayNotification(params: Record<string, any>, body: any): Promise<{
10
10
  payId: string;
11
11
  iState: IState;
12
- extra?: any;
13
- answer: string;
14
- }>>;
12
+ extra?: EntityDict['pay']['Update']['data'];
13
+ price?: number;
14
+ }>;
15
15
  }
16
16
  export {};
@@ -7,6 +7,9 @@ export type WechatPayConfig = {
7
7
  mchId: string;
8
8
  publicKeyFilePath: string;
9
9
  privateKeyFilePath: string;
10
+ apiV3Key: string;
11
+ payNotifyUrl: string;
12
+ refundNotifyUrl: string;
10
13
  lossRatio: number;
11
14
  };
12
15
  export type AccountPayChannel = 'ACCOUNT';
package/es/utils/pay.d.ts CHANGED
@@ -1,2 +1,7 @@
1
+ /// <reference types="node" />
1
2
  import { EntityDict } from '../oak-app-domain';
3
+ import { EntityDict as BaseEntityDict } from 'oak-domain/lib/types/Entity';
4
+ import BackendRuntimeContext from '../context/BackendRuntimeContext';
5
+ import { IncomingHttpHeaders } from 'http';
2
6
  export declare const fullPayProjection: EntityDict['pay']['Selection']['data'];
7
+ export declare function payNotify<ED extends EntityDict & BaseEntityDict>(context: BackendRuntimeContext<ED>, body: any, payId: string, headers: IncomingHttpHeaders): Promise<void>;