Commit 8ea52f9b by 许振钊

Merge branch 'feat_pay__perf_220824' into 'master'

feat(custom): add pay params payId \& modify return

See merge request !2
parents d32de7b1 00aaf9a1
......@@ -98,6 +98,10 @@ export type ToPayParams = {
*/
openId?: string;
appId?: string;
/**
* 支付记录id, 采用余额支付的时候如果前端有此值就带过来
*/
payId?: number;
}
export enum PayError {
......
......@@ -146,7 +146,7 @@ export class Payment {
}
async toPay(params: ToPayParams): Promise<ToPayReturns> {
const {totalAmount, payType, returnUrl, orderId, redirectUrl, openId, appId,} = params
const {totalAmount, payType, returnUrl, orderId, redirectUrl, openId, appId, payId,} = params
let quitUrl = params.quitUrl
// validate start >>>
switch (payType) {
......@@ -221,6 +221,7 @@ export class Payment {
payType,
openId,
appId,
payId,
...this.computeAmount(totalAmount, this.balance),
}
if (payChannel !== null) {
......@@ -228,8 +229,8 @@ export class Payment {
}
const res = await requestForJava.post<DoUnifiedParams, DefaultResponse>(UNIT_PAY, doUnifiedParams)
if (res.code !== '200') return {errorMessage: res.msg as any, success: false, errorType: PayError.BACKEND}
if (params.payType === PayType.BALANCE && res.data.balancePayResult) {
return {success: res.data.balancePayResult === 'true', errorType: PayError.BALANCE}
if (params.payType === PayType.BALANCE && res.data) {
return {success: res.data.result, errorType: PayError.BALANCE}
} else if (payChannel === PayChannel.WX_JSAPI) {
const isPaySucc = await this.wechatPayJSSDK(res.data)
return {
......
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