<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                企業??AI智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                # 注意:本文檔后期不在跟新,新文檔遷移到:[http://www.openkit.cc/docs/openkit/#/](http://www.openkit.cc/docs/openkit/#/) # 首先感謝使用OpenKit工具包 ## 反饋交流QQ群:696279396 # 注意這里暫時只支持APP端支付,網頁端支付將在2.0版本增加 - 首先我們需要 new 一個 WeichartModel 對象 ```java /** * appId:(必填)微信開發平臺應用ID * appSecret:(必填)應用對應的憑證 * appKey:(必填)應用對應的密鑰 * mchId:(必填)微信支付商戶號 * body:(必填)商品描述 * partnerKey:(必填)商戶號對應的密鑰 * partnerId:(必填)商戶id * grantType:(必填)常量固定值 * gateUrl:(必填)獲取預支付id的接口url * notifyUrl:(必填)微信服務器回調通知url * spbillCreateIp:(必填)請求的 IP 地址,其實就是服務器的IP地址 */ WeichartModel weichartModel = new WeichartModel() ``` - 接下去,實例化微信支付接口 ``` WeixinPayService weixinPayService = new WeixinPayServiceImpl(); ``` - 接著,你只要直接調用下面的方法就可以了 ``` /** * 統一訂單生成接口 * @param request * @param response * @param weichartModel 微信配置 * @param totalFee 價格 * @param out_trade_no 訂單號 * @param notify_url 回調地址 * @return code 根據這個判斷微信支付訂單是否生成成功,1:失敗,0:成功 * @throws Exception */ weixinPayService.getOrder(HttpServletRequest request, HttpServletResponse response, WeichartModel weichartModel,String totalFee, String out_trade_no, String notify_url); ``` - 返回值中 code 判斷是訂單號生成成功還是失敗 1:失敗,0:成功 - 回調函數編寫示例 ```java /** * 接收微信支付成功通知 * @param request * @param response * @throws IOException */ @Override public Map<String, String> getnotify(HttpServletRequest request, HttpServletResponse response) throws IOException { PrintWriter writer = response.getWriter(); InputStream inStream = request.getInputStream(); ByteArrayOutputStream outSteam = new ByteArrayOutputStream(); byte[] buffer = new byte[1024]; int len = 0; while ((len = inStream.read(buffer)) != -1) { outSteam.write(buffer, 0, len); } outSteam.close(); inStream.close(); String result = new String(outSteam.toByteArray(), "utf-8"); System.out.println("微信支付通知結果:" + result); Map<String, String> map = null; try { /** * 解析微信通知返回的信息 */ map = XMLUtil.doXMLParse(result); } catch (JDOMException e) { // TODO Auto-generated catch block e.printStackTrace(); } System.out.println("=========:" + result); return map; // 若支付成功,則告知微信服務器收到通知 if (map.get("return_code").equals("SUCCESS")) { if (map.get("result_code").equals("SUCCESS")) { System.out.println("充值成功!"); // 查找 PayRecord payRecord=payRecordService.get(Long.valueOf(map.get("out_trade_no"))); System.out.println("訂單號:"+Long.valueOf(map.get("out_trade_no"))); System.out.println("payRecord.getPayTime():"+payRecord.getPayTime()==null+","+payRecord.getPayTime()); //判斷通知是否已處理,若已處理,則不予處理 if(payRecord.getPayTime()==null){ System.out.println("通知微信后臺"); payRecord.setPayTime(new Date()); String phone=payRecord.getPhone(); AppCustomer appCustomer=appCustomerService.getByPhone(phone); float balance=appCustomer.getBalance(); balance+=Float.valueOf(map.get("total_fee"))/100; appCustomer.setBalance(balance); appCustomerService.update(appCustomer); payRecordService.update(payRecord); String notifyStr = XMLUtil.setXML("SUCCESS", ""); writer.write(notifyStr); writer.flush(); } } } ``` ## 回調說明 * 此方法用于微信支付回調統一調用工具了,將 Xml 文件替換成 Map 文件返回 * 參數說明: |字段名 | 變量名 | 是否必填 | 類型 | 示例 | 描述| |:--:|:--:|:--:|:--:|:--:|:--:| |返回狀態碼 | return_code | 是 | String(16) | SUCCESS | SUCCESS/LFAI此字段是通信標識,非交易標識,交易是否成功需要查看result_code來判斷| |返回信息 | return_msg | 否 | String(128) | 簽名失敗 | 返回信息,如非空,為錯誤原因,簽名失敗,參數格式校驗錯誤| ||||||| |應用ID | appid | 是 | String(32) |wx8888888888888888 |微信開放平臺審核通過的應用APPID| |商戶號 | mch_id | 是 | String(32) |1900000109 | 微信支付分配的商戶號| |設備號 | device_info | 否 | String(32) |013467007045764 | 微信支付分配的終端設備號, |隨機字符串 | nonce_str | 是 | String(32) |5K8264ILTKCH16CQ2502SI8ZNMTM67VS| 隨機字符串,不長于32位| |簽名 | sign | 是 | String(32)| C380BEC2BFD727A4B6845133519F3AD6 |簽名| |錯誤代碼 | err_code | 否 |String(32) |SYSTEMERROR | 錯誤返回的信息描述| |錯誤代碼描述 |err_code_des | 否 |String(128) |系統錯誤| 錯誤返回的信息描述| |用戶標識 | openid | 是 | String(128)| wxd930ea5d5a258f4f |用戶在商戶appid下的唯一標識| |是否關注公眾賬號 |is_subscribe| 否| String(1) |Y |用戶是否關注公眾賬號,Y-關注,N-未關注,僅在公眾賬號類型支付有效| |交易類型| trade_type |是 |String(16) |APP| APP| |付款銀行 |bank_type| 是 |String(16) |CMC| 銀行類型,采用字符串類型的銀行標識,銀行類型見| |總金額 |total_fee |是 |Int |100 |訂單總金額,單位為分| |貨幣種類| fee_type |否 |String(8) |CNY| 貨幣類型,符合ISO4217標準的三位字母代碼,默認人民幣:CNY,其他值列表詳見| |現金支付金額| cash_fee |是| Int |100 |現金支付金額訂單現金支付金額| |現金支付貨幣類型 |cash_fee_type |否 |String(16) |CNY| 貨幣類型,符合ISO4217標準的三位字母代碼,默認人民幣:CNY| |代金券金額 |coupon_fee| 否| Int |10| 代金券或立減優惠金額<=訂單總金額,訂單總金額-代金券或立減優惠金額=現金支付金額| |代金券使用數量| coupon_count| 否| Int |1 |代金券或立減優惠使用數量| |代金券ID| coupon_id_$n |否| String(20)| 10000 |代金券或立減優惠ID,$n為下標,從0開始編號| |單個代金券支付金額 |coupon_fee_$n |否| Int| 100 |單個代金券或立減優惠支付金額,$n為下標,從0開始編號| |微信支付訂單號| transaction_id |是 |String(32) |1217752501201407033233368018 |微信支付訂單號| | 商戶訂單號| out_trade_no| 是| String(32) |1212321211201407033568112322| 商戶系統內部訂單號,要求32個字符內,只能是數字、大小寫字母_-|*@ ,且在同一個商戶號下唯一。| | 商家數據包 |attach| 否 |String(128) |123456 |商家數據包,原樣返回| |支付完成時間 |time_end| 是 |String(14) |20141030133525 |支付完成時間,格式為yyyyMMddHHmmss,如2009年12月25日9點10分10秒表示為20091225091010| ## 反饋交流QQ群:696279396 ## 贊助 ![](https://box.kancloud.cn/bf6f9c0e4f5a786c20d02c56b56a0eaf_600x500.png)
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看