xiongzhu 2 ani în urmă
părinte
comite
c76341b40f
2 a modificat fișierele cu 0 adăugiri și 56 ștergeri
  1. 0 6
      src/weixin/weixin.controller.ts
  2. 0 50
      src/weixin/weixin.service.ts

+ 0 - 6
src/weixin/weixin.controller.ts

@@ -26,12 +26,6 @@ export class WeixinController {
         return await this.weixinService.code2oenId(code)
     }
 
-    @Public()
-    @Get('/pay')
-    public async pay(@Query() { openid }) {
-        return await this.weixinService.pay(openid)
-    }
-
     @Public()
     @Post('/jsapiSign')
     public async jsapiSign(@Body() { url }) {

+ 0 - 50
src/weixin/weixin.service.ts

@@ -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) {