|
|
@@ -97,56 +97,6 @@ export class WeixinService {
|
|
|
return res.openid
|
|
|
}
|
|
|
|
|
|
- async pay(openid: string) {
|
|
|
- let data = {
|
|
|
- appid: this.weixinConfiguration.appId,
|
|
|
- mchid: this.weixinConfiguration.mchId,
|
|
|
- description: 'IJPay 让支付触手可及',
|
|
|
- out_trade_no: Kits.generateStr(),
|
|
|
- notify_url: 'https://chillgpt.raexmeta.com/api/weixin/notify',
|
|
|
- amount: {
|
|
|
- total: 1,
|
|
|
- currency: 'CNY'
|
|
|
- },
|
|
|
- payer: {
|
|
|
- openid
|
|
|
- }
|
|
|
- }
|
|
|
- let result = await PayKit.exePost(
|
|
|
- WX_DOMAIN.CHINA, //
|
|
|
- WX_API_TYPE.JS_API_PAY,
|
|
|
- this.weixinConfiguration.mchId,
|
|
|
- this.weixinConfiguration.certSerial,
|
|
|
- this.privateKey,
|
|
|
- JSON.stringify(data)
|
|
|
- )
|
|
|
- const nonceStr = /nonce_str="(\S+?)"/.exec(result.config.headers['Authorization'])[1]
|
|
|
- console.log(nonceStr)
|
|
|
- Logger.log(JSON.stringify(result.data, null, 2), 'weixin')
|
|
|
- if (result.status === 200) {
|
|
|
- const timeStamp = parseInt((new Date().getTime() / 1000).toString()).toString()
|
|
|
- // const nonceStr = Kits.generateStr()
|
|
|
- const packageStr = `prepay_id=${result.data.prepay_id}`
|
|
|
- const signType = 'RSA'
|
|
|
- const signStr =
|
|
|
- [this.weixinConfiguration.appId, timeStamp, nonceStr, packageStr].join(String.fromCharCode(10)) +
|
|
|
- String.fromCharCode(10)
|
|
|
- const paySign = Kits.sha256WithRsa(signStr, this.privateKey)
|
|
|
- console.log(signStr)
|
|
|
- console.log(paySign)
|
|
|
- return {
|
|
|
- appId: this.weixinConfiguration.appId,
|
|
|
- timestamp: timeStamp,
|
|
|
- nonceStr,
|
|
|
- package: packageStr,
|
|
|
- signType,
|
|
|
- paySign
|
|
|
- }
|
|
|
- } else {
|
|
|
- throw new InternalServerErrorException(result.data.message)
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
async jsapiPay(description: string, amount: number, openid: string, attach: Attach) {
|
|
|
let realAmount = new BigNumber(amount)
|
|
|
if (realAmount.comparedTo(new BigNumber(100)) >= 0) {
|