Skip to content

Commit

Permalink
feat(Wechat): 添加 requestPayment 方法
Browse files Browse the repository at this point in the history
  • Loading branch information
fjc0k committed Sep 26, 2020
1 parent 6c7be51 commit 3827479
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions src/utils/Wechat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,33 @@ export interface WechatOpenLocationParams {
infoUrl?: string
}

export interface WechatRequestPaymentParams {
/**
* 支付签名时间戳。
*/
timestamp: number

/**
* 支付签名随机串。
*/
nonceStr: string

/**
* 统一支付接口返回的 prepay_id 参数值,如:`prepay_id=xxx`。
*/
package: string

/**
* 签名方式。
*/
signType: string

/**
* 支付签名。
*/
paySign: string
}

/**
* 微信内网页的非基础菜单列表。
*
Expand Down Expand Up @@ -537,6 +564,15 @@ export class Wechat {
return this.invoke('showAllNonBaseMenuItem')
}

/**
* 发起微信支付。
*
* @param params 参数
*/
requestPayment(params: WechatRequestPaymentParams): Promise<any> {
return this.invoke('chooseWXPay', params)
}

/**
* 错误处理。
*
Expand Down Expand Up @@ -565,6 +601,7 @@ export class Wechat {
...params,
success: resolve,
fail: reject,
cancel: reject,
})
}
if (typeof wx === 'undefined' || !this.ready) {
Expand Down

0 comments on commit 3827479

Please sign in to comment.