oak-pay-business 1.0.6 → 1.0.7
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.
- package/es/components/AbstractComponents.d.ts +5 -4
- package/es/components/account/detail/index.js +2 -2
- package/es/components/pay/detail/index.d.ts +2 -1
- package/es/components/pay/detail/index.js +31 -3
- package/es/components/pay/detail/index.xml +9 -1
- package/es/components/pay/detail/locales/zh-CN.json +2 -1
- package/es/components/payConfig/system/index.js +14 -0
- package/es/components/payConfig/system/web.pc.d.ts +1 -0
- package/es/components/payConfig/system/web.pc.js +16 -16
- package/es/components/payConfig/upsert/index.d.ts +2 -0
- package/es/components/payConfig/upsert/index.js +23 -23
- package/es/components/payConfig/upsert/wechatPay/index.d.ts +3 -0
- package/es/components/payConfig/upsert/wechatPay/index.js +20 -2
- package/es/components/payConfig/upsert/wechatPay/locales/zh-CN.json +8 -2
- package/es/data/i18n.js +10 -3
- package/es/types/Exception.d.ts +11 -1
- package/es/types/Exception.js +27 -4
- package/es/types/PayClazz.d.ts +6 -6
- package/es/types/PayConfig.d.ts +3 -0
- package/es/utils/pay.d.ts +5 -0
- package/es/utils/pay.js +63 -0
- package/es/utils/payClazz/Account.d.ts +8 -9
- package/es/utils/payClazz/Account.js +3 -3
- package/es/utils/payClazz/Offline.d.ts +6 -7
- package/es/utils/payClazz/Offline.js +4 -4
- package/es/utils/payClazz/WechatPay/WechatPay.d.ts +12 -8
- package/es/utils/payClazz/WechatPay/WechatPay.debug.d.ts +8 -9
- package/es/utils/payClazz/WechatPay/WechatPay.debug.js +7 -7
- package/es/utils/payClazz/WechatPay/WechatPay.js +234 -9
- package/es/utils/payClazz/WechatPay/index.d.ts +2 -1
- package/es/watchers/pay.js +4 -5
- package/lib/data/i18n.js +10 -3
- package/lib/types/Exception.d.ts +11 -1
- package/lib/types/Exception.js +29 -5
- package/lib/types/PayClazz.d.ts +6 -6
- package/lib/types/PayConfig.d.ts +3 -0
- package/lib/utils/pay.d.ts +5 -0
- package/lib/utils/pay.js +66 -1
- package/lib/utils/payClazz/Account.d.ts +8 -9
- package/lib/utils/payClazz/Account.js +3 -3
- package/lib/utils/payClazz/Offline.d.ts +6 -7
- package/lib/utils/payClazz/Offline.js +4 -4
- package/lib/utils/payClazz/WechatPay/WechatPay.d.ts +12 -8
- package/lib/utils/payClazz/WechatPay/WechatPay.debug.d.ts +8 -9
- package/lib/utils/payClazz/WechatPay/WechatPay.debug.js +7 -7
- package/lib/utils/payClazz/WechatPay/WechatPay.js +235 -9
- package/lib/utils/payClazz/WechatPay/index.d.ts +2 -1
- package/lib/watchers/pay.js +4 -5
- package/package.json +16 -15
|
@@ -20,7 +20,7 @@ declare const List: <T extends keyof EntityDict>(props: ReactComponentProps<Enti
|
|
|
20
20
|
rowSelection?: any;
|
|
21
21
|
hideHeader?: boolean | undefined;
|
|
22
22
|
disableSerialNumber?: boolean | undefined;
|
|
23
|
-
size?: "small" | "
|
|
23
|
+
size?: "small" | "middle" | "large" | undefined;
|
|
24
24
|
scroll?: ({
|
|
25
25
|
x?: string | number | true | undefined;
|
|
26
26
|
y?: string | number | undefined;
|
|
@@ -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;
|
|
@@ -45,7 +46,7 @@ declare const ListPro: <T extends keyof EntityDict>(props: {
|
|
|
45
46
|
tablePagination?: any;
|
|
46
47
|
rowSelection?: any;
|
|
47
48
|
disableSerialNumber?: boolean | undefined;
|
|
48
|
-
size?: "small" | "
|
|
49
|
+
size?: "small" | "middle" | "large" | undefined;
|
|
49
50
|
scroll?: any;
|
|
50
51
|
locale?: any;
|
|
51
52
|
opWidth?: number | undefined;
|
|
@@ -57,14 +58,14 @@ declare const Detail: <T extends keyof EntityDict>(props: ReactComponentProps<En
|
|
|
57
58
|
data: Partial<EntityDict[T]["Schema"]>;
|
|
58
59
|
title?: string | undefined;
|
|
59
60
|
bordered?: boolean | undefined;
|
|
60
|
-
layout?: "
|
|
61
|
+
layout?: "vertical" | "horizontal" | undefined;
|
|
61
62
|
}>) => React.ReactElement;
|
|
62
63
|
declare const Upsert: <T extends keyof EntityDict>(props: ReactComponentProps<EntityDict, T, false, {
|
|
63
64
|
helps: Record<string, string>;
|
|
64
65
|
entity: T;
|
|
65
66
|
attributes: OakAbsAttrUpsertDef<EntityDict, T, string | number>[];
|
|
66
67
|
data: EntityDict[T]["Schema"];
|
|
67
|
-
layout: "
|
|
68
|
+
layout: "vertical" | "horizontal";
|
|
68
69
|
mode: "default" | "card";
|
|
69
70
|
}>) => React.ReactElement;
|
|
70
71
|
export { FilterPanel, List, ListPro, Detail, Upsert, ReactComponentProps, ColumnProps, RowWithActions, OakExtraActionProps, OakAbsAttrDef, onActionFnDef, };
|
|
@@ -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
|
-
|
|
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
|
|
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,40 @@ 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
|
+
const result = await wx.requestPayment(prepayMeta);
|
|
129
|
+
console.log(result);
|
|
130
|
+
break;
|
|
131
|
+
}
|
|
132
|
+
default: {
|
|
133
|
+
assert('尚未实现');
|
|
134
|
+
}
|
|
135
|
+
}
|
|
115
136
|
}
|
|
116
137
|
},
|
|
117
138
|
lifetimes: {
|
|
118
139
|
ready() {
|
|
119
140
|
const { oakId } = this.props;
|
|
120
141
|
assert(typeof oakId === 'string');
|
|
121
|
-
this.subDataEvents([`${DATA_SUBSCRIBER_KEYS.payStateChanged}-${oakId}`]);
|
|
142
|
+
this.subDataEvents([`${DATA_SUBSCRIBER_KEYS.payStateChanged}-${oakId}`], 'opb-c-pay-detail');
|
|
122
143
|
},
|
|
123
144
|
detached() {
|
|
124
145
|
const { oakId } = this.props;
|
|
125
146
|
assert(typeof oakId === 'string');
|
|
126
|
-
this.unsubDataEvents([`${DATA_SUBSCRIBER_KEYS.payStateChanged}-${oakId}`]);
|
|
147
|
+
this.unsubDataEvents([`${DATA_SUBSCRIBER_KEYS.payStateChanged}-${oakId}`], 'opb-c-pay-detail');
|
|
148
|
+
}
|
|
149
|
+
},
|
|
150
|
+
listeners: {
|
|
151
|
+
startPayable(prev, next) {
|
|
152
|
+
if (next.startPayable) {
|
|
153
|
+
this.startPay();
|
|
154
|
+
}
|
|
127
155
|
}
|
|
128
156
|
}
|
|
129
157
|
});
|
|
@@ -126,7 +126,15 @@
|
|
|
126
126
|
/>
|
|
127
127
|
</block>
|
|
128
128
|
<block wx:elif="{{startPayable}}">
|
|
129
|
-
|
|
129
|
+
<view class="btn">
|
|
130
|
+
<l-button
|
|
131
|
+
type="default"
|
|
132
|
+
size="long"
|
|
133
|
+
bind:lintap="startPay"
|
|
134
|
+
>
|
|
135
|
+
{{t('pay')}}
|
|
136
|
+
</l-button>
|
|
137
|
+
</view>
|
|
130
138
|
</block>
|
|
131
139
|
<block wx:else>
|
|
132
140
|
<view class="btn">
|
|
@@ -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 } = 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} 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
|
}
|
|
@@ -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:
|
|
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.apiV3Key')}>
|
|
31
|
+
<Input value={config.apiV3Key} placeholder={t('placeholder.apiV3Key')} onChange={({ currentTarget }) => {
|
|
32
|
+
config.apiV3Key = currentTarget.value;
|
|
33
|
+
update(config);
|
|
34
|
+
}}/>
|
|
35
|
+
</Form.Item>
|
|
36
|
+
<Form.Item label={t('label.refundNotifyUrl')}>
|
|
37
|
+
<Input prefix={`${serverUrl}/endpoint`} suffix='/${refundId}' value={config.refundNotifyUrl} placeholder={t('placeholder.refundNotifyUrl')} onChange={({ currentTarget }) => {
|
|
38
|
+
config.refundNotifyUrl = 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
|
-
"
|
|
5
|
+
"payNotifyUrl": "支付回调URL",
|
|
6
|
+
"refundNotifyUrl": "退款回调URL",
|
|
7
|
+
"lossRatio": "手续费比例",
|
|
8
|
+
"apiV3Key": "apiV3Key"
|
|
6
9
|
},
|
|
7
10
|
"placeholder": {
|
|
8
11
|
"privateKeyFilePath": "服务器上存放微信支付帐户私钥文件的路径,注意访问权限",
|
|
9
12
|
"publicKeyFilePath": "服务器上存放微信支付帐户公钥文件的路径,注意访问权限",
|
|
10
|
-
"lossRatio": "填百分比(0.6就代表千分之六)"
|
|
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,8 @@ const i18ns = [
|
|
|
118
118
|
"order": "订单支付",
|
|
119
119
|
"account": "帐户充值"
|
|
120
120
|
},
|
|
121
|
-
"success": "支付成功"
|
|
121
|
+
"success": "支付成功",
|
|
122
|
+
"pay": "支付"
|
|
122
123
|
}
|
|
123
124
|
},
|
|
124
125
|
{
|
|
@@ -217,12 +218,18 @@ const i18ns = [
|
|
|
217
218
|
"label": {
|
|
218
219
|
"privateKeyFilePath": "私钥文件路径",
|
|
219
220
|
"publicKeyFilePath": "公钥文件路径",
|
|
220
|
-
"
|
|
221
|
+
"payNotifyUrl": "支付回调URL",
|
|
222
|
+
"refundNotifyUrl": "退款回调URL",
|
|
223
|
+
"lossRatio": "手续费比例",
|
|
224
|
+
"apiV3Key": "apiV3Key"
|
|
221
225
|
},
|
|
222
226
|
"placeholder": {
|
|
223
227
|
"privateKeyFilePath": "服务器上存放微信支付帐户私钥文件的路径,注意访问权限",
|
|
224
228
|
"publicKeyFilePath": "服务器上存放微信支付帐户公钥文件的路径,注意访问权限",
|
|
225
|
-
"lossRatio": "填百分比(0.6就代表千分之六)"
|
|
229
|
+
"lossRatio": "填百分比(0.6就代表千分之六)",
|
|
230
|
+
"payNotifyUrl": "填写回调的endpoint",
|
|
231
|
+
"refundNotifyUrl": "填写回调endpoint",
|
|
232
|
+
"apiV3Key": "需要登录商户后台获取"
|
|
226
233
|
}
|
|
227
234
|
}
|
|
228
235
|
},
|
package/es/types/Exception.d.ts
CHANGED
|
@@ -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;
|
package/es/types/Exception.js
CHANGED
|
@@ -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
|
-
|
|
19
|
+
let exception = makeDepedentException(data);
|
|
5
20
|
if (exception) {
|
|
6
21
|
return exception;
|
|
7
22
|
}
|
|
8
|
-
|
|
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
|
-
|
|
30
|
+
break;
|
|
12
31
|
}
|
|
13
|
-
}
|
|
32
|
+
}
|
|
33
|
+
if (exception) {
|
|
34
|
+
exception.setOpRecords(data.opRecords);
|
|
35
|
+
}
|
|
36
|
+
return exception;
|
|
14
37
|
}
|
package/es/types/PayClazz.d.ts
CHANGED
|
@@ -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']['
|
|
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
|
-
|
|
9
|
+
decodePayNotification(params: Record<string, any>, body: any): Promise<{
|
|
10
10
|
payId: string;
|
|
11
11
|
iState: IState;
|
|
12
|
-
extra?:
|
|
13
|
-
|
|
14
|
-
}
|
|
12
|
+
extra?: EntityDict['pay']['Update']['data'];
|
|
13
|
+
price?: number;
|
|
14
|
+
}>;
|
|
15
15
|
}
|
|
16
16
|
export {};
|
package/es/types/PayConfig.d.ts
CHANGED
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>;
|
package/es/utils/pay.js
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { getPayClazz } from './payClazz';
|
|
2
|
+
import assert from 'assert';
|
|
3
|
+
import { generateNewIdAsync } from 'oak-domain/lib/utils/uuid';
|
|
1
4
|
export const fullPayProjection = {
|
|
2
5
|
id: 1,
|
|
3
6
|
applicationId: 1,
|
|
@@ -10,5 +13,65 @@ export const fullPayProjection = {
|
|
|
10
13
|
timeoutAt: 1,
|
|
11
14
|
forbidRefundAt: 1,
|
|
12
15
|
orderId: 1,
|
|
16
|
+
order: {
|
|
17
|
+
id: 1,
|
|
18
|
+
title: 1,
|
|
19
|
+
desc: 1,
|
|
20
|
+
},
|
|
13
21
|
accountId: 1,
|
|
14
22
|
};
|
|
23
|
+
export async function payNotify(context, body, payId, headers) {
|
|
24
|
+
const [pay] = await context.select('pay', {
|
|
25
|
+
data: {
|
|
26
|
+
id: 1,
|
|
27
|
+
price: 1,
|
|
28
|
+
iState: 1,
|
|
29
|
+
channel: 1,
|
|
30
|
+
meta: 1,
|
|
31
|
+
applicationId: 1,
|
|
32
|
+
},
|
|
33
|
+
filter: {
|
|
34
|
+
id: payId,
|
|
35
|
+
}
|
|
36
|
+
}, {});
|
|
37
|
+
if (!pay) {
|
|
38
|
+
console.error('接受到无效的payId', payId);
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
const { applicationId, channel, price } = pay;
|
|
42
|
+
const payClazz = await getPayClazz(applicationId, channel, context);
|
|
43
|
+
const { payId: payId2, iState, extra } = await payClazz.decodePayNotification({
|
|
44
|
+
headers,
|
|
45
|
+
}, body);
|
|
46
|
+
assert(payId2 === payId);
|
|
47
|
+
if (iState !== pay.iState) {
|
|
48
|
+
let action = 'close';
|
|
49
|
+
const updateData = {};
|
|
50
|
+
switch (iState) {
|
|
51
|
+
case 'closed': {
|
|
52
|
+
// action = 'close';
|
|
53
|
+
break;
|
|
54
|
+
}
|
|
55
|
+
case 'paid': {
|
|
56
|
+
action = 'succeedPaying';
|
|
57
|
+
updateData.paid = price;
|
|
58
|
+
if (extra) {
|
|
59
|
+
Object.assign(updateData, extra);
|
|
60
|
+
}
|
|
61
|
+
break;
|
|
62
|
+
}
|
|
63
|
+
default: {
|
|
64
|
+
assert(false);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
await context.operate('pay', {
|
|
68
|
+
id: await generateNewIdAsync(),
|
|
69
|
+
action,
|
|
70
|
+
data: updateData,
|
|
71
|
+
filter: {
|
|
72
|
+
id: payId,
|
|
73
|
+
}
|
|
74
|
+
}, {});
|
|
75
|
+
}
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import { OpSchema, UpdateOperationData } from "../../oak-app-domain/Pay/Schema";
|
|
1
|
+
import { Schema, OpSchema, UpdateOperationData } from "../../oak-app-domain/Pay/Schema";
|
|
2
2
|
import PayClazz from "../../types/PayClazz";
|
|
3
3
|
export default class Account implements PayClazz {
|
|
4
|
-
|
|
5
|
-
prepay(pay: OpSchema, data: UpdateOperationData): Promise<void>;
|
|
6
|
-
getState(pay: OpSchema): Promise<string | null | undefined>;
|
|
7
|
-
close(pay: OpSchema): Promise<void>;
|
|
8
|
-
decodeNotification(params: Record<string, string>, body: any): Promise<{
|
|
4
|
+
decodePayNotification(params: Record<string, any>, body: any): Promise<{
|
|
9
5
|
payId: string;
|
|
10
6
|
iState: string | null | undefined;
|
|
11
|
-
extra?:
|
|
12
|
-
|
|
13
|
-
|
|
7
|
+
extra?: UpdateOperationData | undefined;
|
|
8
|
+
}>;
|
|
9
|
+
channel: string;
|
|
10
|
+
prepay(pay: Schema, data: UpdateOperationData): Promise<void>;
|
|
11
|
+
getState(pay: OpSchema): Promise<[string, UpdateOperationData]>;
|
|
12
|
+
close(pay: OpSchema): Promise<void>;
|
|
14
13
|
}
|