• 微信支付


    public WeChatPayResponseData placeOrder(final WeChatPayRequestData request) {
        OneLevelOnlyXML xml = new OneLevelOnlyXML();
        xml.createRootElement("xml");
        for (StringPair param : sign(request.getSortedParameters())) {
          xml.createChild(param.getFirst(), param.getSecond());
        }
        String str = xml.toXMLString();
        LOG.info("Order request: {}", str);
        String ret = http.post("api.mch.weixin.qq.com", 443, "https", "/pay/unifiedorder", str);
        LOG.info("Order response: {}", ret);
        try {
          WeChatPayResponseData response = WeChatPayResponseData.parse(ret);
          String sign = signMD5(response.getAllData().getSorted("sign"));
          if (!sign.equalsIgnoreCase(response.getString("sign"))) {
            LOG.warn("Failed to verify sign");
            return null;
          }
          if (!"SUCCESS".equalsIgnoreCase(response.getString("return_code"))
              || !"SUCCESS".equalsIgnoreCase(response.getString("result_code"))) {
            LOG.warn("Error returned {}", response.getString("return_msg"));
            return null;
          }
          // return response.getString("prepay_id");
          response.setXml(ret);
          return response;
        } catch (UnsupportedEncodingException e) {
          LOG.warn("Cannot parse result", e);
          return null;
        } catch (ParserConfigurationException e) {
          LOG.warn("Cannot parse result", e);
          return null;
        } catch (SAXException e) {
          LOG.warn("Cannot parse result", e);
          return null;
        } catch (IOException e) {
          LOG.warn("Cannot parse result", e);
          return null;
        }
      }
  • 相关阅读:
    不弹出提示直接关闭页面
    orcale表解锁
    序列化和反序列化
    js 实现post传参
    简易实现 instanceOf
    简易实现virtualdom
    react中setState同步、异步问题
    CMake Qt 配置 OpenCV
    VS执行时打开cmd
    VS2019+Qt5.15.2环境配置
  • 原文地址:https://www.cnblogs.com/wjlstation/p/5973932.html
Copyright © 2020-2023  润新知