Tabnine Logo
WechatPayCoreConfig
Code IndexAdd Tabnine to your IDE (free)

How to use
WechatPayCoreConfig
in
cn.minsin.core.init

Best Java code snippets using cn.minsin.core.init.WechatPayCoreConfig (Showing top 5 results out of 315)

origin: cn.minsin/mutils-wechat-wechatpay-core

/**
 * 生成签名
 * 
 * @param sortMap
 * @return
 */
protected static String createSign(SortedMap<String, String> sortMap) {
  return SignUtil.createSign(sortMap, payconfig.getPartnerKey());
}
origin: cn.minsin/mutils-wechat-wechatpay-core

/**
 * 发起微信转账(提现)
 * 
 * @param model 发起提现的包装类
 * @return
 * @throws MutilsErrorException
 */
public static Map<String, String> createWithdrawXml(WithdrawModel model) throws MutilsErrorException {
  String xml = model.toXml(payconfig.getPartnerKey());
  log.info("withdraw xml is {}", xml);
  CloseableHttpClient httpclient = null;
  CloseableHttpResponse response = null;
  try {
    httpclient = HttpClientUtil.getSSLInstance(payconfig.getPartnerId(), payconfig.getCertificatePath(),
        payconfig.getCertificateFormat());
    HttpPost httpost = HttpClientUtil.getPostMethod(payconfig.getWithdrawUrl());
    httpost.setEntity(new StringEntity(xml, "UTF-8"));
    response = httpclient.execute(httpost);
    String jsonStr = EntityUtils.toString(response.getEntity(), "UTF-8");
    log.info("withdraw json is {}", jsonStr);
    return ParseXmlUtil.doXMLParse(jsonStr);
  } catch (Exception e) {
    throw new MutilsErrorException(e, "发起转账失败");
  } finally {
    IOUtil.close(httpclient, response);
  }
}
origin: cn.minsin/mutils-wechat-wechatpay-core

/**
 * 发起退款申请
 * 
 * @param model
 * @return
 * @throws MutilsErrorException
 */
protected static RefundReturnModel createRefundRequest(RefundModel model) throws MutilsErrorException {
  String xmlParam = model.toXml(payconfig.getPartnerKey());
  log.info("refund xml is {}", xmlParam);
  CloseableHttpClient httpclient = null;
  CloseableHttpResponse response = null;
  try {
    httpclient = HttpClientUtil.getSSLInstance(payconfig.getPartnerId(), payconfig.getCertificatePath(),
        payconfig.getCertificateFormat());
    HttpPost httpost = HttpClientUtil.getPostMethod(payconfig.getRefundUrl());
    httpost.setEntity(new StringEntity(xmlParam, "UTF-8"));
    response = httpclient.execute(httpost);
    String jsonStr = EntityUtils.toString(response.getEntity(), "UTF-8");
    log.info("refund json is {}", jsonStr);
    return MapUtil.mapToObject(ParseXmlUtil.doXMLParse(jsonStr), RefundReturnModel.class);
  } catch (Exception e) {
    throw new MutilsErrorException(e, "发起退款失败");
  } finally {
    IOUtil.close(httpclient, response);
  }
}
origin: cn.minsin/mutils-wechat-app

/**
 * 创建APP支付的请求参数 APP将用其发起微信支付
 * 
 * @param model 下单时的包装对象
 * @return APP能发起的请求的包装内容
 * @throws Exception 
 */
public static Map<String, String> createAppPayParamter(AppOrderPayModel model) throws Exception{
    Map<String, String> doXMLParse = createUnifiedOrder(model);
    checkMap(doXMLParse);
    SortedMap<String, String> sortMap = new TreeMap<>();
    String appId = doXMLParse.get("appid");
    String nonceStr = doXMLParse.get("nonce_str");
    String prepayid = doXMLParse.get("prepay_id");
    String timeStamp = String.valueOf(System.currentTimeMillis() / 1000);
    sortMap.put("appid", appId);
    sortMap.put("partnerid", payconfig.getPartnerId());
    sortMap.put("noncestr", nonceStr);
    sortMap.put("package", "Sign=WXPay");
    sortMap.put("timestamp", timeStamp);
    sortMap.put("prepayid", prepayid);
    sortMap.put("sign", createSign(sortMap));
    return sortMap;
}
 
origin: cn.minsin/mutils-wechat-wechatpay-core

/**
 * 统一下单接口 用于生成 预支付id 及二维码id
 * 
 * @param model 预下单的对象
 * @return
 * @throws ParseException 
 * @throws MutilsErrorException
 * @throws IOException
 * @throws JDOMException 
 */
protected static Map<String, String> createUnifiedOrder(BaseWeChatPayModel model) throws ParseException, IOException, MutilsErrorException, JDOMException {
  CloseableHttpClient httpclient = HttpClientUtil.getInstance();// 先初始化;
  CloseableHttpResponse response = null;
  try {
    HttpPost httpost = HttpClientUtil.getPostMethod(payconfig.getUnifiedOrderUrl());
    String xmlParam = model.toXml(payconfig.getPartnerKey());
    log.info("createUnifiedOrder xml is {}", xmlParam);
    httpost.setEntity(new StringEntity(xmlParam, "UTF-8"));
    response = httpclient.execute(httpost);
    String jsonStr = EntityUtils.toString(response.getEntity(), "UTF-8");
    log.info("createUnifiedOrder json is {}", jsonStr);
    if (jsonStr.indexOf("FAIL") != -1) {
      throw new MutilsErrorException(jsonStr);
    }
    return ParseXmlUtil.doXMLParse(jsonStr);
  } finally {
    IOUtil.close(httpclient, response);
  }
}
cn.minsin.core.initWechatPayCoreConfig

Most used methods

  • getPartnerId
  • getCertificateFormat
  • getCertificatePath
  • getPartnerKey
  • getRefundUrl
  • getUnifiedOrderUrl
  • getWithdrawUrl

Popular in Java

  • Making http post requests using okhttp
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • getResourceAsStream (ClassLoader)
  • addToBackStack (FragmentTransaction)
  • MalformedURLException (java.net)
    This exception is thrown when a program attempts to create an URL from an incorrect specification.
  • Arrays (java.util)
    This class contains various methods for manipulating arrays (such as sorting and searching). This cl
  • JButton (javax.swing)
  • DateTimeFormat (org.joda.time.format)
    Factory that creates instances of DateTimeFormatter from patterns and styles. Datetime formatting i
  • Runner (org.openjdk.jmh.runner)
  • SAXParseException (org.xml.sax)
    Encapsulate an XML parse error or warning.> This module, both source code and documentation, is in t
  • Top plugins for Android Studio
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now