Authored by LUOXC

一个证书之使用一个HTTPCLIENT

... ... @@ -17,13 +17,13 @@ public class WeixinPayConfig {
/**微信支付UFO商户号正式**/
public static final String APP_ID_UFO_REAL = "wx75b18b98bdd92bbc";
public static final String PARTNER_ID = "1516774631";
public static final String WECHAT_PAY_UFOREAL_APP_PARTNER_CERT = "/.cert/wechatpay/apiclient_cert_ufo.p12";
public static final String UFO_PARTNER_ID = "1516774631";
public static final String UFO_PARTNER_CERT = "/.cert/wechatpay/apiclient_cert_ufo.p12";
public interface Miniapp{
String APP_PARTNER_CERT = "/.cert/wechatpay/apiclient_cert_ufo.p12";
String APPID = "wxc677c88385762287";
String MALL_ID = PARTNER_ID;
String MALL_ID = UFO_PARTNER_ID;
}
//查询微信支付订单前缀
... ...
... ... @@ -11,7 +11,6 @@ import javax.servlet.http.HttpServletResponse;
import com.yohobuy.ufo.model.order.bo.PaymentData;
import com.yohoufo.order.service.pay.alipay.AlipayCrossBorderService;
import com.yohoufo.order.service.pay.alipay.AbstractAlipayService;
import com.yohoufo.order.service.pay.alipay.bean.AlipayCustomsResponse;
import com.yohoufo.order.service.pay.alipay.bean.AlipayQueryCustomsResponse;
import com.yohoufo.order.service.pay.unionpay.JsUnionpayService;
import org.apache.commons.lang.StringUtils;
... ... @@ -38,7 +37,7 @@ import com.yohoufo.order.model.response.PaymentConfirmRsp;
import com.yohoufo.order.model.response.PrepayResponse;
import com.yohoufo.order.service.IPaymentService;
import com.yohoufo.order.service.pay.alipay.AlipayOuyinService;
import com.yohoufo.order.service.pay.weixin.WeixinPayUFORealAppService;
import com.yohoufo.order.service.pay.weixin.UfoAppWeixinPayService;
@RestController
@RequestMapping(value = "/payment")
... ... @@ -59,7 +58,7 @@ public class PaymentController {
IPaymentService paymentService;
@Autowired
WeixinPayUFORealAppService weixinPayAppService;
UfoAppWeixinPayService ufoAppWeixinPayService;
@Autowired
AlipayOuyinService alipayService;
... ... @@ -201,7 +200,7 @@ public class PaymentController {
wechatLogger.info("[{}] notification received", out_trade_no);
//回调验证
if(!weixinPayAppService.notifyVerify(params)) {
if(!ufoAppWeixinPayService.notifyVerify(params)) {
notifyResponse.setNotifyResult(NotifyResponse.PAYMENT_NOTIFY_RESULT_VERFAIL);
wechatLogger.error("[{}] notification verify failed", out_trade_no);
return ;
... ... @@ -209,7 +208,7 @@ public class PaymentController {
PaymentData paymentData = null;
try {
paymentData = weixinPayAppService.getPaymentData(params);
paymentData = ufoAppWeixinPayService.getPaymentData(params);
// 支付回调,业务处理
paymentService.paySuccess(paymentData);
... ...
... ... @@ -9,8 +9,8 @@ import com.yohoufo.order.service.pay.alipay.AlipayOuyinService;
import com.yohoufo.order.service.pay.alipay.AlipayOuyinWapService;
import com.yohoufo.order.service.pay.unionpay.JsUnionpayService;
import com.yohoufo.order.service.pay.wallet.WalletPayService;
import com.yohoufo.order.service.pay.weixin.WeixinMiniappPayService;
import com.yohoufo.order.service.pay.weixin.WeixinPayUFORealAppService;
import com.yohoufo.order.service.pay.weixin.MiniappWeixinPayService;
import com.yohoufo.order.service.pay.weixin.UfoAppWeixinPayService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
... ... @@ -20,7 +20,7 @@ import org.springframework.stereotype.Component;
public class PayServiceFactory {
@Autowired
WeixinPayUFORealAppService weixinPayAppService;
UfoAppWeixinPayService ufoAppWeixinPayService;
@Autowired
AlipayOuyinService alipayService;
... ... @@ -29,7 +29,7 @@ public class PayServiceFactory {
AlipayCrossBorderService alipayCrossBorderService;
@Autowired
WeixinMiniappPayService weixinMiniappPayService;
MiniappWeixinPayService miniappWeixinPayService;
@Autowired
WalletPayService walletPayService;
... ... @@ -57,11 +57,11 @@ public class PayServiceFactory {
AbstractPayService payService = null;
if (payment == Payment.WECHAT) {
payService = weixinPayAppService;
payService = ufoAppWeixinPayService;
} else if (payment == Payment.ALIPAY || payment == Payment.ALIPAY_HB || payment == Payment.ALIPAY_HBFQ) {
payService = alipayService;
} else if (payment == Payment.MINIAPP) {
payService = weixinMiniappPayService;
payService = miniappWeixinPayService;
} else if (payment == Payment.WALLET) {
payService = walletPayService;
} else if(payment == Payment.UNION_PAY){
... ...
... ... @@ -28,7 +28,6 @@ import com.yohoufo.order.common.BillTradeStatus;
import com.yohoufo.order.common.HbfqEnum;
import com.yohoufo.order.common.TradeType;
import com.yohoufo.order.common.TransferCase;
import com.yohoufo.order.constants.ClearanceFailType;
import com.yohoufo.order.constants.RefundContant;
import com.yohoufo.order.model.PayQueryBo;
import com.yohoufo.order.model.PayRefundBo;
... ... @@ -50,19 +49,15 @@ import com.yohoufo.order.service.handler.transfer.TransferChancelSelector;
import com.yohoufo.order.service.pay.AbstractPayService;
import com.yohoufo.order.service.pay.alipay.AlipayCrossBorderService;
import com.yohoufo.order.service.pay.alipay.AlipayOuyinService;
import com.yohoufo.order.service.pay.alipay.bean.AlipayCustomsResponse;
import com.yohoufo.order.service.pay.alipay.bean.AlipayQueryCustomsResponse;
import com.yohoufo.order.service.pay.alipay.bean.CustomsErrorMsg;
import com.yohoufo.order.service.pay.unionpay.JsUnionpayService;
import com.yohoufo.order.service.pay.wallet.WalletPayService;
import com.yohoufo.order.service.pay.weixin.WeixinMiniappPayService;
import com.yohoufo.order.service.pay.weixin.WeixinPayUFORealAppService;
import com.yohoufo.order.service.pay.weixin.MiniappWeixinPayService;
import com.yohoufo.order.service.pay.weixin.UfoAppWeixinPayService;
import com.yohoufo.order.service.proxy.WalletTransferService;
import com.yohoufo.order.service.support.CustomsSupportService;
import com.yohoufo.order.service.support.codegenerator.OrderCodeGenerator;
import com.yohoufo.order.service.support.codegenerator.bean.CodeMeta;
import com.yohoufo.order.service.transfer.TransferResult;
import com.yohoufo.order.utils.LoggerUtils;
import com.yohoufo.order.utils.PaymentHelper;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
... ... @@ -110,7 +105,7 @@ public class PaymentServiceImpl implements IPaymentService {
MerchantOrderPaymentService merchantOrderPaymentService;
@Autowired
WeixinPayUFORealAppService weixinPayAppService;
UfoAppWeixinPayService ufoAppWeixinPayService;
@Autowired
AlipayOuyinService alipayService;
... ... @@ -137,7 +132,7 @@ public class PaymentServiceImpl implements IPaymentService {
OrdersPayTransferMapper ordersPayTransferMapper;
@Autowired
WeixinMiniappPayService weixinMiniappPayService;
MiniappWeixinPayService miniappWeixinPayService;
@Autowired
WalletPayService walletPayService;
... ...
... ... @@ -2,7 +2,7 @@ package com.yohoufo.order.service.pay.weixin;
import com.yohoufo.common.utils.HttpClient;
import com.yohoufo.order.config.WeixinPayConfig;
import com.yohoufo.order.service.pay.weixin.ssl.WxMiniappHttpSslClient;
import com.yohoufo.order.service.pay.weixin.ssl.WxUfoHttpSslClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
... ... @@ -10,10 +10,10 @@ import org.springframework.stereotype.Service;
* Created by chao.chen on 2018/11/9.
*/
@Service
public class WeixinMiniappPayService extends AbstractWeixinPayService {
public class MiniappWeixinPayService extends AbstractWeixinPayService {
@Autowired
private WxMiniappHttpSslClient wxMiniappHttpSslClient;
private WxUfoHttpSslClient httpSslClient;
@Override
protected String getMchId() {
... ... @@ -34,6 +34,6 @@ public class WeixinMiniappPayService extends AbstractWeixinPayService {
@Override
protected HttpClient getSslHttpClient() {
return wxMiniappHttpSslClient;
return httpSslClient;
}
}
... ...
... ... @@ -5,17 +5,17 @@ import org.springframework.stereotype.Service;
import com.yohoufo.common.utils.HttpClient;
import com.yohoufo.order.config.WeixinPayConfig;
import com.yohoufo.order.service.pay.weixin.ssl.WxUFORealAppHttpSslClient;
import com.yohoufo.order.service.pay.weixin.ssl.WxUfoHttpSslClient;
@Service
public class WeixinPayUFORealAppService extends AbstractWeixinPayService {
public class UfoAppWeixinPayService extends AbstractWeixinPayService {
@Autowired
private WxUFORealAppHttpSslClient httpSslClient;
private WxUfoHttpSslClient httpSslClient;
@Override
protected String getMchId() {
return WeixinPayConfig.PARTNER_ID;
return WeixinPayConfig.UFO_PARTNER_ID;
}
... ...
... ... @@ -18,7 +18,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.SSLContext;
public abstract class HttpSslClientAbstract extends HttpClient {
public abstract class AbstractHttpSslClient extends HttpClient {
//最大总数
private final int sslMaxTotal = 10;
... ...
package com.yohoufo.order.service.pay.weixin.ssl;
import com.yohoufo.order.config.WeixinPayConfig;
import org.springframework.stereotype.Component;
/**
* Created by chao.chen on 2018/11/9.
*/
@Component
public class WxMiniappHttpSslClient extends HttpSslClientAbstract {
@Override
protected String getMchId() {
return WeixinPayConfig.Miniapp.MALL_ID;
}
@Override
protected String getMchCertPath() {
return WeixinPayConfig.Miniapp.APP_PARTNER_CERT;
}
}
... ... @@ -4,16 +4,16 @@ import com.yohoufo.order.config.WeixinPayConfig;
import org.springframework.stereotype.Component;
@Component
public class WxUFORealAppHttpSslClient extends HttpSslClientAbstract {
public class WxUfoHttpSslClient extends AbstractHttpSslClient {
@Override
protected String getMchId() {
return WeixinPayConfig.PARTNER_ID;
return WeixinPayConfig.UFO_PARTNER_ID;
}
@Override
protected String getMchCertPath() {
return WeixinPayConfig.WECHAT_PAY_UFOREAL_APP_PARTNER_CERT;
return WeixinPayConfig.UFO_PARTNER_CERT;
}
}
... ...