Commit 1daa76d5 by 郑炬波

feat: zf

parent c8c1fdcf
{
"name": "@ydl-packages/toolkit",
"version": "1.0.1-next.22",
"version": "1.0.1-next.24",
"description": "",
"main": "./dist/index.umd.js",
"scripts": {
......
......@@ -156,12 +156,6 @@ export class Payment {
success: false,
errorType: PayError.VALIDATE
}
} else if (decodeURIComponent(redirectUrl) === redirectUrl) {
return {
errorMessage: PayErrorMessage.WECHAT_REDIRECT_URL_ENCODE,
success: false,
errorType: PayError.VALIDATE
}
}
} else {
return {
......@@ -203,6 +197,9 @@ export class Payment {
// validate end <<<
// hack, 后端微信redirectUrl用的quitUrl
const payChannel = this.getPayChannel(payType)
if (payChannel === PayChannel.WX_MWEB || payChannel === PayChannel.WX_JSAPI) {
quitUrl = redirectUrl
}
const doUnifiedParams: DoUnifiedParams = {
returnUrl,
quitUrl,
......@@ -285,16 +282,18 @@ export class Payment {
})
}
static async loopValidateOrderState(count = 0, callBack: OrderStateCallBack): Promise<void> {
static async loopValidateOrderState(count = 0, callBack: OrderStateCallBack, polltime = 3000): Promise<void> {
const [, queryString] = window.location.href.split('?')
const query = queryString ? qs.parse(queryString, {ignoreQueryPrefix: true}) : {}
const returnParams: BackInfo = {payId: Number(query[BACK_PAY_ID]), orderId: Number(query[BACK_ORDER_ID])}
let timer: any = null;
const checkLoop = () => {
if (--count > 0) {
setTimeout(() => {
this.loopValidateOrderState(count, callBack)
}, 1000)
timer = setTimeout(() => {
this.loopValidateOrderState(count, callBack, polltime)
}, polltime)
} else {
clearInterval(timer);
callBack({isPay: false, ...returnParams})
}
}
......@@ -304,6 +303,7 @@ export class Payment {
payId: query[BACK_PAY_ID]
})
if (res.code === '200' && res.data === true) {
clearInterval(timer);
callBack({isPay: true, ...returnParams})
} else {
checkLoop()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment