@pisell/private-materials 6.3.26 → 6.3.28
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/build/lowcode/assets-daily.json +11 -11
- package/build/lowcode/assets-dev.json +2 -2
- package/build/lowcode/assets-prod.json +11 -11
- package/build/lowcode/index.js +1 -1
- package/build/lowcode/meta.js +1 -1
- package/build/lowcode/preview.js +8 -8
- package/build/lowcode/render/default/view.css +1 -1
- package/build/lowcode/render/default/view.js +7 -7
- package/build/lowcode/view.css +1 -1
- package/build/lowcode/view.js +7 -7
- package/es/components/eftposPay/linkly/index.js +64 -2
- package/es/components/pay/toC/PaymentMethods/ApplePay/index.js +68 -35
- package/es/components/pay/toC/PaymentMethods/GooglePay/index.js +70 -42
- package/es/components/pay/toC/PaymentMethods/SuperPayAliPayH5/index.js +72 -41
- package/es/components/pay/toC/PaymentMethods/components/PaymentReturnContent/index.d.ts +15 -0
- package/es/components/pay/toC/PaymentMethods/components/PaymentReturnContent/index.js +143 -0
- package/es/components/pay/toC/PaymentMethods/components/PaymentReturnContent/index.less +34 -0
- package/es/components/pay/toC/PaymentMethods/hooks/index.d.ts +19 -0
- package/es/components/pay/toC/PaymentMethods/hooks/index.js +126 -0
- package/es/components/pay/toC/index.js +3 -2
- package/es/components/pay/toC/locales.d.ts +9 -0
- package/es/components/pay/toC/locales.js +12 -3
- package/es/components/pay/toC/model.d.ts +1 -0
- package/es/components/pay/toC/serve.d.ts +5 -0
- package/es/components/pay/toC/serve.js +9 -1
- package/lib/components/eftposPay/linkly/index.js +31 -1
- package/lib/components/pay/toC/PaymentMethods/ApplePay/index.js +27 -7
- package/lib/components/pay/toC/PaymentMethods/GooglePay/index.js +32 -8
- package/lib/components/pay/toC/PaymentMethods/SuperPayAliPayH5/index.js +30 -4
- package/lib/components/pay/toC/PaymentMethods/components/PaymentReturnContent/index.d.ts +15 -0
- package/lib/components/pay/toC/PaymentMethods/components/PaymentReturnContent/index.js +88 -0
- package/lib/components/pay/toC/PaymentMethods/components/PaymentReturnContent/index.less +34 -0
- package/lib/components/pay/toC/PaymentMethods/hooks/index.d.ts +19 -0
- package/lib/components/pay/toC/PaymentMethods/hooks/index.js +90 -0
- package/lib/components/pay/toC/index.js +2 -1
- package/lib/components/pay/toC/locales.d.ts +9 -0
- package/lib/components/pay/toC/locales.js +12 -3
- package/lib/components/pay/toC/model.d.ts +1 -0
- package/lib/components/pay/toC/serve.d.ts +5 -0
- package/lib/components/pay/toC/serve.js +3 -0
- package/package.json +4 -4
|
@@ -113,7 +113,10 @@ export default {
|
|
|
113
113
|
return "You can select multiple ".concat(walletName, " to combine for payment");
|
|
114
114
|
},
|
|
115
115
|
'tocPay.text.bestValueCombination': 'Best value combination',
|
|
116
|
-
'tocPay.text.viewDetail': 'View detail'
|
|
116
|
+
'tocPay.text.viewDetail': 'View detail',
|
|
117
|
+
'tocPay.text.returnAndSelectOtherPaymentMethod': 'Go Back / Choose Another Payment',
|
|
118
|
+
'tocPay.text.paymentCompletedAndViewOrder': 'Payment Completed / View Order',
|
|
119
|
+
'tocPay.text.paymentFailed': 'Not paid yet, please check if the payment is successful'
|
|
117
120
|
},
|
|
118
121
|
'zh-CN': {
|
|
119
122
|
'tocPay.text.checkout': '结账',
|
|
@@ -228,7 +231,10 @@ export default {
|
|
|
228
231
|
return "\u60A8\u53EF\u4EE5\u9009\u62E9\u591A\u4E2A".concat(walletName, "\u8FDB\u884C\u7EC4\u5408\u4ED8\u6B3E");
|
|
229
232
|
},
|
|
230
233
|
'tocPay.text.bestValueCombination': '最佳组合',
|
|
231
|
-
'tocPay.text.viewDetail': '查看详情'
|
|
234
|
+
'tocPay.text.viewDetail': '查看详情',
|
|
235
|
+
'tocPay.text.returnAndSelectOtherPaymentMethod': '返回 / 选择其他支付方式',
|
|
236
|
+
'tocPay.text.paymentCompletedAndViewOrder': '支付完成 / 查看订单',
|
|
237
|
+
'tocPay.text.paymentFailed': "未支付完成,请检查是否支付成功"
|
|
232
238
|
},
|
|
233
239
|
'zh-HK': {
|
|
234
240
|
'tocPay.text.checkout': '結帳',
|
|
@@ -343,6 +349,9 @@ export default {
|
|
|
343
349
|
return "\u60A8\u53EF\u4EE5\u9078\u64C7\u591A\u500B".concat(walletName, "\u9032\u884C\u7D44\u5408\u4ED8\u6B3E");
|
|
344
350
|
},
|
|
345
351
|
'tocPay.text.bestValueCombination': '最佳組合',
|
|
346
|
-
'tocPay.text.viewDetail': '查看詳情'
|
|
352
|
+
'tocPay.text.viewDetail': '查看詳情',
|
|
353
|
+
'tocPay.text.returnAndSelectOtherPaymentMethod': '返回 / 選擇其他支付方式',
|
|
354
|
+
'tocPay.text.paymentCompletedAndViewOrder': '支付完成 / 查看訂單',
|
|
355
|
+
'tocPay.text.paymentFailed': "未支付完成,请检查是否支付成功"
|
|
347
356
|
}
|
|
348
357
|
};
|
|
@@ -177,4 +177,12 @@ export var getWalletNameAndPopupStatus = /*#__PURE__*/function () {
|
|
|
177
177
|
return function getWalletNameAndPopupStatus(_x4) {
|
|
178
178
|
return _ref4.apply(this, arguments);
|
|
179
179
|
};
|
|
180
|
-
}();
|
|
180
|
+
}();
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* @title: 获取支付结果
|
|
184
|
+
* @description: 获取支付结果
|
|
185
|
+
*/
|
|
186
|
+
export var getPaymentResult = function getPaymentResult(values) {
|
|
187
|
+
return request.getRequest().get("/h5/pay/order/payment/result", values);
|
|
188
|
+
};
|
|
@@ -125,6 +125,7 @@ var Linkly = ({ api, onChange }) => {
|
|
|
125
125
|
failRef.current = fail;
|
|
126
126
|
}, [fail]);
|
|
127
127
|
(0, import_react.useEffect)(() => {
|
|
128
|
+
var _a, _b, _c;
|
|
128
129
|
if (statusRef.current === import_const.StatusEnum.Success || statusRef.current === import_const.StatusEnum.Fail) {
|
|
129
130
|
return;
|
|
130
131
|
}
|
|
@@ -136,7 +137,36 @@ var Linkly = ({ api, onChange }) => {
|
|
|
136
137
|
resultQuery();
|
|
137
138
|
return;
|
|
138
139
|
}
|
|
139
|
-
|
|
140
|
+
if (((_a = utils == null ? void 0 : utils.isTerminal) == null ? void 0 : _a.call(utils)) && ((_c = (_b = utils == null ? void 0 : utils.interaction) == null ? void 0 : _b.utils) == null ? void 0 : _c.asyncDataManager)) {
|
|
141
|
+
const _payOrRefund = async () => {
|
|
142
|
+
var _a2, _b2, _c2;
|
|
143
|
+
try {
|
|
144
|
+
const activeStatus = await ((_c2 = (_b2 = (_a2 = utils == null ? void 0 : utils.interaction) == null ? void 0 : _a2.utils) == null ? void 0 : _b2.asyncDataManager) == null ? void 0 : _c2.call(_b2, {
|
|
145
|
+
module: "get",
|
|
146
|
+
key: "pay_webview_active"
|
|
147
|
+
}));
|
|
148
|
+
if (activeStatus !== "unActive") {
|
|
149
|
+
payOrRefund(resultQuery, handleLinklySuccess);
|
|
150
|
+
} else {
|
|
151
|
+
(0, import_utils.sendWarningLog)({
|
|
152
|
+
title: "Linkly-支付-当前页面非活跃状态,无法进行支付",
|
|
153
|
+
content: [
|
|
154
|
+
{ key: "response", value: JSON.stringify({ activeStatus }) }
|
|
155
|
+
]
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
} catch (error) {
|
|
159
|
+
(0, import_utils.sendWarningLog)({
|
|
160
|
+
title: "Linkly-支付-获取当前页面活跃状态失败",
|
|
161
|
+
content: [{ key: "error", value: JSON.stringify(error) }]
|
|
162
|
+
});
|
|
163
|
+
payOrRefund(resultQuery, handleLinklySuccess);
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
_payOrRefund();
|
|
167
|
+
} else {
|
|
168
|
+
payOrRefund(resultQuery, handleLinklySuccess);
|
|
169
|
+
}
|
|
140
170
|
}, []);
|
|
141
171
|
(0, import_react.useEffect)(() => {
|
|
142
172
|
return () => {
|
|
@@ -35,15 +35,17 @@ module.exports = __toCommonJS(ApplePay_exports);
|
|
|
35
35
|
var import_react = __toESM(require("react"));
|
|
36
36
|
var import_materials = require("@pisell/materials");
|
|
37
37
|
var import_ThreedsLoading = __toESM(require("../MWCreditCard/TDSPay/ThreedsLoading"));
|
|
38
|
+
var import_PaymentReturnContent = __toESM(require("../components/PaymentReturnContent"));
|
|
38
39
|
var import_model = require("../../model");
|
|
39
40
|
var import_utils = require("@pisell/utils");
|
|
40
41
|
var import_payGroup = require("../../payGroup");
|
|
41
42
|
var import_useEngineContext = __toESM(require("../../../../../hooks/useEngineContext"));
|
|
42
43
|
var import_usePaymentLogger = __toESM(require("../../../../../hooks/usePaymentLogger"));
|
|
44
|
+
var import_hooks = require("../hooks");
|
|
43
45
|
var import_index = require("./index.less");
|
|
44
46
|
var import_utils2 = require("../../utils");
|
|
45
47
|
var ApplePay = (props, ref) => {
|
|
46
|
-
var _a, _b;
|
|
48
|
+
var _a, _b, _c, _d;
|
|
47
49
|
const { state } = (0, import_react.useContext)(import_model.Context);
|
|
48
50
|
const [open, setOpen] = (0, import_react.useState)(false);
|
|
49
51
|
const context = (0, import_useEngineContext.default)();
|
|
@@ -52,8 +54,12 @@ var ApplePay = (props, ref) => {
|
|
|
52
54
|
orderId: ((_b = state.payGroup) == null ? void 0 : _b.order_id) || "unknown",
|
|
53
55
|
step: "2"
|
|
54
56
|
});
|
|
57
|
+
const { isReturned, handleRedirect, resetState } = (0, import_hooks.usePaymentRedirect)({
|
|
58
|
+
orderId: (_c = state.payGroup) == null ? void 0 : _c.order_id,
|
|
59
|
+
paymentType: "applePay"
|
|
60
|
+
});
|
|
55
61
|
const init = async ({ payGroup }) => {
|
|
56
|
-
var _a2, _b2,
|
|
62
|
+
var _a2, _b2, _c2, _d2, _e, _f, _g;
|
|
57
63
|
paymentLogger.addLog({
|
|
58
64
|
key: "ApplePay初始化开始",
|
|
59
65
|
value: ""
|
|
@@ -81,14 +87,14 @@ var ApplePay = (props, ref) => {
|
|
|
81
87
|
value: ""
|
|
82
88
|
});
|
|
83
89
|
try {
|
|
84
|
-
const locale = ((
|
|
85
|
-
const shopId = (_f = (_e = (
|
|
90
|
+
const locale = ((_c2 = dvaStore.core) == null ? void 0 : _c2.translateLocale) || "en";
|
|
91
|
+
const shopId = (_f = (_e = (_d2 = dvaStore.core) == null ? void 0 : _d2.core) == null ? void 0 : _e.shop) == null ? void 0 : _f.id;
|
|
86
92
|
const currentURL = window.location.href;
|
|
87
93
|
const linkElement = document.createElement("a");
|
|
88
94
|
linkElement.href = currentURL;
|
|
89
95
|
const shop_domain = linkElement.hostname;
|
|
90
96
|
const _href = `${config.pay}${(0, import_utils2.formatFranchiseeRoute)(
|
|
91
|
-
`/apple-pay?order_id=${(_g = state.payGroup) == null ? void 0 : _g.order_id}&shop_id=${shopId}&locale=${locale}&shop_domain=${shop_domain}&total_amount=${values.amount}&payment_group_id=${values.payment_group_id}`,
|
|
97
|
+
`/apple-pay?order_id=${(_g = state.payGroup) == null ? void 0 : _g.order_id}&shop_id=${shopId}&locale=${locale}&shop_domain=${shop_domain}&total_amount=${values.amount}&payment_group_id=${values.payment_group_id}&front_order_uuid=${state.front_order_uuid}`,
|
|
92
98
|
state.history
|
|
93
99
|
)}`;
|
|
94
100
|
paymentLogger.addLog({
|
|
@@ -96,7 +102,7 @@ var ApplePay = (props, ref) => {
|
|
|
96
102
|
value: ""
|
|
97
103
|
});
|
|
98
104
|
paymentLogger.sendLogs("ApplePay跳转成功");
|
|
99
|
-
|
|
105
|
+
await handleRedirect(_href);
|
|
100
106
|
} catch (err) {
|
|
101
107
|
paymentLogger.addLog({
|
|
102
108
|
key: "ApplePay处理错误",
|
|
@@ -118,6 +124,10 @@ var ApplePay = (props, ref) => {
|
|
|
118
124
|
init
|
|
119
125
|
})
|
|
120
126
|
);
|
|
127
|
+
const handleReturn = () => {
|
|
128
|
+
setOpen(false);
|
|
129
|
+
resetState();
|
|
130
|
+
};
|
|
121
131
|
return /* @__PURE__ */ import_react.default.createElement(
|
|
122
132
|
import_materials.PisellModal,
|
|
123
133
|
{
|
|
@@ -128,11 +138,21 @@ var ApplePay = (props, ref) => {
|
|
|
128
138
|
closable: false,
|
|
129
139
|
bodyStyle: { padding: 0 }
|
|
130
140
|
},
|
|
131
|
-
/* @__PURE__ */ import_react.default.createElement("div", { className: "" },
|
|
141
|
+
/* @__PURE__ */ import_react.default.createElement("div", { className: "" }, !isReturned && // 跳转前展示 Loading
|
|
142
|
+
/* @__PURE__ */ import_react.default.createElement(
|
|
132
143
|
import_ThreedsLoading.default,
|
|
133
144
|
{
|
|
134
145
|
title: import_utils.locales.getText("tocPay.text.connectingApplePay")
|
|
135
146
|
}
|
|
147
|
+
), isReturned && // 跳转后返回时展示新组件内容
|
|
148
|
+
/* @__PURE__ */ import_react.default.createElement(
|
|
149
|
+
import_PaymentReturnContent.default,
|
|
150
|
+
{
|
|
151
|
+
handleReturn,
|
|
152
|
+
state,
|
|
153
|
+
orderId: (_d = state.payGroup) == null ? void 0 : _d.order_id,
|
|
154
|
+
unique_payment_number: state == null ? void 0 : state.front_order_uuid
|
|
155
|
+
}
|
|
136
156
|
))
|
|
137
157
|
);
|
|
138
158
|
};
|
|
@@ -41,8 +41,10 @@ var import_payGroup = require("../../payGroup");
|
|
|
41
41
|
var import_useEngineContext = __toESM(require("../../../../../hooks/useEngineContext"));
|
|
42
42
|
var import_usePaymentLogger = __toESM(require("../../../../../hooks/usePaymentLogger"));
|
|
43
43
|
var import_utils2 = require("../../utils");
|
|
44
|
+
var import_hooks = require("../hooks");
|
|
45
|
+
var import_PaymentReturnContent = __toESM(require("../components/PaymentReturnContent"));
|
|
44
46
|
var GooglePay = (props, ref) => {
|
|
45
|
-
var _a, _b, _c;
|
|
47
|
+
var _a, _b, _c, _d, _e;
|
|
46
48
|
const { state } = (0, import_react.useContext)(import_model.Context);
|
|
47
49
|
const [open, setOpen] = (0, import_react.useState)(false);
|
|
48
50
|
const context = (0, import_useEngineContext.default)();
|
|
@@ -52,12 +54,17 @@ var GooglePay = (props, ref) => {
|
|
|
52
54
|
orderId: ((_c = state.payGroup) == null ? void 0 : _c.order_id) || "unknown",
|
|
53
55
|
step: "2"
|
|
54
56
|
});
|
|
57
|
+
const { isReturned, handleRedirect, resetState } = (0, import_hooks.usePaymentRedirect)({
|
|
58
|
+
orderId: (_d = state.payGroup) == null ? void 0 : _d.order_id,
|
|
59
|
+
paymentType: "googlePay"
|
|
60
|
+
});
|
|
55
61
|
const init = async ({ payGroup }) => {
|
|
56
|
-
var _a2, _b2, _c2,
|
|
62
|
+
var _a2, _b2, _c2, _d2, _e2, _f, _g, _h, _i, _j, _k;
|
|
57
63
|
paymentLogger.addLog({
|
|
58
64
|
key: "GooglePay初始化开始",
|
|
59
65
|
value: ""
|
|
60
66
|
});
|
|
67
|
+
setOpen(true);
|
|
61
68
|
const utils = context.appHelper.utils || {};
|
|
62
69
|
const dvaStore = (_b2 = (_a2 = utils == null ? void 0 : utils.getStore) == null ? void 0 : _a2.call(utils)) == null ? void 0 : _b2.getState();
|
|
63
70
|
const values = (0, import_payGroup.getPayGroupParamsFromStorage)(payGroup.order_id);
|
|
@@ -79,15 +86,19 @@ var GooglePay = (props, ref) => {
|
|
|
79
86
|
key: "GooglePay获取支付参数成功",
|
|
80
87
|
value: ""
|
|
81
88
|
});
|
|
82
|
-
if (((
|
|
89
|
+
if (((_d2 = (_c2 = interaction == null ? void 0 : interaction.utils) == null ? void 0 : _c2.isAppEnv) == null ? void 0 : _d2.call(_c2)) && ((_f = (_e2 = interaction == null ? void 0 : interaction.utils) == null ? void 0 : _e2.isAndroid_ios) == null ? void 0 : _f.call(_e2)) === "android") {
|
|
83
90
|
paymentLogger.addLog({
|
|
84
91
|
key: "GooglePay使用Android客户端支付",
|
|
85
92
|
value: ""
|
|
86
93
|
});
|
|
87
94
|
paymentLogger.sendLogs("GooglePay客户端支付");
|
|
88
|
-
return (0, import_utils2.clientPayment)({
|
|
95
|
+
return (0, import_utils2.clientPayment)({
|
|
96
|
+
order_id: payGroup.order_id,
|
|
97
|
+
type: "google_pay",
|
|
98
|
+
values,
|
|
99
|
+
interaction
|
|
100
|
+
});
|
|
89
101
|
}
|
|
90
|
-
setOpen(true);
|
|
91
102
|
try {
|
|
92
103
|
const locale = ((_g = dvaStore.core) == null ? void 0 : _g.translateLocale) || "en";
|
|
93
104
|
const shopId = (_j = (_i = (_h = dvaStore.core) == null ? void 0 : _h.core) == null ? void 0 : _i.shop) == null ? void 0 : _j.id;
|
|
@@ -96,7 +107,7 @@ var GooglePay = (props, ref) => {
|
|
|
96
107
|
linkElement.href = currentURL;
|
|
97
108
|
const shop_domain = linkElement.hostname;
|
|
98
109
|
const _href = `${config.pay}${(0, import_utils2.formatFranchiseeRoute)(
|
|
99
|
-
`/google-pay?order_id=${(_k = state.payGroup) == null ? void 0 : _k.order_id}&shop_id=${shopId}&locale=${locale}&shop_domain=${shop_domain}&total_amount=${values.amount}&payment_group_id=${values.payment_group_id}`,
|
|
110
|
+
`/google-pay?order_id=${(_k = state.payGroup) == null ? void 0 : _k.order_id}&shop_id=${shopId}&locale=${locale}&shop_domain=${shop_domain}&total_amount=${values.amount}&payment_group_id=${values.payment_group_id}&front_order_uuid=${state.front_order_uuid}`,
|
|
100
111
|
state.history
|
|
101
112
|
)}`;
|
|
102
113
|
paymentLogger.addLog({
|
|
@@ -104,7 +115,7 @@ var GooglePay = (props, ref) => {
|
|
|
104
115
|
value: ""
|
|
105
116
|
});
|
|
106
117
|
paymentLogger.sendLogs("GooglePay跳转成功");
|
|
107
|
-
|
|
118
|
+
await handleRedirect(_href);
|
|
108
119
|
} catch (err) {
|
|
109
120
|
paymentLogger.addLog({
|
|
110
121
|
key: "GooglePay处理错误",
|
|
@@ -126,6 +137,10 @@ var GooglePay = (props, ref) => {
|
|
|
126
137
|
init
|
|
127
138
|
})
|
|
128
139
|
);
|
|
140
|
+
const handleReturn = () => {
|
|
141
|
+
setOpen(false);
|
|
142
|
+
resetState();
|
|
143
|
+
};
|
|
129
144
|
return /* @__PURE__ */ import_react.default.createElement(
|
|
130
145
|
import_materials.PisellModal,
|
|
131
146
|
{
|
|
@@ -136,11 +151,20 @@ var GooglePay = (props, ref) => {
|
|
|
136
151
|
closable: false,
|
|
137
152
|
bodyStyle: { padding: 0 }
|
|
138
153
|
},
|
|
139
|
-
/* @__PURE__ */ import_react.default.createElement("div", { className: "" }, /* @__PURE__ */ import_react.default.createElement(
|
|
154
|
+
/* @__PURE__ */ import_react.default.createElement("div", { className: "" }, !isReturned && /* @__PURE__ */ import_react.default.createElement(
|
|
140
155
|
import_ThreedsLoading.default,
|
|
141
156
|
{
|
|
142
157
|
title: import_utils.locales.getText("tocPay.text.connectingGooglePay")
|
|
143
158
|
}
|
|
159
|
+
), isReturned && // 跳转后返回时展示新组件内容
|
|
160
|
+
/* @__PURE__ */ import_react.default.createElement(
|
|
161
|
+
import_PaymentReturnContent.default,
|
|
162
|
+
{
|
|
163
|
+
handleReturn,
|
|
164
|
+
state,
|
|
165
|
+
orderId: (_e = state.payGroup) == null ? void 0 : _e.order_id,
|
|
166
|
+
unique_payment_number: state.front_order_uuid
|
|
167
|
+
}
|
|
144
168
|
))
|
|
145
169
|
);
|
|
146
170
|
};
|
|
@@ -43,18 +43,25 @@ var import_index = require("./index.less");
|
|
|
43
43
|
var import_useEngineContext = __toESM(require("../../../../../hooks/useEngineContext"));
|
|
44
44
|
var import_usePaymentLogger = __toESM(require("../../../../../hooks/usePaymentLogger"));
|
|
45
45
|
var import_utils2 = require("../../utils");
|
|
46
|
+
var import_hooks = require("../hooks");
|
|
47
|
+
var import_PaymentReturnContent = __toESM(require("../components/PaymentReturnContent"));
|
|
46
48
|
var SuperPayAliPayH5 = (props, ref) => {
|
|
47
|
-
var _a, _b;
|
|
49
|
+
var _a, _b, _c, _d;
|
|
48
50
|
const { state } = (0, import_react.useContext)(import_model.Context);
|
|
49
51
|
const { onChange } = props;
|
|
50
52
|
const [open, setOpen] = (0, import_react.useState)(false);
|
|
51
53
|
const [showSuccessBackButton, setShowSuccessBackButton] = (0, import_react.useState)(false);
|
|
54
|
+
const [statePayNumber, setStatePayNumber] = (0, import_react.useState)("");
|
|
52
55
|
const context = (0, import_useEngineContext.default)();
|
|
53
56
|
const { interaction } = (_a = context.appHelper) == null ? void 0 : _a.utils;
|
|
54
57
|
const paymentLogger = (0, import_usePaymentLogger.default)({
|
|
55
58
|
orderId: ((_b = state.payGroup) == null ? void 0 : _b.order_id) || "unknown",
|
|
56
59
|
step: "2"
|
|
57
60
|
});
|
|
61
|
+
const { isReturned, handleRedirect, resetState } = (0, import_hooks.usePaymentRedirect)({
|
|
62
|
+
orderId: (_c = state.payGroup) == null ? void 0 : _c.order_id,
|
|
63
|
+
paymentType: "aliPay"
|
|
64
|
+
});
|
|
58
65
|
const init = async ({ payGroup }) => {
|
|
59
66
|
var _a2, _b2;
|
|
60
67
|
paymentLogger.addLog({
|
|
@@ -68,7 +75,12 @@ var SuperPayAliPayH5 = (props, ref) => {
|
|
|
68
75
|
value: "检测到App环境,调用客户端支付"
|
|
69
76
|
});
|
|
70
77
|
paymentLogger.sendLogs("SuperPayAliPayH5App环境支付");
|
|
71
|
-
return (0, import_utils2.clientPayment)({
|
|
78
|
+
return (0, import_utils2.clientPayment)({
|
|
79
|
+
order_id: payGroup.order_id,
|
|
80
|
+
type: "aliPay",
|
|
81
|
+
values,
|
|
82
|
+
interaction
|
|
83
|
+
});
|
|
72
84
|
}
|
|
73
85
|
setOpen(true);
|
|
74
86
|
if (!values) {
|
|
@@ -97,13 +109,14 @@ var SuperPayAliPayH5 = (props, ref) => {
|
|
|
97
109
|
value: ""
|
|
98
110
|
});
|
|
99
111
|
(0, import_payGroup.setPayNumber)(payGroup == null ? void 0 : payGroup.order_id, data == null ? void 0 : data.pay_number);
|
|
112
|
+
setStatePayNumber(data == null ? void 0 : data.pay_number);
|
|
100
113
|
setShowSuccessBackButton(true);
|
|
101
114
|
paymentLogger.addLog({
|
|
102
115
|
key: "SuperPayAliPayH5准备跳转支付宝",
|
|
103
116
|
value: ""
|
|
104
117
|
});
|
|
105
118
|
paymentLogger.sendLogs("SuperPayAliPayH5跳转成功");
|
|
106
|
-
|
|
119
|
+
await handleRedirect(data == null ? void 0 : data.pay_url);
|
|
107
120
|
} else {
|
|
108
121
|
paymentLogger.addLog({
|
|
109
122
|
key: "SuperPayAliPayH5支付链接为空",
|
|
@@ -144,6 +157,10 @@ var SuperPayAliPayH5 = (props, ref) => {
|
|
|
144
157
|
key: "success"
|
|
145
158
|
});
|
|
146
159
|
};
|
|
160
|
+
const handleReturn = () => {
|
|
161
|
+
setOpen(false);
|
|
162
|
+
resetState();
|
|
163
|
+
};
|
|
147
164
|
return /* @__PURE__ */ import_react.default.createElement(
|
|
148
165
|
import_materials.PisellModal,
|
|
149
166
|
{
|
|
@@ -154,13 +171,22 @@ var SuperPayAliPayH5 = (props, ref) => {
|
|
|
154
171
|
closable: false,
|
|
155
172
|
bodyStyle: { padding: 0 }
|
|
156
173
|
},
|
|
157
|
-
/* @__PURE__ */ import_react.default.createElement("div", { className: "" }, /* @__PURE__ */ import_react.default.createElement(
|
|
174
|
+
/* @__PURE__ */ import_react.default.createElement("div", { className: "" }, !isReturned && /* @__PURE__ */ import_react.default.createElement(
|
|
158
175
|
import_ThreedsLoading.default,
|
|
159
176
|
{
|
|
160
177
|
title: import_utils.locales.getText("tocPay.text.redirectingToAlipay"),
|
|
161
178
|
onSuccessBack: handleSuccessBack,
|
|
162
179
|
showSuccessBackButton
|
|
163
180
|
}
|
|
181
|
+
), isReturned && /* @__PURE__ */ import_react.default.createElement(
|
|
182
|
+
import_PaymentReturnContent.default,
|
|
183
|
+
{
|
|
184
|
+
pay_number: statePayNumber,
|
|
185
|
+
handleReturn,
|
|
186
|
+
state,
|
|
187
|
+
orderId: (_d = state.payGroup) == null ? void 0 : _d.order_id,
|
|
188
|
+
unique_payment_number: state.front_order_uuid
|
|
189
|
+
}
|
|
164
190
|
))
|
|
165
191
|
);
|
|
166
192
|
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import './index.less';
|
|
3
|
+
export interface PaymentReturnContentProps {
|
|
4
|
+
orderId?: string;
|
|
5
|
+
unique_payment_number?: string;
|
|
6
|
+
state?: any;
|
|
7
|
+
handleReturn?: () => void;
|
|
8
|
+
pay_number?: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* 支付返回后展示的内容组件
|
|
12
|
+
* 当用户从外部支付页面返回时展示此组件
|
|
13
|
+
*/
|
|
14
|
+
declare const PaymentReturnContent: React.FC<PaymentReturnContentProps>;
|
|
15
|
+
export default PaymentReturnContent;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
|
|
29
|
+
// src/components/pay/toC/PaymentMethods/components/PaymentReturnContent/index.tsx
|
|
30
|
+
var PaymentReturnContent_exports = {};
|
|
31
|
+
__export(PaymentReturnContent_exports, {
|
|
32
|
+
default: () => PaymentReturnContent_default
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(PaymentReturnContent_exports);
|
|
35
|
+
var import_react = __toESM(require("react"));
|
|
36
|
+
var import_materials = require("@pisell/materials");
|
|
37
|
+
var import_utils = require("@pisell/utils");
|
|
38
|
+
var import_ahooks = require("ahooks");
|
|
39
|
+
var import_serve = require("../../../serve");
|
|
40
|
+
var import_usePrefix = __toESM(require("../../../../../../hooks/usePrefix"));
|
|
41
|
+
var import_index = require("./index.less");
|
|
42
|
+
var PaymentReturnContent = ({
|
|
43
|
+
orderId,
|
|
44
|
+
unique_payment_number,
|
|
45
|
+
state,
|
|
46
|
+
handleReturn,
|
|
47
|
+
pay_number
|
|
48
|
+
}) => {
|
|
49
|
+
const prefix = (0, import_usePrefix.default)();
|
|
50
|
+
const getPaymentIsPaid = (0, import_ahooks.useMemoizedFn)(async () => {
|
|
51
|
+
if (!unique_payment_number && !pay_number) {
|
|
52
|
+
return true;
|
|
53
|
+
}
|
|
54
|
+
const { data } = await (0, import_serve.getPaymentResult)({
|
|
55
|
+
order_id: orderId,
|
|
56
|
+
pay_number,
|
|
57
|
+
unique_payment_number: pay_number ? void 0 : unique_payment_number
|
|
58
|
+
});
|
|
59
|
+
return (data == null ? void 0 : data.payment_status) === "paid";
|
|
60
|
+
});
|
|
61
|
+
const handleViewOrder = async () => {
|
|
62
|
+
var _a;
|
|
63
|
+
const isPaid = await getPaymentIsPaid();
|
|
64
|
+
if (!isPaid) {
|
|
65
|
+
(0, import_materials.PisellToast)({
|
|
66
|
+
content: import_utils.locales.getText("tocPay.text.paymentFailed")
|
|
67
|
+
});
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
(_a = state.payCallback) == null ? void 0 : _a.call(state, {
|
|
71
|
+
key: "success"
|
|
72
|
+
});
|
|
73
|
+
};
|
|
74
|
+
const handleGoBack = async () => {
|
|
75
|
+
var _a;
|
|
76
|
+
const isPaid = await getPaymentIsPaid();
|
|
77
|
+
if (!isPaid) {
|
|
78
|
+
handleReturn == null ? void 0 : handleReturn();
|
|
79
|
+
return;
|
|
80
|
+
} else {
|
|
81
|
+
(_a = state.payCallback) == null ? void 0 : _a.call(state, {
|
|
82
|
+
key: "success"
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
return /* @__PURE__ */ import_react.default.createElement("div", { className: "payment-return-content" }, /* @__PURE__ */ import_react.default.createElement("div", { className: "payment-return-content-img" }, /* @__PURE__ */ import_react.default.createElement("img", { src: `${prefix}/payment-content.png`, alt: "success" })), /* @__PURE__ */ import_react.default.createElement("div", { className: "payment-return-content-buttons" }, /* @__PURE__ */ import_react.default.createElement(import_materials.Button, { block: true, className: "payment-return-content-order-button", onClick: handleViewOrder }, import_utils.locales.getText("tocPay.text.paymentCompletedAndViewOrder")), /* @__PURE__ */ import_react.default.createElement(import_materials.Button, { block: true, onClick: handleGoBack }, import_utils.locales.getText("tocPay.text.returnAndSelectOtherPaymentMethod"))));
|
|
87
|
+
};
|
|
88
|
+
var PaymentReturnContent_default = PaymentReturnContent;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
.payment-return-content {
|
|
2
|
+
padding: 100px 46px 0;
|
|
3
|
+
|
|
4
|
+
.payment-return-content-img {
|
|
5
|
+
width: 100%;
|
|
6
|
+
margin-bottom: 60px;
|
|
7
|
+
min-height: 270px;
|
|
8
|
+
img {
|
|
9
|
+
width: 100%;
|
|
10
|
+
height: 100%;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.payment-return-content-buttons {
|
|
15
|
+
display: flex;
|
|
16
|
+
flex-direction: column;
|
|
17
|
+
gap: 24px;
|
|
18
|
+
button {
|
|
19
|
+
border-radius: 40px;
|
|
20
|
+
span {
|
|
21
|
+
width: 100%;
|
|
22
|
+
text-overflow: ellipsis;
|
|
23
|
+
overflow: hidden;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
.payment-return-content-order-button {
|
|
27
|
+
background: #7F56DA;
|
|
28
|
+
color: var(--Primary-700, #6941C6);
|
|
29
|
+
border: 1px solid var(--Primary-200, #E9D7FE);
|
|
30
|
+
background: var(--Primary-50, #F9F5FF);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export interface UsePaymentRedirectOptions {
|
|
2
|
+
orderId?: string;
|
|
3
|
+
paymentType: string;
|
|
4
|
+
onAfterReturn?: () => void;
|
|
5
|
+
}
|
|
6
|
+
export interface UsePaymentRedirectReturn {
|
|
7
|
+
isReturned: boolean;
|
|
8
|
+
handleRedirect: (url: string) => Promise<void>;
|
|
9
|
+
resetState: () => void;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* 支付跳转 Hook
|
|
13
|
+
* 用于处理跳转到外部支付页面的逻辑,包括:
|
|
14
|
+
* 1. 保存跳转标记到 history state
|
|
15
|
+
* 2. 跳转到外部支付页面
|
|
16
|
+
* 3. 监听页面返回事件
|
|
17
|
+
* 4. 返回后更新状态
|
|
18
|
+
*/
|
|
19
|
+
export declare const usePaymentRedirect: (options: UsePaymentRedirectOptions) => UsePaymentRedirectReturn;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/components/pay/toC/PaymentMethods/hooks/index.tsx
|
|
20
|
+
var hooks_exports = {};
|
|
21
|
+
__export(hooks_exports, {
|
|
22
|
+
usePaymentRedirect: () => usePaymentRedirect
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(hooks_exports);
|
|
25
|
+
var import_ahooks = require("ahooks");
|
|
26
|
+
var import_react = require("react");
|
|
27
|
+
var usePaymentRedirect = (options) => {
|
|
28
|
+
const { orderId, paymentType, onAfterReturn } = options;
|
|
29
|
+
const [isReturned, setIsReturned] = (0, import_react.useState)(false);
|
|
30
|
+
const handleRedirect = (0, import_ahooks.useMemoizedFn)(
|
|
31
|
+
async (url) => {
|
|
32
|
+
try {
|
|
33
|
+
const currentState = window.history.state || {};
|
|
34
|
+
window.history.replaceState(
|
|
35
|
+
{
|
|
36
|
+
...currentState,
|
|
37
|
+
paymentRedirected: true,
|
|
38
|
+
paymentType,
|
|
39
|
+
orderId,
|
|
40
|
+
timestamp: Date.now()
|
|
41
|
+
},
|
|
42
|
+
"",
|
|
43
|
+
window.location.href
|
|
44
|
+
);
|
|
45
|
+
window.location.href = url;
|
|
46
|
+
} catch (error) {
|
|
47
|
+
throw error;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
);
|
|
51
|
+
const resetState = (0, import_ahooks.useMemoizedFn)(() => {
|
|
52
|
+
setIsReturned(false);
|
|
53
|
+
});
|
|
54
|
+
(0, import_react.useEffect)(() => {
|
|
55
|
+
const handlePageShow = (event) => {
|
|
56
|
+
if (!orderId) return;
|
|
57
|
+
const historyState = window.history.state;
|
|
58
|
+
if ((historyState == null ? void 0 : historyState.paymentRedirected) && (historyState == null ? void 0 : historyState.paymentType) === paymentType && (historyState == null ? void 0 : historyState.orderId) === orderId) {
|
|
59
|
+
console.log(
|
|
60
|
+
`检测到从 ${paymentType} 返回, event.persisted:`,
|
|
61
|
+
event.persisted
|
|
62
|
+
);
|
|
63
|
+
setIsReturned(true);
|
|
64
|
+
if (onAfterReturn) {
|
|
65
|
+
onAfterReturn();
|
|
66
|
+
}
|
|
67
|
+
const newState = { ...historyState };
|
|
68
|
+
delete newState.paymentRedirected;
|
|
69
|
+
delete newState.paymentType;
|
|
70
|
+
delete newState.timestamp;
|
|
71
|
+
delete newState.orderId;
|
|
72
|
+
window.history.replaceState(newState, "", window.location.href);
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
handlePageShow({ persisted: false });
|
|
76
|
+
window.addEventListener("pageshow", handlePageShow);
|
|
77
|
+
return () => {
|
|
78
|
+
window.removeEventListener("pageshow", handlePageShow);
|
|
79
|
+
};
|
|
80
|
+
}, [orderId, paymentType]);
|
|
81
|
+
return {
|
|
82
|
+
isReturned,
|
|
83
|
+
handleRedirect,
|
|
84
|
+
resetState
|
|
85
|
+
};
|
|
86
|
+
};
|
|
87
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
88
|
+
0 && (module.exports = {
|
|
89
|
+
usePaymentRedirect
|
|
90
|
+
});
|
|
@@ -83,7 +83,8 @@ var ToCPay = (props, ref) => {
|
|
|
83
83
|
status: "init",
|
|
84
84
|
// 将支付回调储存在store, 方便其他模块调用
|
|
85
85
|
payCallback: props.callback,
|
|
86
|
-
history: (_a2 = context.appHelper.utils) == null ? void 0 : _a2.history
|
|
86
|
+
history: (_a2 = context.appHelper.utils) == null ? void 0 : _a2.history,
|
|
87
|
+
front_order_uuid: (0, import_utils.getUniqueId)("front_order_uuid_")
|
|
87
88
|
// 支付组
|
|
88
89
|
// payGroup: {
|
|
89
90
|
// order_id: initProps?.order?.order_id,
|