WeChat公式アカウント支払いメモ

 

1. WeChatログインをプルアップして、コードコードhttps://open.weixin.qq.com/connect/oauth2/authorize?appid=xxxxxx&redirect_uri=callback address of the client page&response_type = code&scope = snsapi_base&state = STATE#wechat_redirect

注1.クライアントページのコールバックURLは、encodeURIを使用する必要があります(http:// xxxxxxxx)

        2. vueのハッシュモードの場合、ステップ1を実行します。URLに2つの#が表示されるため、ログインのプルアップに失敗します 

2. WeChatのopenidと引き換えにコード値を取得する

3.ビジネス決済プロセスを開始する

payOrder(){ 
      let payDto = {
         'amount':this .amount、
         'payInfo':this .notice、
         'name':this .name、
         'idCardNum':this .idCardNum、
         'mobile':this .mobile 
      } 
      wxpayH5Create( payDto).then(result => {
         var resu = result.data.result
         this .onBridgeReady(resu)
      })
    }、
onBridgeReady(resu){ 
      WeixinJSBridge.invoke(
         'getBrandWCPayRequest' 、{
         'appId' :resu.appid、
         'timeStamp' :resu.timeStamp、
         'nonceStr' :resu.nonceStr、
         'package' :resu.package、
         'signType' : resu.signType、
         'paySign' :resu.paySign 
      }、
       (res)=> { if(res.err_msg.indexOf( 'ok')!== -1 ){ 
            this。$ router.push({ 
              path: 'reportIndex ' 
              クエリ:{  
                名前:this.name、
                idCardNum:this.idCardNum、
                モバイル:this.mobile 
              } 
            })
          } 
        })
    }

注:WeixinJSBridgeはWeChatブラウザー内で提供されます。他のブラウザーはこの関数を使用して支払いを呼び出すことはできません。

 

おすすめ

転載: www.cnblogs.com/caoruichun/p/12695382.html