diff --git a/jeepay-core/src/main/java/com/jeequan/jeepay/core/constants/CS.java b/jeepay-core/src/main/java/com/jeequan/jeepay/core/constants/CS.java index 7cf7113..e821101 100644 --- a/jeepay-core/src/main/java/com/jeequan/jeepay/core/constants/CS.java +++ b/jeepay-core/src/main/java/com/jeequan/jeepay/core/constants/CS.java @@ -137,10 +137,10 @@ public class CS { //接口类型 public interface IF_CODE{ - String ALIPAY = "alipay"; //支付宝官方支付 - String WXPAY = "wxpay"; //微信官方支付 - String YSFPAY = "ysfpay"; //云闪付开放平台 - + String ALIPAY = "alipay"; // 支付宝官方支付 + String WXPAY = "wxpay"; // 微信官方支付 + String YSFPAY = "ysfpay"; // 云闪付开放平台 + String XXPAY = "xxpay"; // 小新支付 } diff --git a/jeepay-core/src/main/java/com/jeequan/jeepay/core/model/params/NormalMchParams.java b/jeepay-core/src/main/java/com/jeequan/jeepay/core/model/params/NormalMchParams.java index 863d537..a2f03c6 100644 --- a/jeepay-core/src/main/java/com/jeequan/jeepay/core/model/params/NormalMchParams.java +++ b/jeepay-core/src/main/java/com/jeequan/jeepay/core/model/params/NormalMchParams.java @@ -19,6 +19,7 @@ import com.alibaba.fastjson.JSONObject; import com.jeequan.jeepay.core.constants.CS; import com.jeequan.jeepay.core.model.params.alipay.AlipayNormalMchParams; import com.jeequan.jeepay.core.model.params.wxpay.WxpayNormalMchParams; +import com.jeequan.jeepay.core.model.params.xxpay.XxpayNormalMchParams; /* * 抽象类 普通商户参数定义 @@ -35,6 +36,8 @@ public abstract class NormalMchParams { return JSONObject.parseObject(paramsStr, WxpayNormalMchParams.class); }else if(CS.IF_CODE.ALIPAY.equals(ifCode)){ return JSONObject.parseObject(paramsStr, AlipayNormalMchParams.class); + }else if(CS.IF_CODE.XXPAY.equals(ifCode)){ + return JSONObject.parseObject(paramsStr, XxpayNormalMchParams.class); } return null; } diff --git a/jeepay-core/src/main/java/com/jeequan/jeepay/core/model/params/xxpay/XxpayNormalMchParams.java b/jeepay-core/src/main/java/com/jeequan/jeepay/core/model/params/xxpay/XxpayNormalMchParams.java new file mode 100644 index 0000000..c6a7d3e --- /dev/null +++ b/jeepay-core/src/main/java/com/jeequan/jeepay/core/model/params/xxpay/XxpayNormalMchParams.java @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2021-2031, 河北计全科技有限公司 (https://www.jeequan.com & jeequan@126.com). + *
+ * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE 3.0; + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *
+ * http://www.gnu.org/licenses/lgpl.html + *
+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.jeequan.jeepay.core.model.params.xxpay; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.jeequan.jeepay.core.model.params.NormalMchParams; +import com.jeequan.jeepay.core.utils.StringKit; +import lombok.Data; +import org.apache.commons.lang3.StringUtils; + +/* + * 小新支付 普通商户参数定义 + * + * @author jmdhappy + * @site https://www.jeequan.com + * @date 2021/9/10 21:51 + */ +@Data +public class XxpayNormalMchParams extends NormalMchParams { + + /** 商户号 */ + private String mchId; + + /** 私钥 */ + private String key; + + /** 支付网关地址 */ + private String payUrl; + + @Override + public String deSenData() { + XxpayNormalMchParams mchParams = this; + if (StringUtils.isNotBlank(this.key)) { + mchParams.setKey(StringKit.str2Star(this.key, 4, 4, 6)); + } + return ((JSONObject) JSON.toJSON(mchParams)).toJSONString(); + } + +} diff --git a/jeepay-payment/src/main/java/com/jeequan/jeepay/pay/channel/xxpay/XxpayChannelNoticeService.java b/jeepay-payment/src/main/java/com/jeequan/jeepay/pay/channel/xxpay/XxpayChannelNoticeService.java new file mode 100644 index 0000000..3c53b10 --- /dev/null +++ b/jeepay-payment/src/main/java/com/jeequan/jeepay/pay/channel/xxpay/XxpayChannelNoticeService.java @@ -0,0 +1,104 @@ +/* + * Copyright (c) 2021-2031, 河北计全科技有限公司 (https://www.jeequan.com & jeequan@126.com). + *
+ * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE 3.0; + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *
+ * http://www.gnu.org/licenses/lgpl.html + *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.jeequan.jeepay.pay.channel.xxpay;
+
+import com.alibaba.fastjson.JSONObject;
+import com.jeequan.jeepay.core.constants.CS;
+import com.jeequan.jeepay.core.entity.PayOrder;
+import com.jeequan.jeepay.core.exception.ResponseException;
+import com.jeequan.jeepay.core.model.params.xxpay.XxpayNormalMchParams;
+import com.jeequan.jeepay.pay.channel.AbstractChannelNoticeService;
+import com.jeequan.jeepay.pay.model.MchAppConfigContext;
+import com.jeequan.jeepay.pay.rqrs.msg.ChannelRetMsg;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.tuple.MutablePair;
+import org.springframework.http.ResponseEntity;
+import org.springframework.stereotype.Service;
+
+import javax.servlet.http.HttpServletRequest;
+
+/*
+* 小新支付 回调接口实现类
+*
+* @author jmdhappy
+* @site https://www.jeequan.com
+* @date 2021/9/21 00:16
+*/
+@Service
+@Slf4j
+public class XxpayChannelNoticeService extends AbstractChannelNoticeService {
+
+
+ @Override
+ public String getIfCode() {
+ return CS.IF_CODE.XXPAY;
+ }
+
+ @Override
+ public MutablePair
+ * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE 3.0;
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.gnu.org/licenses/lgpl.html
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.jeequan.jeepay.pay.channel.xxpay;
+
+import cn.hutool.http.HttpUtil;
+import com.alibaba.fastjson.JSONObject;
+import com.jeequan.jeepay.core.constants.CS;
+import com.jeequan.jeepay.core.entity.PayOrder;
+import com.jeequan.jeepay.core.model.params.xxpay.XxpayNormalMchParams;
+import com.jeequan.jeepay.core.utils.JeepayKit;
+import com.jeequan.jeepay.pay.channel.IPayOrderQueryService;
+import com.jeequan.jeepay.pay.model.MchAppConfigContext;
+import com.jeequan.jeepay.pay.rqrs.msg.ChannelRetMsg;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.stereotype.Service;
+
+import java.util.Map;
+import java.util.TreeMap;
+
+/*
+* 小新支付 查单接口实现类
+*
+* @author jmdhappy
+* @site https://www.jeequan.com
+* @date 2021/9/21 01:05
+*/
+@Service
+@Slf4j
+public class XxpayPayOrderQueryService implements IPayOrderQueryService {
+
+ @Override
+ public String getIfCode() {
+ return CS.IF_CODE.XXPAY;
+ }
+
+ @Override
+ public ChannelRetMsg query(PayOrder payOrder, MchAppConfigContext mchAppConfigContext){
+ XxpayNormalMchParams xxpayParams = mchAppConfigContext.getNormalMchParamsByIfCode(getIfCode(), XxpayNormalMchParams.class);
+ String queryPayOrderUrl = XxpayKit.getQueryPayOrderUrl(xxpayParams.getPayUrl());
+ Map
+ * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE 3.0;
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.gnu.org/licenses/lgpl.html
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.jeequan.jeepay.pay.channel.xxpay;
+
+import com.jeequan.jeepay.core.constants.CS;
+import com.jeequan.jeepay.core.entity.PayOrder;
+import com.jeequan.jeepay.pay.channel.AbstractPaymentService;
+import com.jeequan.jeepay.pay.model.MchAppConfigContext;
+import com.jeequan.jeepay.pay.rqrs.AbstractRS;
+import com.jeequan.jeepay.pay.rqrs.payorder.UnifiedOrderRQ;
+import com.jeequan.jeepay.pay.util.PaywayUtil;
+import org.springframework.stereotype.Service;
+
+/*
+* 支付接口: 小新支付
+* 支付方式: 自适应
+*
+* @author jmdhappy
+* @site https://www.jeequan.com
+* @date 2021/9/20 20:00
+*/
+@Service
+public class XxpayPaymentService extends AbstractPaymentService {
+
+ @Override
+ public String getIfCode() {
+ return CS.IF_CODE.XXPAY;
+ }
+
+ @Override
+ public boolean isSupport(String wayCode) {
+ return true;
+ }
+
+ @Override
+ public String preCheck(UnifiedOrderRQ rq, PayOrder payOrder) {
+ return PaywayUtil.getRealPaywayService(this, payOrder.getWayCode()).preCheck(rq, payOrder);
+ }
+
+ @Override
+ public AbstractRS pay(UnifiedOrderRQ rq, PayOrder payOrder, MchAppConfigContext mchAppConfigContext) throws Exception {
+ return PaywayUtil.getRealPaywayService(this, payOrder.getWayCode()).pay(rq, payOrder, mchAppConfigContext);
+ }
+
+}
diff --git a/jeepay-payment/src/main/java/com/jeequan/jeepay/pay/channel/xxpay/payway/AliBar.java b/jeepay-payment/src/main/java/com/jeequan/jeepay/pay/channel/xxpay/payway/AliBar.java
new file mode 100644
index 0000000..071aad3
--- /dev/null
+++ b/jeepay-payment/src/main/java/com/jeequan/jeepay/pay/channel/xxpay/payway/AliBar.java
@@ -0,0 +1,136 @@
+/*
+ * Copyright (c) 2021-2031, 河北计全科技有限公司 (https://www.jeequan.com & jeequan@126.com).
+ *
+ * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE 3.0;
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.gnu.org/licenses/lgpl.html
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.jeequan.jeepay.pay.channel.xxpay.payway;
+
+import cn.hutool.http.HttpUtil;
+import com.alibaba.fastjson.JSONObject;
+import com.jeequan.jeepay.core.entity.PayOrder;
+import com.jeequan.jeepay.core.exception.BizException;
+import com.jeequan.jeepay.core.model.params.xxpay.XxpayNormalMchParams;
+import com.jeequan.jeepay.core.utils.JeepayKit;
+import com.jeequan.jeepay.pay.channel.xxpay.XxpayKit;
+import com.jeequan.jeepay.pay.channel.xxpay.XxpayPaymentService;
+import com.jeequan.jeepay.pay.model.MchAppConfigContext;
+import com.jeequan.jeepay.pay.rqrs.AbstractRS;
+import com.jeequan.jeepay.pay.rqrs.msg.ChannelRetMsg;
+import com.jeequan.jeepay.pay.rqrs.payorder.UnifiedOrderRQ;
+import com.jeequan.jeepay.pay.rqrs.payorder.payway.AliBarOrderRQ;
+import com.jeequan.jeepay.pay.rqrs.payorder.payway.AliBarOrderRS;
+import com.jeequan.jeepay.pay.util.ApiResBuilder;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.stereotype.Service;
+
+import java.util.Map;
+import java.util.TreeMap;
+
+/*
+ * 小新支付 支付宝条码支付
+ *
+ * @author jmdhappy
+ * @site https://www.jeequan.com
+ * @date 2021/9/20 10:09
+ */
+@Service("xxpayPaymentByAliBarService") //Service Name需保持全局唯一性
+@Slf4j
+public class AliBar extends XxpayPaymentService {
+
+ @Override
+ public String preCheck(UnifiedOrderRQ rq, PayOrder payOrder) {
+
+ AliBarOrderRQ bizRQ = (AliBarOrderRQ) rq;
+ if(StringUtils.isEmpty(bizRQ.getAuthCode())){
+ throw new BizException("用户支付条码[authCode]不可为空");
+ }
+
+ return null;
+ }
+
+ @Override
+ public AbstractRS pay(UnifiedOrderRQ rq, PayOrder payOrder, MchAppConfigContext mchAppConfigContext){
+
+ AliBarOrderRQ bizRQ = (AliBarOrderRQ) rq;
+ XxpayNormalMchParams params = mchAppConfigContext.getNormalMchParamsByIfCode(getIfCode(), XxpayNormalMchParams.class);
+ Map