com.github.binarywang.wxpay.config.WxPayConfig Java Examples

The following examples show how to use com.github.binarywang.wxpay.config.WxPayConfig. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WxPayConfiguration.java    From mall4j with GNU Affero General Public License v3.0 6 votes vote down vote up
private WxPayService getWxMpPayServiceByAppId(String appid) {
        WxPayConfig payConfig = new WxPayConfig();
        payConfig.setAppId(appid);
        payConfig.setMchId(wxPay.getMchId());
        payConfig.setMchKey(wxPay.getMchKey());
        payConfig.setKeyPath(wxPay.getKeyPath());
        payConfig.setSignType(WxPayConstants.SignType.MD5);

        WxPayService wxPayService = new WxPayServiceImpl();

//      打开下面的代码,开启沙箱模式
//        if (Objects.equals(profile, "dev")) {
//            String sandboxSignKey = null;
//            try {
//                wxPayService.setConfig(payConfig);
//                sandboxSignKey = wxPayService.getSandboxSignKey();
//            } catch (WxPayException e) {
//                e.printStackTrace();
//            }
//            payConfig.setUseSandboxEnv(true);
//            payConfig.setMchKey(sandboxSignKey);
//        }

        wxPayService.setConfig(payConfig);
        return wxPayService;
    }
 
Example #2
Source File: WxMaConfiguration.java    From charging_pile_cloud with MIT License 6 votes vote down vote up
@Bean
@ConditionalOnMissingBean
public WxPayService wxService() {
    WxPayConfig payConfig = new WxPayConfig();
    payConfig.setAppId(StringUtils.trimToNull(wxPayProperties.getAppId()));
    payConfig.setMchId(StringUtils.trimToNull(wxPayProperties.getMchId()));
    payConfig.setMchKey(StringUtils.trimToNull(wxPayProperties.getMchKey()));
    payConfig.setSignType("MD5");
    payConfig.setNotifyUrl(StringUtils.trimToNull(wxPayProperties.getNotifyUrl()));
   // payConfig.setKeyPath(StringUtils.trimToNull(wxPayProperties.getKeyPath()));

    // 可以指定是否使用沙箱环境
    payConfig.setUseSandboxEnv(false);

    WxPayService wxPayService = new WxPayServiceImpl();
    wxPayService.setConfig(payConfig);
    return wxPayService;
}
 
Example #3
Source File: PayChannel4WxServiceImpl.java    From xxpay-master with MIT License 6 votes vote down vote up
/**
 * 构建微信企业付款请求数据
 * @param transOrder
 * @param wxPayConfig
 * @return
 */
WxEntPayRequest buildWxEntPayRequest(TransOrder transOrder, WxPayConfig wxPayConfig) {
    // 微信企业付款请求对象
    WxEntPayRequest request = new WxEntPayRequest();
    request.setAmount(transOrder.getAmount().intValue()); // 金额,单位分
    String checkName = "NO_CHECK";
    if(transOrder.getExtra() != null) checkName = JSON.parseObject(transOrder.getExtra()).getString("checkName");
    request.setCheckName(checkName);
    request.setDescription(transOrder.getRemarkInfo());
    request.setReUserName(transOrder.getUserName());
    request.setPartnerTradeNo(transOrder.getTransOrderId());
    request.setDeviceInfo(transOrder.getDevice());
    request.setSpbillCreateIp(transOrder.getClientIp());
    request.setOpenid(transOrder.getChannelUser());
    return request;
}
 
Example #4
Source File: WxPayUtil.java    From fw-cloud-framework with MIT License 6 votes vote down vote up
/**
 * 获取微信支付配置
 */
public static WxPayConfig getWxPayConfig(String configParam, String tradeType,
		String certRootPath, String notifyUrl) {
	WxPayConfig wxPayConfig = new WxPayConfig();
	JSONObject paramObj = JSON.parseObject(configParam);
	wxPayConfig.setMchId(paramObj.getString("mchId"));
	if (null != tradeType && tradeType.equals(PayConstant.WxConstant.TRADE_TYPE_APP)) {
		wxPayConfig.setAppId(paramObj.getString("openAppId"));
	} else {
		wxPayConfig.setAppId(paramObj.getString("appId"));
	}
	wxPayConfig.setMchKey(paramObj.getString("key"));
	if (!PublicHelper.isEmpty(certRootPath)) wxPayConfig.setKeyPath(certRootPath + File.separator + paramObj.getString("certLocalPath"));
	if (!PublicHelper.isEmpty(notifyUrl)) wxPayConfig.setNotifyUrl(notifyUrl);
	if (!PublicHelper.isEmpty(tradeType)) wxPayConfig.setTradeType(tradeType);
	return wxPayConfig;
}
 
Example #5
Source File: ApiTestModule.java    From weixin-java-tools with Apache License 2.0 6 votes vote down vote up
@Override
public void configure(Binder binder) {
  try (InputStream inputStream = ClassLoader.getSystemResourceAsStream(TEST_CONFIG_XML)) {
    if (inputStream == null) {
      throw new RuntimeException("测试配置文件【" + TEST_CONFIG_XML + "】未找到,请参照test-config-sample.xml文件生成");
    }

    XmlWxPayConfig config = this.fromXml(XmlWxPayConfig.class, inputStream);
    WxPayService wxService = new WxPayServiceImpl();
    wxService.setConfig(config);

    binder.bind(WxPayService.class).toInstance(wxService);
    binder.bind(WxPayConfig.class).toInstance(config);
  } catch (IOException e) {
    this.log.error(e.getMessage(), e);
  }

}
 
Example #6
Source File: WxConfig.java    From litemall with MIT License 5 votes vote down vote up
@Bean
public WxPayConfig wxPayConfig() {
    WxPayConfig payConfig = new WxPayConfig();
    payConfig.setAppId(properties.getAppId());
    payConfig.setMchId(properties.getMchId());
    payConfig.setMchKey(properties.getMchKey());
    payConfig.setNotifyUrl(properties.getNotifyUrl());
    payConfig.setKeyPath(properties.getKeyPath());
    payConfig.setTradeType("JSAPI");
    payConfig.setSignType("MD5");
    return payConfig;
}
 
Example #7
Source File: PayChannel4WxServiceImpl.java    From xxpay-master with MIT License 5 votes vote down vote up
/**
 * 构建微信退款请求数据
 * @param refundOrder
 * @param wxPayConfig
 * @return
 */
WxPayRefundRequest buildWxPayRefundRequest(RefundOrder refundOrder, WxPayConfig wxPayConfig) {
    // 微信退款请求对象
    WxPayRefundRequest request = new WxPayRefundRequest();
    request.setTransactionId(refundOrder.getChannelPayOrderNo());
    request.setOutTradeNo(refundOrder.getPayOrderId());
    request.setDeviceInfo(refundOrder.getDevice());
    request.setOutRefundNo(refundOrder.getRefundOrderId());
    request.setRefundDesc(refundOrder.getRemarkInfo());
    request.setRefundFee(refundOrder.getRefundAmount().intValue());
    request.setRefundFeeType("CNY");
    request.setTotalFee(refundOrder.getPayAmount().intValue());
    return request;
}
 
Example #8
Source File: WxPayUtil.java    From xxpay-master with MIT License 5 votes vote down vote up
/**
 * 获取微信支付配置
 * @param configParam
 * @return
 */
public static WxPayConfig getWxPayConfig(String configParam) {
    WxPayConfig wxPayConfig = new WxPayConfig();
    JSONObject paramObj = JSON.parseObject(configParam);
    wxPayConfig.setMchId(paramObj.getString("mchId"));
    wxPayConfig.setAppId(paramObj.getString("appId"));
    wxPayConfig.setMchKey(paramObj.getString("key"));
    return wxPayConfig;
}
 
Example #9
Source File: WxPayUtil.java    From xxpay-master with MIT License 5 votes vote down vote up
/**
 * 获取微信支付配置
 * @param configParam
 * @param tradeType
 * @param certRootPath
 * @param notifyUrl
 * @return
 */
public static WxPayConfig getWxPayConfig(String configParam, String tradeType, String certRootPath, String notifyUrl) {
    WxPayConfig wxPayConfig = new WxPayConfig();
    JSONObject paramObj = JSON.parseObject(configParam);
    wxPayConfig.setMchId(paramObj.getString("mchId"));
    wxPayConfig.setAppId(paramObj.getString("appId"));
    wxPayConfig.setKeyPath(certRootPath + File.separator + paramObj.getString("certLocalPath"));
    wxPayConfig.setMchKey(paramObj.getString("key"));
    wxPayConfig.setNotifyUrl(notifyUrl);
    wxPayConfig.setTradeType(tradeType);
    return wxPayConfig;
}
 
Example #10
Source File: WxPayUtil.java    From xxpay-master with MIT License 5 votes vote down vote up
/**
 * 获取微信支付配置
 * @param configParam
 * @return
 */
public static WxPayConfig getWxPayConfig(String configParam) {
    WxPayConfig wxPayConfig = new WxPayConfig();
    JSONObject paramObj = JSON.parseObject(configParam);
    wxPayConfig.setMchId(paramObj.getString("mchId"));
    wxPayConfig.setAppId(paramObj.getString("appId"));
    wxPayConfig.setMchKey(paramObj.getString("key"));
    return wxPayConfig;
}
 
Example #11
Source File: WxPayUtil.java    From xxpay-master with MIT License 5 votes vote down vote up
/**
 * 获取微信支付配置
 * @param configParam
 * @param tradeType
 * @param certRootPath
 * @param notifyUrl
 * @return
 */
public static WxPayConfig getWxPayConfig(String configParam, String tradeType, String certRootPath, String notifyUrl) {
    WxPayConfig wxPayConfig = new WxPayConfig();
    JSONObject paramObj = JSON.parseObject(configParam);
    wxPayConfig.setMchId(paramObj.getString("mchId"));
    wxPayConfig.setAppId(paramObj.getString("appId"));
    wxPayConfig.setKeyPath(certRootPath + File.separator + paramObj.getString("certLocalPath"));
    wxPayConfig.setMchKey(paramObj.getString("key"));
    wxPayConfig.setNotifyUrl(notifyUrl);
    wxPayConfig.setTradeType(tradeType);
    return wxPayConfig;
}
 
Example #12
Source File: WxPayUtil.java    From xxpay-master with MIT License 5 votes vote down vote up
/**
 * 获取微信支付配置
 * @param configParam
 * @return
 */
public static WxPayConfig getWxPayConfig(String configParam) {
    WxPayConfig wxPayConfig = new WxPayConfig();
    JSONObject paramObj = JSON.parseObject(configParam);
    wxPayConfig.setMchId(paramObj.getString("mchId"));
    wxPayConfig.setAppId(paramObj.getString("appId"));
    wxPayConfig.setMchKey(paramObj.getString("key"));
    return wxPayConfig;
}
 
Example #13
Source File: WxPayUtil.java    From xxpay-master with MIT License 5 votes vote down vote up
/**
 * 获取微信支付配置
 * @param configParam
 * @param tradeType
 * @param certRootPath
 * @param notifyUrl
 * @return
 */
public static WxPayConfig getWxPayConfig(String configParam, String tradeType, String certRootPath, String notifyUrl) {
    WxPayConfig wxPayConfig = new WxPayConfig();
    JSONObject paramObj = JSON.parseObject(configParam);
    wxPayConfig.setMchId(paramObj.getString("mchId"));
    wxPayConfig.setAppId(paramObj.getString("appId"));
    wxPayConfig.setKeyPath(certRootPath + File.separator + paramObj.getString("certLocalPath"));
    wxPayConfig.setMchKey(paramObj.getString("key"));
    wxPayConfig.setNotifyUrl(notifyUrl);
    wxPayConfig.setTradeType(tradeType);
    return wxPayConfig;
}
 
Example #14
Source File: WxPayConfiguration.java    From springboot-seed with MIT License 5 votes vote down vote up
@Bean
@ConditionalOnMissingBean
public WxPayService wxService() {
    WxPayConfig payConfig = new WxPayConfig();
    payConfig.setAppId(StringUtils.trimToNull(this.properties.getAppId()));
    payConfig.setMchId(StringUtils.trimToNull(this.properties.getMchId()));
    payConfig.setMchKey(StringUtils.trimToNull(this.properties.getMchKey()));
    payConfig.setSubAppId(StringUtils.trimToNull(this.properties.getSubAppId()));
    payConfig.setSubMchId(StringUtils.trimToNull(this.properties.getSubMchId()));
    payConfig.setKeyPath(StringUtils.trimToNull(this.properties.getKeyPath()));

    WxPayService wxPayService = new WxPayServiceImpl();
    wxPayService.setConfig(payConfig);
    return wxPayService;
}
 
Example #15
Source File: WxConfig.java    From BigDataPlatform with GNU General Public License v3.0 5 votes vote down vote up
@Bean
public WxPayConfig wxPayConfig() {
    WxPayConfig payConfig = new WxPayConfig();
    payConfig.setAppId(properties.getAppId());
    payConfig.setMchId(properties.getMchId());
    payConfig.setMchKey(properties.getMchKey());
    payConfig.setNotifyUrl(properties.getNotifyUrl());
    payConfig.setKeyPath(properties.getKeyPath());
    payConfig.setTradeType("JSAPI");
    payConfig.setSignType("MD5");
    return payConfig;
}
 
Example #16
Source File: WxPayRefundRequest.java    From weixin-java-tools with Apache License 2.0 5 votes vote down vote up
@Override
public void checkAndSign(WxPayConfig config) throws WxPayException {
  if (StringUtils.isBlank(this.getOpUserId())) {
    this.setOpUserId(config.getMchId());
  }

  super.checkAndSign(config);
}
 
Example #17
Source File: WxPayUnifiedOrderRequest.java    From weixin-java-tools with Apache License 2.0 5 votes vote down vote up
@Override
public void checkAndSign(WxPayConfig config) throws WxPayException {
  if (StringUtils.isBlank(this.getNotifyUrl())) {
    this.setNotifyUrl(config.getNotifyUrl());
  }

  if (StringUtils.isBlank(this.getTradeType())) {
    this.setTradeType(config.getTradeType());
  }

  super.checkAndSign(config);
}
 
Example #18
Source File: WxConfig.java    From mall with MIT License 5 votes vote down vote up
@Bean
public WxPayConfig wxPayConfig() {
    WxPayConfig payConfig = new WxPayConfig();
    payConfig.setAppId(properties.getAppId());
    payConfig.setMchId(properties.getMchId());
    payConfig.setMchKey(properties.getMchKey());
    payConfig.setNotifyUrl(properties.getNotifyUrl());
    payConfig.setKeyPath(properties.getKeyPath());
    payConfig.setTradeType("JSAPI");
    payConfig.setSignType("MD5");
    return payConfig;
}
 
Example #19
Source File: WxConfig.java    From unimall with Apache License 2.0 5 votes vote down vote up
@Bean
public WxPayConfig wxPayConfig() {
    WxPayConfig payConfig = new WxPayConfig();
    payConfig.setMchId(properties.getMchId());
    payConfig.setMchKey(properties.getMchKey());
    payConfig.setNotifyUrl(properties.getNotifyUrl());
    payConfig.setKeyPath(properties.getKeyPath());
    payConfig.setSignType("MD5");
    return payConfig;
}
 
Example #20
Source File: WxConfig.java    From dts-shop with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Bean
public WxPayConfig wxPayConfig() {
	WxPayConfig payConfig = new WxPayConfig();
	payConfig.setAppId(properties.getAppId());
	payConfig.setMchId(properties.getMchId());
	payConfig.setMchKey(properties.getMchKey());
	payConfig.setNotifyUrl(properties.getNotifyUrl());
	payConfig.setKeyPath(properties.getKeyPath());
	payConfig.setTradeType("JSAPI");
	payConfig.setSignType("MD5");
	return payConfig;
}
 
Example #21
Source File: WxUnifiedOrderServiceImpl.java    From fw-cloud-framework with MIT License 4 votes vote down vote up
/**
 * 构建微信统一下单请求数据
 */
private WxPayUnifiedOrderRequest buildUnifiedOrderRequest(PayOrder payOrder,
		WxPayConfig wxPayConfig) {
	String tradeType = wxPayConfig.getTradeType();
	String payOrderId = payOrder.getPayOrderId();
	Integer totalFee = payOrder.getAmount().intValue();// 支付金额,单位分
	String deviceInfo = payOrder.getDevice();
	String body = payOrder.getBody();
	String detail = null;
	String attach = null;
	String outTradeNo = payOrderId;
	String feeType = "CNY";
	String spBillCreateIP = payOrder.getIp();
	String timeStart = null;
	String timeExpire = null;
	String goodsTag = null;
	String notifyUrl = wxPayConfig.getNotifyUrl();
	String productId = null;
	if (tradeType.equals(PayConstant.WxConstant.TRADE_TYPE_NATIVE))
		productId = JSON.parseObject(payOrder.getExtra()).getString("productId");
	String limitPay = null;
	String openId = null;
	if (tradeType.equals(PayConstant.WxConstant.TRADE_TYPE_JSPAI))
		openId = JSON.parseObject(payOrder.getExtra()).getString("openId");
	String sceneInfo = null;
	if (tradeType.equals(PayConstant.WxConstant.TRADE_TYPE_MWEB)) {
		JSONObject extraObject = JSON.parseObject(WebUtils.buildURLDecoder(payOrder.getExtra()));
		sceneInfo = extraObject.getJSONObject("sceneInfo").toJSONString();
	}
	// 微信统一下单请求对象
	WxPayUnifiedOrderRequest request = new WxPayUnifiedOrderRequest();
	request.setDeviceInfo(deviceInfo);
	request.setBody(body);
	request.setDetail(detail);
	request.setAttach(attach);
	request.setOutTradeNo(outTradeNo);
	request.setFeeType(feeType);
	request.setTotalFee(totalFee);
	request.setSpbillCreateIp(spBillCreateIP);
	request.setTimeStart(timeStart);
	request.setTimeExpire(timeExpire);
	request.setGoodsTag(goodsTag);
	request.setNotifyUrl(notifyUrl);
	request.setTradeType(tradeType);
	request.setProductId(productId);
	request.setLimitPay(limitPay);
	request.setOpenid(openId);
	request.setSceneInfo(sceneInfo);

	return request;
}
 
Example #22
Source File: BaseWxPayRequest.java    From weixin-java-tools with Apache License 2.0 4 votes vote down vote up
/**
 * <pre>
 * 检查参数,并设置签名
 * 1、检查参数(注意:子类实现需要检查参数的而外功能时,请在调用父类的方法前进行相应判断)
 * 2、补充系统参数,如果未传入则从配置里读取
 * 3、生成签名,并设置进去
 * </pre>
 *
 * @param config 支付配置对象,用于读取相应系统配置信息
 */
public void checkAndSign(WxPayConfig config) throws WxPayException {
  this.checkFields();

  if (!ignoreAppid()) {
    if (StringUtils.isBlank(getAppid())) {
      this.setAppid(config.getAppId());
    }
  }

  if (StringUtils.isBlank(getMchId())) {
    this.setMchId(config.getMchId());
  }

  if (StringUtils.isBlank(getSubAppId())) {
    this.setSubAppId(config.getSubAppId());
  }

  if (StringUtils.isBlank(getSubMchId())) {
    this.setSubMchId(config.getSubMchId());
  }

  if (StringUtils.isBlank(getSignType())) {
    if (config.getSignType() != null && !ALL_SIGN_TYPES.contains(config.getSignType())) {
      throw new WxPayException("非法的signType配置:" + config.getSignType() + ",请检查配置!");
    }
    this.setSignType(StringUtils.trimToNull(config.getSignType()));
  } else {
    if (!ALL_SIGN_TYPES.contains(this.getSignType())) {
      throw new WxPayException("非法的sign_type参数:" + this.getSignType());
    }
  }

  if (StringUtils.isBlank(getNonceStr())) {
    this.setNonceStr(String.valueOf(System.currentTimeMillis()));
  }

  //设置签名字段的值
  this.setSign(SignUtils.createSign(this, this.getSignType(), config.getMchKey(),
    this.ignoreSignType()));
}
 
Example #23
Source File: BaseWxPayServiceImpl.java    From weixin-java-tools with Apache License 2.0 4 votes vote down vote up
@Override
public void setConfig(WxPayConfig config) {
  this.config = config;
}
 
Example #24
Source File: PayChannel4WxServiceImpl.java    From xxpay-master with MIT License 4 votes vote down vote up
/**
 * 构建微信统一下单请求数据
 * @param payOrder
 * @param wxPayConfig
 * @return
 */
WxPayUnifiedOrderRequest buildUnifiedOrderRequest(PayOrder payOrder, WxPayConfig wxPayConfig) {
    String tradeType = wxPayConfig.getTradeType();
    String payOrderId = payOrder.getPayOrderId();
    Integer totalFee = payOrder.getAmount().intValue();// 支付金额,单位分
    String deviceInfo = payOrder.getDevice();
    String body = payOrder.getBody();
    String detail = null;
    String attach = null;
    String outTradeNo = payOrderId;
    String feeType = "CNY";
    String spBillCreateIP = payOrder.getClientIp();
    String timeStart = null;
    String timeExpire = null;
    String goodsTag = null;
    String notifyUrl = wxPayConfig.getNotifyUrl();
    String productId = null;
    if(tradeType.equals(PayConstant.WxConstant.TRADE_TYPE_NATIVE)) productId = JSON.parseObject(payOrder.getExtra()).getString("productId");
    String limitPay = null;
    String openId = null;
    if(tradeType.equals(PayConstant.WxConstant.TRADE_TYPE_JSPAI)) openId = JSON.parseObject(payOrder.getExtra()).getString("openId");
    String sceneInfo = null;
    if(tradeType.equals(PayConstant.WxConstant.TRADE_TYPE_MWEB)) sceneInfo = JSON.parseObject(payOrder.getExtra()).getString("sceneInfo");
    // 微信统一下单请求对象
    WxPayUnifiedOrderRequest request = new WxPayUnifiedOrderRequest();
    request.setDeviceInfo(deviceInfo);
    request.setBody(body);
    request.setDetail(detail);
    request.setAttach(attach);
    request.setOutTradeNo(outTradeNo);
    request.setFeeType(feeType);
    request.setTotalFee(totalFee);
    request.setSpbillCreateIp(spBillCreateIP);
    request.setTimeStart(timeStart);
    request.setTimeExpire(timeExpire);
    request.setGoodsTag(goodsTag);
    request.setNotifyURL(notifyUrl);
    request.setTradeType(tradeType);
    request.setProductId(productId);
    request.setLimitPay(limitPay);
    request.setOpenid(openId);
    request.setSceneInfo(sceneInfo);

    return request;
}
 
Example #25
Source File: BaseWxPayServiceImpl.java    From weixin-java-tools with Apache License 2.0 4 votes vote down vote up
@Override
public WxPayConfig getConfig() {
  return this.config;
}
 
Example #26
Source File: PayChannel4WxController.java    From xxpay-master with MIT License 4 votes vote down vote up
/**
 * 构建微信统一下单请求数据
 * @param payOrder
 * @param wxPayConfig
 * @return
 */
WxPayUnifiedOrderRequest buildUnifiedOrderRequest(PayOrder payOrder, WxPayConfig wxPayConfig) {
    String tradeType = wxPayConfig.getTradeType();
    String payOrderId = payOrder.getPayOrderId();
    Integer totalFee = payOrder.getAmount().intValue();// 支付金额,单位分
    String deviceInfo = payOrder.getDevice();
    String body = payOrder.getBody();
    String detail = null;
    String attach = null;
    String outTradeNo = payOrderId;
    String feeType = "CNY";
    String spBillCreateIP = payOrder.getClientIp();
    String timeStart = null;
    String timeExpire = null;
    String goodsTag = null;
    String notifyUrl = wxPayConfig.getNotifyUrl();
    String productId = null;
    if(tradeType.equals(PayConstant.WxConstant.TRADE_TYPE_NATIVE)) productId = JSON.parseObject(payOrder.getExtra()).getString("productId");
    String limitPay = null;
    String openId = null;
    if(tradeType.equals(PayConstant.WxConstant.TRADE_TYPE_JSPAI)) openId = JSON.parseObject(payOrder.getExtra()).getString("openId");
    String sceneInfo = null;
    if(tradeType.equals(PayConstant.WxConstant.TRADE_TYPE_MWEB)) sceneInfo = JSON.parseObject(payOrder.getExtra()).getString("sceneInfo");
    // 微信统一下单请求对象
    WxPayUnifiedOrderRequest request = new WxPayUnifiedOrderRequest();
    request.setDeviceInfo(deviceInfo);
    request.setBody(body);
    request.setDetail(detail);
    request.setAttach(attach);
    request.setOutTradeNo(outTradeNo);
    request.setFeeType(feeType);
    request.setTotalFee(totalFee);
    request.setSpbillCreateIp(spBillCreateIP);
    request.setTimeStart(timeStart);
    request.setTimeExpire(timeExpire);
    request.setGoodsTag(goodsTag);
    request.setNotifyURL(notifyUrl);
    request.setTradeType(tradeType);
    request.setProductId(productId);
    request.setLimitPay(limitPay);
    request.setOpenid(openId);
    request.setSceneInfo(sceneInfo);

    return request;
}
 
Example #27
Source File: PayChannel4WxServiceImpl.java    From xxpay-master with MIT License 4 votes vote down vote up
/**
 * 构建微信统一下单请求数据
 * @param payOrder
 * @param wxPayConfig
 * @return
 */
WxPayUnifiedOrderRequest buildUnifiedOrderRequest(PayOrder payOrder, WxPayConfig wxPayConfig) {
    String tradeType = wxPayConfig.getTradeType();
    String payOrderId = payOrder.getPayOrderId();
    Integer totalFee = payOrder.getAmount().intValue();// 支付金额,单位分
    String deviceInfo = payOrder.getDevice();
    String body = payOrder.getBody();
    String detail = null;
    String attach = null;
    String outTradeNo = payOrderId;
    String feeType = "CNY";
    String spBillCreateIP = payOrder.getClientIp();
    String timeStart = null;
    String timeExpire = null;
    String goodsTag = null;
    String notifyUrl = wxPayConfig.getNotifyUrl();
    String productId = null;
    if(tradeType.equals(PayConstant.WxConstant.TRADE_TYPE_NATIVE)) productId = JSON.parseObject(payOrder.getExtra()).getString("productId");
    String limitPay = null;
    String openId = null;
    if(tradeType.equals(PayConstant.WxConstant.TRADE_TYPE_JSPAI)) openId = JSON.parseObject(payOrder.getExtra()).getString("openId");
    String sceneInfo = null;
    if(tradeType.equals(PayConstant.WxConstant.TRADE_TYPE_MWEB)) sceneInfo = JSON.parseObject(payOrder.getExtra()).getString("sceneInfo");
    // 微信统一下单请求对象
    WxPayUnifiedOrderRequest request = new WxPayUnifiedOrderRequest();
    request.setDeviceInfo(deviceInfo);
    request.setBody(body);
    request.setDetail(detail);
    request.setAttach(attach);
    request.setOutTradeNo(outTradeNo);
    request.setFeeType(feeType);
    request.setTotalFee(totalFee);
    request.setSpbillCreateIp(spBillCreateIP);
    request.setTimeStart(timeStart);
    request.setTimeExpire(timeExpire);
    request.setGoodsTag(goodsTag);
    request.setNotifyURL(notifyUrl);
    request.setTradeType(tradeType);
    request.setProductId(productId);
    request.setLimitPay(limitPay);
    request.setOpenid(openId);
    request.setSceneInfo(sceneInfo);
    return request;
}
 
Example #28
Source File: WxPayService.java    From weixin-java-tools with Apache License 2.0 2 votes vote down vote up
/**
 * 设置配置对象.
 */
void setConfig(WxPayConfig config);
 
Example #29
Source File: WxPayService.java    From weixin-java-tools with Apache License 2.0 2 votes vote down vote up
/**
 * 获取配置.
 */
WxPayConfig getConfig();