Commit 1be0abe5 by zhengxiao

Merge branch 'feat_wechat_231115' into feat_pay_230904

parents b669e734 53323d51
...@@ -118,6 +118,10 @@ export enum PayErrorMessage { ...@@ -118,6 +118,10 @@ export enum PayErrorMessage {
WECHAT_JSSDK_PAY_ERROR = '支付失败', WECHAT_JSSDK_PAY_ERROR = '支付失败',
WECHAT_H5_PAY_BREAK = '微信h5支付中断', WECHAT_H5_PAY_BREAK = '微信h5支付中断',
ALIPAY_H5_PAY_BREAK = '支付宝支付中断', ALIPAY_H5_PAY_BREAK = '支付宝支付中断',
/**
* 微信支付appid和openid不匹配
*/
WECHAT_OPENID_APPID_NOT_MATCH = 'appid和openid不匹配',
} }
export type ToPayReturns = { export type ToPayReturns = {
......
...@@ -280,6 +280,9 @@ export class Payment { ...@@ -280,6 +280,9 @@ export class Payment {
doUnifiedParams.payChannel = payChannel doUnifiedParams.payChannel = payChannel
} }
const res = await requestForJava.post<DoUnifiedParams, DefaultResponse>(UNIT_PAY, doUnifiedParams) const res = await requestForJava.post<DoUnifiedParams, DefaultResponse>(UNIT_PAY, doUnifiedParams)
if (Utils.isWechat() && res.msg === PayErrorMessage.WECHAT_OPENID_APPID_NOT_MATCH) {
window.location.href = `https://m.ydl.com/pay/wx-pay-open-id?toLink=${window.location.href}`;
}
if (res.code !== '200') return {errorMessage: res.msg as any, success: false, errorType: PayError.BACKEND} if (res.code !== '200') return {errorMessage: res.msg as any, success: false, errorType: PayError.BACKEND}
if (params.payType === PayType.BALANCE && res.data) { if (params.payType === PayType.BALANCE && res.data) {
return {success: res.data.result, errorType: PayError.BALANCE} return {success: res.data.result, errorType: PayError.BALANCE}
......
...@@ -5,7 +5,7 @@ export class Utils { ...@@ -5,7 +5,7 @@ export class Utils {
return /MicroMessenger/i.test(window.navigator.userAgent) return /MicroMessenger/i.test(window.navigator.userAgent)
} }
static isAlipay(): boolean { static isAlipay(): boolean {
return /AlipayClient/i.test(window.navigator.userAgent) return /AlipayClient/i.test(window.navigator.userAgent) || /AliApp/i.test(window.navigator.userAgent)
} }
static getCookie(key: string): string | null { static getCookie(key: string): string | null {
return Cookies.get(key) || null return Cookies.get(key) || null
......
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