| | |
| | | import com.github.binarywang.wxpay.service.impl.WxPayServiceImpl; |
| | | import com.wechat.pay.java.core.Config; |
| | | import com.wechat.pay.java.core.RSAAutoCertificateConfig; |
| | | import com.wechat.pay.java.core.RSAPublicKeyConfig; |
| | | import com.wechat.pay.java.core.http.HostName; |
| | | import com.wechat.pay.java.core.notification.RSAPublicKeyNotificationConfig; |
| | | import com.wechat.pay.java.service.billdownload.BillDownloadService; |
| | | import com.wechat.pay.java.service.partnerpayments.jsapi.JsapiService; |
| | | import com.wechat.pay.java.service.partnerpayments.jsapi.JsapiServiceExtension; |
| | |
| | | public static WxMaService wxMaService; |
| | | /********微信小程序支付**********/ |
| | | public static JsapiService wxPayService; |
| | | public static WxPayService wxPayV2Service; |
| | | // public static WxPayService wxPayV2Service; |
| | | public static RefundService refundService; |
| | | public static JsapiServiceExtension jsapiExtService; |
| | | public static BillDownloadService billDownloadService; |
| | |
| | | void init() { |
| | | this.load_WxMaService(); |
| | | this.load_wxPayService(); |
| | | this.load_wxPayV2Service(); |
| | | this.load_transferToUser(); |
| | | // this.load_wxPayV2Service(); |
| | | this.load_transferToUser(); |
| | | this.wxProperties = wxPayProperties; |
| | | } |
| | |
| | | config.setAppid(StringUtils.trimToNull(wxPayProperties.getSubAppId())); |
| | | config.setSecret(StringUtils.trimToNull(wxPayProperties.getSubAppSecret())); |
| | | }else { |
| | | config.setAppid(StringUtils.trimToNull(wxPayProperties.getAppId())); |
| | | config.setSecret(StringUtils.trimToNull(wxPayProperties.getAppSecret())); |
| | | // config.setAppid(StringUtils.trimToNull(wxPayProperties.getAppId())); |
| | | // config.setSecret(StringUtils.trimToNull(wxPayProperties.getAppSecret())); |
| | | } |
| | | config.setMsgDataFormat("JSON"); |
| | | //config.setToken(""); |
| | |
| | | public void load_wxPayService() { |
| | | try { |
| | | Config config = |
| | | new RSAAutoCertificateConfig.Builder() |
| | | new RSAPublicKeyConfig.Builder() |
| | | .merchantId(wxPayProperties.getMchId()) |
| | | .privateKeyFromPath(wxPayProperties.getPrivateKeyPath()) |
| | | .publicKeyFromPath(wxPayProperties.getPubKeyPath()) |
| | | .publicKeyId(wxPayProperties.getPayPublicKeyId()) |
| | | .merchantSerialNumber(wxPayProperties.getSerialNumer()) |
| | | .apiV3Key(wxPayProperties.getApiV3Key()) |
| | | .build(); |
| | | this.wxPayService = new JsapiService.Builder().config(config).build(); |
| | | |
| | | |
| | | // Config config = |
| | | // new RSAAutoCertificateConfig.Builder() |
| | | // .merchantId(wxPayProperties.getMchId()) |
| | | // .privateKeyFromPath(wxPayProperties.getPrivateKeyPath()) |
| | | //// .publicKeyFromPath(wxPayProperties.getPubKeyPath()) |
| | | //// .publicKeyId("PUB_KEY_ID_0117000719222024112700219100000508") |
| | | // .merchantSerialNumber(wxPayProperties.getSerialNumer()) |
| | | // .apiV3Key(wxPayProperties.getApiV3Key()) |
| | | // .build(); |
| | | // this.wxPayService = new JsapiService.Builder().config(config).build(); |
| | | |
| | | this.jsapiExtService = new JsapiServiceExtension.Builder().config(config).build(); |
| | | this.refundService = new RefundService.Builder().config(config).build(); |
| | |
| | | /** |
| | | * 初始化微信小程序支付 |
| | | */ |
| | | public void load_wxPayV2Service() |
| | | { |
| | | WxPayConfig payConfig = new WxPayConfig(); |
| | | payConfig.setTradeType(WxPayConstants.TradeType.JSAPI); |
| | | payConfig.setSignType(WxPayConstants.SignType.MD5); |
| | | payConfig.setAppId(StringUtils.trimToNull(wxPayProperties.getAppId())); |
| | | payConfig.setSubAppId(StringUtils.trimToNull(wxPayProperties.getSubAppId())); |
| | | payConfig.setMchId(StringUtils.trimToNull(wxPayProperties.getMchId())); |
| | | payConfig.setSubMchId(StringUtils.trimToNull(wxPayProperties.getSubMchId())); |
| | | payConfig.setMchKey(StringUtils.trimToNull(wxPayProperties.getMchKey())); |
| | | // payConfig.setKeyPath(StringUtils.trimToNull(wxPayProperties.getKeyPath())); |
| | | payConfig.setNotifyUrl(StringUtils.trimToNull(wxPayProperties.getNotifyUrl())); |
| | | WxPayService wxPayService = new WxPayServiceImpl(); |
| | | wxPayService.setConfig(payConfig); |
| | | this.wxPayV2Service = wxPayService; |
| | | } |
| | | // public void load_wxPayV2Service() |
| | | // { |
| | | // WxPayConfig payConfig = new WxPayConfig(); |
| | | // payConfig.setTradeType(WxPayConstants.TradeType.JSAPI); |
| | | // payConfig.setSignType(WxPayConstants.SignType.MD5); |
| | | // payConfig.setAppId(StringUtils.trimToNull(wxPayProperties.getAppId())); |
| | | // payConfig.setSubAppId(StringUtils.trimToNull(wxPayProperties.getSubAppId())); |
| | | // payConfig.setMchId(StringUtils.trimToNull(wxPayProperties.getMchId())); |
| | | // payConfig.setSubMchId(StringUtils.trimToNull(wxPayProperties.getSubMchId())); |
| | | // payConfig.setMchKey(StringUtils.trimToNull(wxPayProperties.getMchKey())); |
| | | //// payConfig.setKeyPath(StringUtils.trimToNull(wxPayProperties.getKeyPath())); |
| | | // payConfig.setNotifyUrl(StringUtils.trimToNull(wxPayProperties.getNotifyUrl())); |
| | | // WxPayService wxPayService = new WxPayServiceImpl(); |
| | | // wxPayService.setConfig(payConfig); |
| | | // this.wxPayV2Service = wxPayService; |
| | | // } |
| | | |
| | | |
| | | /** |
| | |
| | | // } |
| | | |
| | | |
| | | //转账业务 |
| | | public void load_transferToUser() |
| | | { |
| | | TransferToUser transferToUser = new TransferToUser( |