mirror of
https://github.com/jeequan/jeepay
synced 2024-11-17 23:08:03 +08:00
jeepay对接计全付+计全付配置SQL+本地pls包+微信和支付宝小程序的OrderRQ和OrderRS
This commit is contained in:
parent
54cb88c6ad
commit
2743de4b65
@ -755,3 +755,13 @@ VALUES ('pppay', 'PayPal支付', 1, 0, 1,
|
||||
'[{"name":"sandbox","desc":"环境配置","type":"radio","verify":"required","values":"1,0","titles":"沙箱环境, 生产环境"},{"name":"clientId","desc":"Client ID(客户端ID)","type":"text","verify":"required"},{"name":"secret","desc":"Secret(密钥)","type":"text","verify":"required","star":"1"},{"name":"refundWebhook","desc":"退款 Webhook id","type":"text","verify":"required"},{"name":"notifyWebhook","desc":"支付 Webhook id","type":"text","verify":"required"}]',
|
||||
'[{"wayCode": "PP_PC"}]',
|
||||
'http://jeequan.oss-cn-beijing.aliyuncs.com/jeepay/img/paypal.png', '#005ea6', 1, 'PayPal官方通道');
|
||||
|
||||
-- 计全付支付通道
|
||||
INSERT INTO t_pay_interface_define (if_code, if_name, is_mch_mode, is_isv_mode, config_page_type, isv_params, isvsub_mch_params, normal_mch_params, way_codes, icon, bg_color, state, remark)
|
||||
VALUES ('jeepluspay', '计全付', 1, 0, 1,
|
||||
NULL,
|
||||
NULL,
|
||||
'[{"name":"signType","desc":"签名方式","type":"radio","verify":"required","values":"MD5,RSA2","titles":"MD5,RSA2"},{"name":"merchantNo","desc":"计全付商户号","type":"text","verify":"required"},{"name":"appId","desc":"应用ID","type":"text","verify":"required"},{"name":"appSecret","desc":"md5秘钥","type":"textarea","verify":"required","star":"1"},{"name":"rsa2AppPrivateKey","desc":"RSA2: 应用私钥","type":"text","verify":"required","star":"1"},{"name":"rsa2PayPublicKey","desc":"RSA2: 支付网关公钥","type":"text","verify":"required","star":"1"}]',
|
||||
'[{"wayCode": "ALI_APP"}, {"wayCode": "ALI_BAR"}, {"wayCode": "ALI_JSAPI"}, {"wayCode": "ALI_LITE"}, {"wayCode": "ALI_PC"}, {"wayCode": "ALI_QR"}, {"wayCode": "ALI_WAP"}, {"wayCode": "WX_APP"}, {"wayCode": "WX_BAR"}, {"wayCode": "WX_H5"}, {"wayCode": "WX_JSAPI"}, {"wayCode": "WX_LITE"}, {"wayCode": "WX_NATIVE"}]',
|
||||
'http://jeequan.oss-cn-beijing.aliyuncs.com/jeepay/img/jeepluspay.svg', '#0CACFF', 1, '计全付');
|
||||
|
||||
|
@ -254,4 +254,14 @@ VALUES ('wxpay', '微信支付官方', 1, 1, 2,
|
||||
## -- ++++ [v1.13.0] ===> [v1.14.0] ++++
|
||||
-- 日志请求参数、响应参数长度修改
|
||||
alter table t_sys_log modify `opt_req_param` TEXT DEFAULT NULL COMMENT '操作请求参数';
|
||||
alter table t_sys_log modify `opt_res_info` TEXT DEFAULT NULL COMMENT '操作响应结果';
|
||||
alter table t_sys_log modify `opt_res_info` TEXT DEFAULT NULL COMMENT '操作响应结果';
|
||||
|
||||
|
||||
-- 增加计全付支付通道
|
||||
INSERT INTO t_pay_interface_define (if_code, if_name, is_mch_mode, is_isv_mode, config_page_type, isv_params, isvsub_mch_params, normal_mch_params, way_codes, icon, bg_color, state, remark)
|
||||
VALUES ('jeepluspay', '计全付', 1, 0, 1,
|
||||
NULL,
|
||||
NULL,
|
||||
'[{"name":"signType","desc":"签名方式","type":"radio","verify":"required","values":"MD5,RSA2","titles":"MD5,RSA2"},{"name":"merchantNo","desc":"计全付商户号","type":"text","verify":"required"},{"name":"appId","desc":"应用ID","type":"text","verify":"required"},{"name":"appSecret","desc":"md5秘钥","type":"textarea","verify":"required","star":"1"},{"name":"rsa2AppPrivateKey","desc":"RSA2: 应用私钥","type":"text","verify":"required","star":"1"},{"name":"rsa2PayPublicKey","desc":"RSA2: 支付网关公钥","type":"text","verify":"required","star":"1"}]',
|
||||
'[{"wayCode": "ALI_APP"}, {"wayCode": "ALI_BAR"}, {"wayCode": "ALI_JSAPI"}, {"wayCode": "ALI_LITE"}, {"wayCode": "ALI_PC"}, {"wayCode": "ALI_QR"}, {"wayCode": "ALI_WAP"}, {"wayCode": "WX_APP"}, {"wayCode": "WX_BAR"}, {"wayCode": "WX_H5"}, {"wayCode": "WX_JSAPI"}, {"wayCode": "WX_LITE"}, {"wayCode": "WX_NATIVE"}]',
|
||||
'http://jeequan.oss-cn-beijing.aliyuncs.com/jeepay/img/jeepluspay.svg', '#0CACFF', 1, '计全付');
|
||||
|
@ -147,6 +147,7 @@ public class CS {
|
||||
String YSFPAY = "ysfpay"; // 云闪付开放平台
|
||||
String XXPAY = "xxpay"; // 小新支付
|
||||
String PPPAY = "pppay"; // Paypal 支付
|
||||
String JEEPLUSPAY = "jeepluspay"; // 计全支付plus
|
||||
}
|
||||
|
||||
|
||||
@ -159,6 +160,7 @@ public class CS {
|
||||
|
||||
String ALI_BAR = "ALI_BAR"; //支付宝条码支付
|
||||
String ALI_JSAPI = "ALI_JSAPI"; //支付宝服务窗支付
|
||||
String ALI_LITE = "ALI_LITE"; //支付宝小程序支付
|
||||
String ALI_APP = "ALI_APP"; //支付宝 app支付
|
||||
String ALI_PC = "ALI_PC"; //支付宝 电脑网站支付
|
||||
String ALI_WAP = "ALI_WAP"; //支付宝 wap支付
|
||||
|
@ -18,6 +18,7 @@ package com.jeequan.jeepay.core.model.params;
|
||||
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.jeepluspay.JeepluspayNormalMchParams;
|
||||
import com.jeequan.jeepay.core.model.params.pppay.PpPayNormalMchParams;
|
||||
import com.jeequan.jeepay.core.model.params.wxpay.WxpayNormalMchParams;
|
||||
import com.jeequan.jeepay.core.model.params.xxpay.XxpayNormalMchParams;
|
||||
@ -41,6 +42,8 @@ public abstract class NormalMchParams {
|
||||
return JSONObject.parseObject(paramsStr, XxpayNormalMchParams.class);
|
||||
}else if (CS.IF_CODE.PPPAY.equals(ifCode)){
|
||||
return JSONObject.parseObject(paramsStr, PpPayNormalMchParams.class);
|
||||
}else if (CS.IF_CODE.JEEPLUSPAY.equals(ifCode)){
|
||||
return JSONObject.parseObject(paramsStr, JeepluspayNormalMchParams.class);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2031, 河北计全科技有限公司 (https://www.jeequan.com & jeequan@126.com).
|
||||
* <p>
|
||||
* 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
|
||||
* <p>
|
||||
* http://www.gnu.org/licenses/lgpl.html
|
||||
* <p>
|
||||
* 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.jeepluspay;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/*
|
||||
* 计全支付plus, 通用配置信息
|
||||
*
|
||||
* @author yurong
|
||||
* @site https://www.jeequan.com
|
||||
* @date 2022/8/11 14:32
|
||||
*/
|
||||
@Data
|
||||
public class JeepluspayConfig {
|
||||
|
||||
/** 签名类型 */
|
||||
public static final String DEFAULT_SIGN_TYPE = "MD5";
|
||||
public static final String SIGN_TYPE_RSA2 = "RSA2";
|
||||
|
||||
/** 支付订单状态 */
|
||||
public static String PAY_STATE_SUCCESS = "2"; // 2-支付成功
|
||||
public static String PAY_STATE_FAIL = "3"; // 3-支付失败
|
||||
|
||||
/** 退款订单状态 */
|
||||
public static String Refund_STATE_SUCCESS = "2"; // 2-退款成功
|
||||
public static String Refund_STATE_FAIL = "3"; // 3-退款失败
|
||||
|
||||
/** 支付方式 */
|
||||
public static String ALI_BAR = "ALI_BAR"; // 支付宝条码
|
||||
public static String ALI_JSAPI = "ALI_JSAPI"; // 支付宝生活号
|
||||
public static String ALI_APP = "ALI_APP"; // 支付宝APP
|
||||
public static String ALI_WAP = "ALI_WAP"; // 支付宝WAP
|
||||
public static String ALI_PC = "ALI_PC"; // 支付宝PC网站
|
||||
public static String ALI_QR = "ALI_QR"; // 支付宝二维码
|
||||
public static String WX_BAR = "WX_BAR"; // 微信条码
|
||||
public static String WX_JSAPI = "WX_JSAPI"; // 微信公众号
|
||||
public static String WX_LITE = "WX_LITE"; // 微信小程序
|
||||
public static String WX_APP = "WX_APP"; // 微信APP
|
||||
public static String WX_H5 = "WX_H5"; // 微信H5
|
||||
public static String WX_NATIVE = "WX_NATIVE"; // 微信扫码
|
||||
}
|
@ -0,0 +1,64 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2031, 河北计全科技有限公司 (https://www.jeequan.com & jeequan@126.com).
|
||||
* <p>
|
||||
* 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
|
||||
* <p>
|
||||
* http://www.gnu.org/licenses/lgpl.html
|
||||
* <p>
|
||||
* 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.jeepluspay;
|
||||
|
||||
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;
|
||||
|
||||
/*
|
||||
* 计全支付plus, 普通商户参数定义
|
||||
*
|
||||
* @author yurong
|
||||
* @site https://www.jeequan.com
|
||||
* @date 2022/8/11 14:32
|
||||
*/
|
||||
@Data
|
||||
public class JeepluspayNormalMchParams extends NormalMchParams {
|
||||
|
||||
/** 商户号 */
|
||||
private String merchantNo;
|
||||
|
||||
/** 应用ID */
|
||||
private String appId;
|
||||
|
||||
/** 签名方式 **/
|
||||
private String signType;
|
||||
|
||||
/** md5秘钥 */
|
||||
private String AppSecret;
|
||||
|
||||
/** RSA2: 应用私钥 */
|
||||
private String rsa2AppPrivateKey;
|
||||
|
||||
/** RSA2: 支付网关公钥 */
|
||||
public String rsa2PayPublicKey;
|
||||
|
||||
|
||||
@Override
|
||||
public String deSenData() {
|
||||
|
||||
JeepluspayNormalMchParams mchParams = this;
|
||||
if (StringUtils.isNotBlank(this.AppSecret)) {
|
||||
mchParams.setAppSecret(StringKit.str2Star(this.AppSecret, 4, 4, 6));
|
||||
}
|
||||
return ((JSONObject) JSON.toJSON(mchParams)).toJSONString();
|
||||
}
|
||||
|
||||
}
|
@ -15,6 +15,12 @@
|
||||
<artifactId>jeepay</artifactId>
|
||||
<version>Final</version>
|
||||
</parent>
|
||||
|
||||
<!-- 项目属性 -->
|
||||
<properties>
|
||||
<projectRootDir>${basedir}/../</projectRootDir>
|
||||
</properties>
|
||||
|
||||
<!-- 项目依赖声明 -->
|
||||
<dependencies>
|
||||
|
||||
@ -118,6 +124,15 @@
|
||||
<version>1.2.2</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 计全付本地依赖包 -->
|
||||
<dependency>
|
||||
<groupId>com.jeequan</groupId>
|
||||
<artifactId>jeepay-sdk-java</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${projectRootDir}/libs/jeepay-sdk-java-pls-1.0.0.jar</systemPath>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
||||
|
@ -0,0 +1,128 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2031, 河北计全科技有限公司 (https://www.jeequan.com & jeequan@126.com).
|
||||
* <p>
|
||||
* 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
|
||||
* <p>
|
||||
* http://www.gnu.org/licenses/lgpl.html
|
||||
* <p>
|
||||
* 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.jeepluspay;
|
||||
|
||||
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.jeepluspay.JeepluspayConfig;
|
||||
import com.jeequan.jeepay.core.model.params.jeepluspay.JeepluspayNormalMchParams;
|
||||
import com.jeequan.jeepay.pay.channel.AbstractChannelNoticeService;
|
||||
import com.jeequan.jeepay.pay.model.MchAppConfigContext;
|
||||
import com.jeequan.jeepay.pay.rqrs.msg.ChannelRetMsg;
|
||||
import com.jeequan.jeepay.util.JeepayKit;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.tuple.MutablePair;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
/*
|
||||
* 计全付 回调
|
||||
*
|
||||
* @author yr
|
||||
* @site https://www.jeequan.com
|
||||
* @date 2022/7/20 10:31
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class JeepluspayChannelNoticeService extends AbstractChannelNoticeService {
|
||||
|
||||
@Override
|
||||
public String getIfCode() {
|
||||
return CS.IF_CODE.JEEPLUSPAY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MutablePair<String, Object> parseParams(HttpServletRequest request, String urlOrderId, NoticeTypeEnum noticeTypeEnum) {
|
||||
try {
|
||||
JSONObject params = getReqParamJSON();
|
||||
// 获取订单号
|
||||
String payOrderId = params.getString("mchOrderNo");
|
||||
return MutablePair.of(payOrderId, params);
|
||||
} catch (Exception e) {
|
||||
log.error("error", e);
|
||||
throw ResponseException.buildText("ERROR");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelRetMsg doNotice(HttpServletRequest request, Object params, PayOrder payOrder, MchAppConfigContext mchAppConfigContext, NoticeTypeEnum noticeTypeEnum) {
|
||||
try {
|
||||
String logPrefix = "【处理计全付回调】";
|
||||
// 获取请求参数
|
||||
JSONObject paramsJson = (JSONObject) params;
|
||||
log.info("{} 回调参数, jsonParams:{}", logPrefix, paramsJson);
|
||||
// 校验签名
|
||||
String sign = paramsJson.getString("sign");
|
||||
boolean verifyResult = verifyParams(paramsJson, sign, mchAppConfigContext);
|
||||
// 验证参数失败
|
||||
if (!verifyResult) {
|
||||
throw ResponseException.buildText("ERROR");
|
||||
}
|
||||
log.info("{}验证支付通知数据及签名通过", logPrefix);
|
||||
// 验签成功后判断上游订单状态
|
||||
ResponseEntity okResponse = textResp("success");
|
||||
|
||||
// 支付状态: 0-订单生成, 1-支付中, 2-支付成功, 3-支付失败, 4-已撤销, 5-已退款, 6-订单关闭
|
||||
String status = paramsJson.getString("state");
|
||||
ChannelRetMsg result = new ChannelRetMsg();
|
||||
result.setResponseEntity(okResponse);
|
||||
result.setChannelOrderId(paramsJson.getString("payOrderId"));
|
||||
result.setChannelState(ChannelRetMsg.ChannelState.WAITING); // 默认支付中
|
||||
if (JeepluspayConfig.PAY_STATE_SUCCESS.equals(status)) {
|
||||
result.setChannelState(ChannelRetMsg.ChannelState.CONFIRM_SUCCESS);
|
||||
} else if (JeepluspayConfig.PAY_STATE_FAIL.equals(status)) {
|
||||
result.setChannelState(ChannelRetMsg.ChannelState.CONFIRM_FAIL);
|
||||
}
|
||||
return result;
|
||||
} catch (Exception e) {
|
||||
log.error("error", e);
|
||||
throw ResponseException.buildText("ERROR");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证计全付通知参数
|
||||
*
|
||||
* @return boolean true or false
|
||||
*/
|
||||
public boolean verifyParams(JSONObject jsonParams, String sign, MchAppConfigContext mchAppConfigContext) {
|
||||
try {
|
||||
// 返回数据
|
||||
if (StringUtils.isEmpty(sign)) {
|
||||
log.info("验签参数为空 [sign] :{}", sign);
|
||||
return false;
|
||||
}
|
||||
JeepluspayNormalMchParams normalMchParams = (JeepluspayNormalMchParams) configContextQueryService.queryNormalMchParams(mchAppConfigContext.getMchNo(), mchAppConfigContext.getAppId(), CS.IF_CODE.JEEPLUSPAY);
|
||||
jsonParams.remove("sign");
|
||||
// 获取md5秘钥,生成签名
|
||||
String newSign = JeepayKit.getSign(jsonParams, normalMchParams.getAppSecret());
|
||||
// 验签 异步时都是MD5
|
||||
if (!sign.equals(newSign)) {
|
||||
log.info("验签失败! 回调参数:parameter = {}", jsonParams);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
log.error("error", e);
|
||||
throw ResponseException.buildText("ERROR");
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,133 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2031, 河北计全科技有限公司 (https://www.jeequan.com & jeequan@126.com).
|
||||
* <p>
|
||||
* 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
|
||||
* <p>
|
||||
* http://www.gnu.org/licenses/lgpl.html
|
||||
* <p>
|
||||
* 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.jeepluspay;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.jeequan.jeepay.core.constants.CS;
|
||||
import com.jeequan.jeepay.core.entity.RefundOrder;
|
||||
import com.jeequan.jeepay.core.exception.ResponseException;
|
||||
import com.jeequan.jeepay.core.model.params.jeepluspay.JeepluspayConfig;
|
||||
import com.jeequan.jeepay.core.model.params.jeepluspay.JeepluspayNormalMchParams;
|
||||
import com.jeequan.jeepay.pay.channel.AbstractChannelRefundNoticeService;
|
||||
import com.jeequan.jeepay.pay.model.MchAppConfigContext;
|
||||
import com.jeequan.jeepay.pay.rqrs.msg.ChannelRetMsg;
|
||||
import com.jeequan.jeepay.util.JeepayKit;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.tuple.MutablePair;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
/*
|
||||
* 计全支付plus 退款回调接口实现类
|
||||
*
|
||||
* @author yr
|
||||
* @site https://www.jeequan.com
|
||||
* @date 2022/7/20 10:31
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class JeepluspayChannelRefundNoticeService extends AbstractChannelRefundNoticeService {
|
||||
|
||||
@Override
|
||||
public String getIfCode() {
|
||||
return CS.IF_CODE.JEEPLUSPAY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MutablePair<String, Object> parseParams(HttpServletRequest request, String urlOrderId, NoticeTypeEnum noticeTypeEnum) {
|
||||
|
||||
try {
|
||||
JSONObject params = getReqParamJSON();
|
||||
String refundOrderId = params.getString("mchRefundNo");
|
||||
return MutablePair.of(refundOrderId, params);
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("error", e);
|
||||
throw ResponseException.buildText("ERROR");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelRetMsg doNotice(HttpServletRequest request, Object params, RefundOrder refundOrder, MchAppConfigContext mchAppConfigContext, NoticeTypeEnum noticeTypeEnum) {
|
||||
try {
|
||||
String logPrefix = "【处理计全付退款回调】";
|
||||
// 获取请求参数
|
||||
JSONObject jsonParams = (JSONObject) params;
|
||||
log.info("{} 回调参数, jsonParams:{}", logPrefix, jsonParams);
|
||||
// 校验签名
|
||||
String sign = jsonParams.getString("sign");
|
||||
boolean verifyResult = verifyParams(jsonParams, sign, mchAppConfigContext);
|
||||
// 验证参数失败
|
||||
if (!verifyResult) {
|
||||
throw ResponseException.buildText("ERROR");
|
||||
}
|
||||
log.info("{}验证退款通知数据及签名通过", logPrefix);
|
||||
//验签成功后判断上游订单状态
|
||||
ResponseEntity okResponse = textResp("success");
|
||||
|
||||
// 退款状态 0-订单生成 1-退款中 2-退款成功 3-退款失败 4-退款关闭
|
||||
String status = jsonParams.getString("state");
|
||||
|
||||
ChannelRetMsg result = new ChannelRetMsg();
|
||||
result.setChannelOrderId(jsonParams.getString("refundOrderId")); //渠道订单号
|
||||
result.setResponseEntity(okResponse); //响应数据
|
||||
|
||||
result.setChannelState(ChannelRetMsg.ChannelState.WAITING); // 默认退款中
|
||||
|
||||
if (JeepluspayConfig.Refund_STATE_SUCCESS.equals(status)) {
|
||||
result.setChannelState(ChannelRetMsg.ChannelState.CONFIRM_SUCCESS);
|
||||
}else if (JeepluspayConfig.Refund_STATE_FAIL.equals(status)) {
|
||||
result.setChannelState(ChannelRetMsg.ChannelState.CONFIRM_FAIL);
|
||||
}
|
||||
return result;
|
||||
} catch (Exception e) {
|
||||
log.error("error", e);
|
||||
throw ResponseException.buildText("ERROR");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证计全支付plus通知参数
|
||||
*
|
||||
* @return boolean true or false
|
||||
*/
|
||||
public boolean verifyParams(JSONObject jsonParams, String sign, MchAppConfigContext mchAppConfigContext) {
|
||||
try {
|
||||
// 返回数据
|
||||
if (StringUtils.isEmpty(sign)) {
|
||||
log.info("验签参数为空 [sign] :{}", sign);
|
||||
return false;
|
||||
}
|
||||
JeepluspayNormalMchParams normalMchParams = (JeepluspayNormalMchParams) configContextQueryService.queryNormalMchParams(mchAppConfigContext.getMchNo(), mchAppConfigContext.getAppId(), CS.IF_CODE.JEEPLUSPAY);
|
||||
jsonParams.remove("sign");
|
||||
// 获取md5秘钥,生成签名
|
||||
String newSign = JeepayKit.getSign(jsonParams, normalMchParams.getAppSecret());
|
||||
// 验签 异步时都是MD5
|
||||
if (!sign.equals(newSign)) {
|
||||
log.info("验签失败! 回调参数:parameter = {}", jsonParams);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
log.error("error", e);
|
||||
throw ResponseException.buildText("ERROR");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,98 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2031, 河北计全科技有限公司 (https://www.jeequan.com & jeequan@126.com).
|
||||
* <p>
|
||||
* 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
|
||||
* <p>
|
||||
* http://www.gnu.org/licenses/lgpl.html
|
||||
* <p>
|
||||
* 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.jeepluspay;
|
||||
|
||||
import com.jeequan.jeepay.Jeepay;
|
||||
import com.jeequan.jeepay.JeepayClient;
|
||||
import com.jeequan.jeepay.core.constants.CS;
|
||||
import com.jeequan.jeepay.core.entity.PayOrder;
|
||||
import com.jeequan.jeepay.core.model.params.jeepluspay.JeepluspayConfig;
|
||||
import com.jeequan.jeepay.core.model.params.jeepluspay.JeepluspayNormalMchParams;
|
||||
import com.jeequan.jeepay.model.PayOrderQueryReqModel;
|
||||
import com.jeequan.jeepay.pay.channel.IPayOrderQueryService;
|
||||
import com.jeequan.jeepay.pay.model.MchAppConfigContext;
|
||||
import com.jeequan.jeepay.pay.rqrs.msg.ChannelRetMsg;
|
||||
import com.jeequan.jeepay.pay.service.ConfigContextQueryService;
|
||||
import com.jeequan.jeepay.request.PayOrderQueryRequest;
|
||||
import com.jeequan.jeepay.response.PayOrderQueryResponse;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 计全支付plus 查询订单
|
||||
*
|
||||
* @author yurong
|
||||
* @site https://www.jeequan.com
|
||||
* @date 2022/7/20 9:31
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class JeepluspayPayOrderQueryService implements IPayOrderQueryService {
|
||||
@Autowired
|
||||
private ConfigContextQueryService configContextQueryService;
|
||||
|
||||
@Override
|
||||
public String getIfCode() {
|
||||
return CS.IF_CODE.JEEPLUSPAY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelRetMsg query(PayOrder payOrder, MchAppConfigContext mchAppConfigContext) throws Exception {
|
||||
PayOrderQueryRequest request = new PayOrderQueryRequest();
|
||||
PayOrderQueryReqModel model = new PayOrderQueryReqModel();
|
||||
try {
|
||||
JeepluspayNormalMchParams normalMchParams = (JeepluspayNormalMchParams) configContextQueryService.queryNormalMchParams(mchAppConfigContext.getMchNo(), mchAppConfigContext.getAppId(), CS.IF_CODE.JEEPLUSPAY);
|
||||
model.setMchNo(normalMchParams.getMerchantNo()); // 商户号
|
||||
model.setAppId(normalMchParams.getAppId()); // 应用ID
|
||||
model.setMchOrderNo(payOrder.getPayOrderId()); // 支付订单号
|
||||
request.setBizModel(model);
|
||||
// 发起请求
|
||||
PayOrderQueryResponse response = new PayOrderQueryResponse();
|
||||
boolean checkSign = false;
|
||||
boolean isSuccess = false;
|
||||
if (normalMchParams.getSignType().equals(JeepluspayConfig.DEFAULT_SIGN_TYPE) || StringUtils.isEmpty(normalMchParams.getSignType())) {
|
||||
JeepayClient jeepayClient = JeepayClient.getInstance(normalMchParams.getAppId(), normalMchParams.getAppSecret(), Jeepay.getApiBase());
|
||||
response = jeepayClient.execute(request);
|
||||
checkSign = response.checkSign(normalMchParams.getAppSecret());
|
||||
isSuccess = response.isSuccess(normalMchParams.getAppSecret());
|
||||
|
||||
} else if (normalMchParams.getSignType().equals(JeepluspayConfig.SIGN_TYPE_RSA2)) {
|
||||
JeepayClient jeepayClient = JeepayClient.getInstance(normalMchParams.getAppId(), normalMchParams.getRsa2AppPrivateKey(), Jeepay.getApiBase());
|
||||
response = jeepayClient.executeByRSA2(request);
|
||||
checkSign = response.checkSignByRsa2(normalMchParams.getRsa2PayPublicKey());
|
||||
isSuccess = response.isSuccessByRsa2(normalMchParams.getRsa2PayPublicKey());
|
||||
}
|
||||
|
||||
// 请求响应状态
|
||||
if (isSuccess && checkSign) {
|
||||
// 如果查询请求成功
|
||||
if (JeepluspayConfig.PAY_STATE_SUCCESS.equals(String.valueOf(response.get().getState()))) {
|
||||
return ChannelRetMsg.confirmSuccess(response.get().getPayOrderId());
|
||||
} else if (JeepluspayConfig.PAY_STATE_FAIL.equals(String.valueOf(response.get().getState()))) {
|
||||
// 失败
|
||||
return ChannelRetMsg.confirmFail();
|
||||
}
|
||||
}
|
||||
// 支付中
|
||||
return ChannelRetMsg.waiting();
|
||||
} catch (Exception e) {
|
||||
// 支付中
|
||||
return ChannelRetMsg.waiting();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
package com.jeequan.jeepay.pay.channel.jeepluspay;
|
||||
|
||||
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;
|
||||
|
||||
/**
|
||||
* 计全支付plus
|
||||
*
|
||||
* @author yurong
|
||||
* @site https://www.jeequan.com
|
||||
* @date 2022/8/11 15:37
|
||||
*/
|
||||
@Service
|
||||
public class JeepluspayPaymentService extends AbstractPaymentService {
|
||||
|
||||
@Override
|
||||
public String getIfCode() {
|
||||
return CS.IF_CODE.JEEPLUSPAY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSupport(String wayCode) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String preCheck(UnifiedOrderRQ bizRQ, PayOrder payOrder) {
|
||||
return PaywayUtil.getRealPaywayService(this, payOrder.getWayCode()).preCheck(bizRQ, payOrder);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AbstractRS pay(UnifiedOrderRQ bizRQ, PayOrder payOrder, MchAppConfigContext mchAppConfigContext) throws Exception {
|
||||
return PaywayUtil.getRealPaywayService(this, payOrder.getWayCode()).pay(bizRQ, payOrder, mchAppConfigContext);
|
||||
}
|
||||
}
|
@ -0,0 +1,154 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2031, 河北计全科技有限公司 (https://www.jeequan.com & jeequan@126.com).
|
||||
* <p>
|
||||
* 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
|
||||
* <p>
|
||||
* http://www.gnu.org/licenses/lgpl.html
|
||||
* <p>
|
||||
* 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.jeepluspay;
|
||||
|
||||
import com.jeequan.jeepay.Jeepay;
|
||||
import com.jeequan.jeepay.JeepayClient;
|
||||
import com.jeequan.jeepay.core.constants.CS;
|
||||
import com.jeequan.jeepay.core.entity.PayOrder;
|
||||
import com.jeequan.jeepay.core.entity.RefundOrder;
|
||||
import com.jeequan.jeepay.core.model.params.jeepluspay.JeepluspayConfig;
|
||||
import com.jeequan.jeepay.core.model.params.jeepluspay.JeepluspayNormalMchParams;
|
||||
import com.jeequan.jeepay.exception.JeepayException;
|
||||
import com.jeequan.jeepay.model.RefundOrderCreateReqModel;
|
||||
import com.jeequan.jeepay.model.RefundOrderQueryReqModel;
|
||||
import com.jeequan.jeepay.pay.channel.AbstractRefundService;
|
||||
import com.jeequan.jeepay.pay.model.MchAppConfigContext;
|
||||
import com.jeequan.jeepay.pay.rqrs.msg.ChannelRetMsg;
|
||||
import com.jeequan.jeepay.pay.rqrs.refund.RefundOrderRQ;
|
||||
import com.jeequan.jeepay.request.RefundOrderCreateRequest;
|
||||
import com.jeequan.jeepay.request.RefundOrderQueryRequest;
|
||||
import com.jeequan.jeepay.response.RefundOrderCreateResponse;
|
||||
import com.jeequan.jeepay.response.RefundOrderQueryResponse;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 退款接口: 计全退款plus
|
||||
*
|
||||
* @author yurong
|
||||
* @site https://www.jeequan.com
|
||||
* @date 2022/8/16 15:28
|
||||
*/
|
||||
@Service
|
||||
public class JeepluspayRefundService extends AbstractRefundService {
|
||||
|
||||
@Override
|
||||
public String getIfCode() {
|
||||
return CS.IF_CODE.JEEPLUSPAY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String preCheck(RefundOrderRQ bizRQ, RefundOrder refundOrder, PayOrder payOrder) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelRetMsg refund(RefundOrderRQ bizRQ, RefundOrder refundOrder, PayOrder payOrder, MchAppConfigContext mchAppConfigContext) throws Exception {
|
||||
JeepluspayNormalMchParams normalMchParams = (JeepluspayNormalMchParams) configContextQueryService.queryNormalMchParams(mchAppConfigContext.getMchNo(), mchAppConfigContext.getAppId(), CS.IF_CODE.JEEPLUSPAY);
|
||||
RefundOrderCreateRequest request = new RefundOrderCreateRequest();
|
||||
RefundOrderCreateReqModel model = new RefundOrderCreateReqModel();
|
||||
model.setMchNo(normalMchParams.getMerchantNo()); // 商户号
|
||||
model.setAppId(normalMchParams.getAppId()); // 应用ID
|
||||
model.setPayOrderId(payOrder.getChannelOrderNo()); // 支付订单号
|
||||
model.setMchRefundNo(refundOrder.getRefundOrderId()); // 商户退款单号
|
||||
model.setRefundAmount(refundOrder.getRefundAmount()); // 金额,单位分
|
||||
model.setCurrency(refundOrder.getCurrency()); // 币种,目前只支持cny
|
||||
model.setRefundReason(refundOrder.getRefundReason()); // 退款原因
|
||||
model.setClientIp(refundOrder.getClientIp()); // 发起退款请求客户端的IP地址
|
||||
model.setNotifyUrl(getNotifyUrl()); // 异步通知地址
|
||||
request.setBizModel(model);
|
||||
// 构造函数响应数据
|
||||
ChannelRetMsg channelRetMsg = new ChannelRetMsg();
|
||||
try {
|
||||
// 发起退款
|
||||
RefundOrderCreateResponse response = new RefundOrderCreateResponse();
|
||||
boolean checkSign = false;
|
||||
boolean isSuccess = false;
|
||||
if (normalMchParams.getSignType().equals(JeepluspayConfig.DEFAULT_SIGN_TYPE) || StringUtils.isEmpty(normalMchParams.getSignType())) {
|
||||
JeepayClient jeepayClient = JeepayClient.getInstance(normalMchParams.getAppId(), normalMchParams.getAppSecret(), Jeepay.getApiBase());
|
||||
response = jeepayClient.execute(request);
|
||||
checkSign = response.checkSign(normalMchParams.getAppSecret());
|
||||
isSuccess = response.isSuccess(normalMchParams.getAppSecret());
|
||||
|
||||
} else if (normalMchParams.getSignType().equals(JeepluspayConfig.SIGN_TYPE_RSA2)) {
|
||||
JeepayClient jeepayClient = JeepayClient.getInstance(normalMchParams.getAppId(), normalMchParams.getRsa2AppPrivateKey(), Jeepay.getApiBase());
|
||||
response = jeepayClient.executeByRSA2(request);
|
||||
checkSign = response.checkSignByRsa2(normalMchParams.getRsa2PayPublicKey());
|
||||
isSuccess = response.isSuccessByRsa2(normalMchParams.getRsa2PayPublicKey());
|
||||
}
|
||||
|
||||
if (checkSign) {
|
||||
channelRetMsg.setChannelOrderId(response.get().getRefundOrderId());
|
||||
// 退款发送成功
|
||||
if (isSuccess) {
|
||||
channelRetMsg.setChannelState(ChannelRetMsg.ChannelState.CONFIRM_SUCCESS);
|
||||
} else {
|
||||
channelRetMsg.setChannelState(ChannelRetMsg.ChannelState.CONFIRM_FAIL);
|
||||
channelRetMsg.setChannelErrCode(response.getCode().toString());
|
||||
channelRetMsg.setChannelErrMsg(response.getMsg());
|
||||
}
|
||||
}
|
||||
} catch (JeepayException e) {
|
||||
channelRetMsg.setChannelState(ChannelRetMsg.ChannelState.CONFIRM_FAIL);
|
||||
}
|
||||
return channelRetMsg;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelRetMsg query(RefundOrder refundOrder, MchAppConfigContext mchAppConfigContext) throws Exception {
|
||||
RefundOrderQueryRequest request = new RefundOrderQueryRequest();
|
||||
RefundOrderQueryReqModel model = new RefundOrderQueryReqModel();
|
||||
try {
|
||||
JeepluspayNormalMchParams normalMchParams = (JeepluspayNormalMchParams) configContextQueryService.queryNormalMchParams(mchAppConfigContext.getMchNo(), mchAppConfigContext.getAppId(), CS.IF_CODE.JEEPLUSPAY);
|
||||
model.setMchNo(normalMchParams.getMerchantNo()); // 商户号
|
||||
model.setAppId(normalMchParams.getAppId()); // 应用ID
|
||||
model.setRefundOrderId(refundOrder.getRefundOrderId()); // 退款订单号
|
||||
request.setBizModel(model);
|
||||
// 发起请求
|
||||
RefundOrderQueryResponse response = new RefundOrderQueryResponse();
|
||||
boolean checkSign = false;
|
||||
boolean isSuccess = false;
|
||||
if (normalMchParams.getSignType().equals(JeepluspayConfig.DEFAULT_SIGN_TYPE) || StringUtils.isEmpty(normalMchParams.getSignType())) {
|
||||
JeepayClient jeepayClient = JeepayClient.getInstance(normalMchParams.getAppId(), normalMchParams.getAppSecret(), Jeepay.getApiBase());
|
||||
response = jeepayClient.execute(request);
|
||||
checkSign = response.checkSign(normalMchParams.getAppSecret());
|
||||
isSuccess = response.isSuccessByRsa2(normalMchParams.getRsa2PayPublicKey());
|
||||
} else if (normalMchParams.getSignType().equals(JeepluspayConfig.SIGN_TYPE_RSA2)) {
|
||||
JeepayClient jeepayClient = JeepayClient.getInstance(normalMchParams.getAppId(), normalMchParams.getRsa2AppPrivateKey(), Jeepay.getApiBase());
|
||||
response = jeepayClient.executeByRSA2(request);
|
||||
checkSign = response.checkSignByRsa2(normalMchParams.getRsa2PayPublicKey());
|
||||
isSuccess = response.isSuccessByRsa2(normalMchParams.getRsa2PayPublicKey());
|
||||
}
|
||||
|
||||
// 请求响应状态
|
||||
if (isSuccess && checkSign) {
|
||||
// 如果查询请求成功
|
||||
if (JeepluspayConfig.PAY_STATE_SUCCESS.equals(response.get().getState().toString())) {
|
||||
return ChannelRetMsg.confirmSuccess(response.get().getRefundOrderId());
|
||||
} else if (JeepluspayConfig.PAY_STATE_FAIL.equals(response.get().getState().toString())) {
|
||||
// 失败
|
||||
return ChannelRetMsg.confirmFail();
|
||||
}
|
||||
}
|
||||
// 退款中
|
||||
return ChannelRetMsg.waiting();
|
||||
} catch (Exception e) {
|
||||
// 退款中
|
||||
return ChannelRetMsg.waiting();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,115 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2031, 河北计全科技有限公司 (https://www.jeequan.com & jeequan@126.com).
|
||||
* <p>
|
||||
* 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
|
||||
* <p>
|
||||
* http://www.gnu.org/licenses/lgpl.html
|
||||
* <p>
|
||||
* 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.jeepluspay.payway;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.jeequan.jeepay.Jeepay;
|
||||
import com.jeequan.jeepay.JeepayClient;
|
||||
import com.jeequan.jeepay.core.constants.CS;
|
||||
import com.jeequan.jeepay.core.entity.PayOrder;
|
||||
import com.jeequan.jeepay.core.model.params.jeepluspay.JeepluspayConfig;
|
||||
import com.jeequan.jeepay.core.model.params.jeepluspay.JeepluspayNormalMchParams;
|
||||
import com.jeequan.jeepay.exception.JeepayException;
|
||||
import com.jeequan.jeepay.model.PayOrderCreateReqModel;
|
||||
import com.jeequan.jeepay.pay.channel.jeepluspay.JeepluspayPaymentService;
|
||||
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.AliAppOrderRS;
|
||||
import com.jeequan.jeepay.pay.util.ApiResBuilder;
|
||||
import com.jeequan.jeepay.request.PayOrderCreateRequest;
|
||||
import com.jeequan.jeepay.response.PayOrderCreateResponse;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/*
|
||||
* 计全付 支付宝 APP支付
|
||||
*
|
||||
* @author yr
|
||||
* @site https://www.jeequan.com
|
||||
* @date 2022/8/6 16:20
|
||||
*/
|
||||
@Service("jeepluspayPaymentByAliAppService") //Service Name需保持全局唯一性
|
||||
public class AliApp extends JeepluspayPaymentService {
|
||||
|
||||
@Override
|
||||
public String preCheck(UnifiedOrderRQ rq, PayOrder payOrder) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AbstractRS pay(UnifiedOrderRQ rq, PayOrder payOrder, MchAppConfigContext mchAppConfigContext) {
|
||||
JeepluspayNormalMchParams normalMchParams = (JeepluspayNormalMchParams) configContextQueryService.queryNormalMchParams(mchAppConfigContext.getMchNo(), mchAppConfigContext.getAppId(), CS.IF_CODE.JEEPLUSPAY);
|
||||
// 构建请求数据
|
||||
PayOrderCreateRequest request = new PayOrderCreateRequest();
|
||||
PayOrderCreateReqModel model = new PayOrderCreateReqModel();
|
||||
model.setMchNo(normalMchParams.getMerchantNo()); // 商户号
|
||||
model.setAppId(normalMchParams.getAppId()); // 应用ID
|
||||
model.setMchOrderNo(payOrder.getPayOrderId()); // 商户订单号
|
||||
model.setWayCode(JeepluspayConfig.ALI_APP); // 支付方式
|
||||
model.setAmount(payOrder.getAmount()); // 金额,单位分
|
||||
model.setCurrency(payOrder.getCurrency()); // 币种,目前只支持cny
|
||||
model.setClientIp(payOrder.getClientIp()); // 发起支付请求客户端的IP地址
|
||||
model.setSubject(payOrder.getSubject()); // 商品标题
|
||||
model.setBody(payOrder.getBody()); // 商品描述
|
||||
model.setNotifyUrl(getNotifyUrl()); // 异步通知地址
|
||||
JSONObject channelExtra = new JSONObject();
|
||||
channelExtra.put("payDataType", CS.PAY_DATA_TYPE.ALI_APP);
|
||||
model.setChannelExtra(channelExtra.toString()); // 支付宝app支付参数
|
||||
request.setBizModel(model);
|
||||
// 构造函数响应数据
|
||||
AliAppOrderRS res = ApiResBuilder.buildSuccess(AliAppOrderRS.class);
|
||||
ChannelRetMsg channelRetMsg = new ChannelRetMsg();
|
||||
res.setChannelRetMsg(channelRetMsg);
|
||||
try {
|
||||
// 发起统一下单
|
||||
PayOrderCreateResponse response = new PayOrderCreateResponse();
|
||||
boolean checkSign = false;
|
||||
boolean isSuccess = false;
|
||||
if (normalMchParams.getSignType().equals(JeepluspayConfig.DEFAULT_SIGN_TYPE) || StringUtils.isEmpty(normalMchParams.getSignType())) {
|
||||
JeepayClient jeepayClient = JeepayClient.getInstance(normalMchParams.getAppId(), normalMchParams.getAppSecret(), Jeepay.getApiBase());
|
||||
response = jeepayClient.execute(request);
|
||||
checkSign = response.checkSign(normalMchParams.getAppSecret());
|
||||
isSuccess = response.isSuccess(normalMchParams.getAppSecret());
|
||||
|
||||
} else if (normalMchParams.getSignType().equals(JeepluspayConfig.SIGN_TYPE_RSA2)) {
|
||||
JeepayClient jeepayClient = JeepayClient.getInstance(normalMchParams.getAppId(), normalMchParams.getRsa2AppPrivateKey(), Jeepay.getApiBase());
|
||||
response = jeepayClient.executeByRSA2(request);
|
||||
checkSign = response.checkSignByRsa2(normalMchParams.getRsa2PayPublicKey());
|
||||
isSuccess = response.isSuccessByRsa2(normalMchParams.getRsa2PayPublicKey());
|
||||
}
|
||||
|
||||
if (checkSign) {
|
||||
channelRetMsg.setChannelOrderId(response.get().getPayOrderId());
|
||||
if (isSuccess) {
|
||||
// 下单成功
|
||||
JSONObject payData = response.getData().getJSONObject("payData");
|
||||
res.setPayData(payData.toJSONString());
|
||||
channelRetMsg.setChannelAttach(payData.toJSONString());
|
||||
channelRetMsg.setChannelState(ChannelRetMsg.ChannelState.WAITING);
|
||||
} else {
|
||||
channelRetMsg.setChannelState(ChannelRetMsg.ChannelState.CONFIRM_FAIL);
|
||||
channelRetMsg.setChannelErrCode(response.get().getErrCode());
|
||||
channelRetMsg.setChannelErrMsg(response.get().getErrMsg());
|
||||
}
|
||||
}
|
||||
} catch (JeepayException e) {
|
||||
channelRetMsg.setChannelState(ChannelRetMsg.ChannelState.CONFIRM_FAIL);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
}
|
@ -0,0 +1,119 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2031, 河北计全科技有限公司 (https://www.jeequan.com & jeequan@126.com).
|
||||
* <p>
|
||||
* 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
|
||||
* <p>
|
||||
* http://www.gnu.org/licenses/lgpl.html
|
||||
* <p>
|
||||
* 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.jeepluspay.payway;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.jeequan.jeepay.Jeepay;
|
||||
import com.jeequan.jeepay.JeepayClient;
|
||||
import com.jeequan.jeepay.core.constants.CS;
|
||||
import com.jeequan.jeepay.core.entity.PayOrder;
|
||||
import com.jeequan.jeepay.core.exception.BizException;
|
||||
import com.jeequan.jeepay.core.model.params.jeepluspay.JeepluspayConfig;
|
||||
import com.jeequan.jeepay.core.model.params.jeepluspay.JeepluspayNormalMchParams;
|
||||
import com.jeequan.jeepay.exception.JeepayException;
|
||||
import com.jeequan.jeepay.model.PayOrderCreateReqModel;
|
||||
import com.jeequan.jeepay.pay.channel.jeepluspay.JeepluspayPaymentService;
|
||||
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 com.jeequan.jeepay.request.PayOrderCreateRequest;
|
||||
import com.jeequan.jeepay.response.PayOrderCreateResponse;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/*
|
||||
* 计全付 支付宝 条码支付
|
||||
*
|
||||
* @author yr
|
||||
* @site https://www.jeequan.com
|
||||
* @date 2022/8/11 15:37
|
||||
*/
|
||||
@Service("jeepluspayPaymentByAliBarService") //Service Name需保持全局唯一性
|
||||
public class AliBar extends JeepluspayPaymentService {
|
||||
|
||||
@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;
|
||||
JeepluspayNormalMchParams normalMchParams = (JeepluspayNormalMchParams) configContextQueryService.queryNormalMchParams(mchAppConfigContext.getMchNo(), mchAppConfigContext.getAppId(), CS.IF_CODE.JEEPLUSPAY);
|
||||
// 构建请求数据
|
||||
PayOrderCreateRequest request = new PayOrderCreateRequest();
|
||||
PayOrderCreateReqModel model = new PayOrderCreateReqModel();
|
||||
model.setMchNo(normalMchParams.getMerchantNo()); // 商户号
|
||||
model.setAppId(normalMchParams.getAppId()); // 应用ID
|
||||
model.setMchOrderNo(payOrder.getPayOrderId()); // 商户订单号
|
||||
model.setWayCode(JeepluspayConfig.ALI_BAR); // 支付方式
|
||||
model.setAmount(payOrder.getAmount()); // 金额,单位分
|
||||
model.setCurrency(payOrder.getCurrency()); // 币种,目前只支持cny
|
||||
model.setClientIp(payOrder.getClientIp()); // 发起支付请求客户端的IP地址
|
||||
model.setSubject(payOrder.getSubject()); // 商品标题
|
||||
model.setBody(payOrder.getBody()); // 商品描述
|
||||
model.setNotifyUrl(getNotifyUrl()); // 异步通知地址
|
||||
JSONObject channelExtra = new JSONObject();
|
||||
channelExtra.put("authCode", bizRQ.getAuthCode());
|
||||
model.setChannelExtra(channelExtra.toString()); // 用户付款码值
|
||||
request.setBizModel(model);
|
||||
// 构造函数响应数据
|
||||
AliBarOrderRS res = ApiResBuilder.buildSuccess(AliBarOrderRS.class);
|
||||
ChannelRetMsg channelRetMsg = new ChannelRetMsg();
|
||||
res.setChannelRetMsg(channelRetMsg);
|
||||
try {
|
||||
// 发起统一下单
|
||||
PayOrderCreateResponse response = new PayOrderCreateResponse();
|
||||
boolean checkSign = false;
|
||||
boolean isSuccess = false;
|
||||
if (normalMchParams.getSignType().equals(JeepluspayConfig.DEFAULT_SIGN_TYPE) || StringUtils.isEmpty(normalMchParams.getSignType())) {
|
||||
JeepayClient jeepayClient = JeepayClient.getInstance(normalMchParams.getAppId(), normalMchParams.getAppSecret(), Jeepay.getApiBase());
|
||||
response = jeepayClient.execute(request);
|
||||
checkSign = response.checkSign(normalMchParams.getAppSecret());
|
||||
isSuccess = response.isSuccess(normalMchParams.getAppSecret());
|
||||
|
||||
} else if (normalMchParams.getSignType().equals(JeepluspayConfig.SIGN_TYPE_RSA2)) {
|
||||
JeepayClient jeepayClient = JeepayClient.getInstance(normalMchParams.getAppId(), normalMchParams.getRsa2AppPrivateKey(), Jeepay.getApiBase());
|
||||
response = jeepayClient.executeByRSA2(request);
|
||||
checkSign = response.checkSignByRsa2(normalMchParams.getRsa2PayPublicKey());
|
||||
isSuccess = response.isSuccessByRsa2(normalMchParams.getRsa2PayPublicKey());
|
||||
}
|
||||
|
||||
if (checkSign) {
|
||||
channelRetMsg.setChannelOrderId(response.get().getPayOrderId());
|
||||
if (isSuccess) {
|
||||
// 下单成功
|
||||
channelRetMsg.setChannelState(ChannelRetMsg.ChannelState.CONFIRM_SUCCESS);
|
||||
} else {
|
||||
channelRetMsg.setChannelState(ChannelRetMsg.ChannelState.CONFIRM_FAIL);
|
||||
channelRetMsg.setChannelErrCode(response.get().getErrCode());
|
||||
channelRetMsg.setChannelErrMsg(response.get().getErrMsg());
|
||||
}
|
||||
}
|
||||
} catch (JeepayException e) {
|
||||
channelRetMsg.setChannelState(ChannelRetMsg.ChannelState.CONFIRM_FAIL);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
}
|
@ -0,0 +1,122 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2031, 河北计全科技有限公司 (https://www.jeequan.com & jeequan@126.com).
|
||||
* <p>
|
||||
* 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
|
||||
* <p>
|
||||
* http://www.gnu.org/licenses/lgpl.html
|
||||
* <p>
|
||||
* 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.jeepluspay.payway;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.jeequan.jeepay.Jeepay;
|
||||
import com.jeequan.jeepay.JeepayClient;
|
||||
import com.jeequan.jeepay.core.constants.CS;
|
||||
import com.jeequan.jeepay.core.entity.PayOrder;
|
||||
import com.jeequan.jeepay.core.exception.BizException;
|
||||
import com.jeequan.jeepay.core.model.params.jeepluspay.JeepluspayConfig;
|
||||
import com.jeequan.jeepay.core.model.params.jeepluspay.JeepluspayNormalMchParams;
|
||||
import com.jeequan.jeepay.exception.JeepayException;
|
||||
import com.jeequan.jeepay.model.PayOrderCreateReqModel;
|
||||
import com.jeequan.jeepay.pay.channel.jeepluspay.JeepluspayPaymentService;
|
||||
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.AliJsapiOrderRQ;
|
||||
import com.jeequan.jeepay.pay.rqrs.payorder.payway.AliJsapiOrderRS;
|
||||
import com.jeequan.jeepay.pay.util.ApiResBuilder;
|
||||
import com.jeequan.jeepay.request.PayOrderCreateRequest;
|
||||
import com.jeequan.jeepay.response.PayOrderCreateResponse;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/*
|
||||
* 计全付 支付宝 jsapi支付
|
||||
*
|
||||
* @author yr
|
||||
* @site https://www.jeequan.com
|
||||
* @date 2022/8/15 09:46
|
||||
*/
|
||||
@Service("jeepluspayPaymentByAliJsapiService") //Service Name需保持全局唯一性
|
||||
public class AliJsapi extends JeepluspayPaymentService {
|
||||
|
||||
@Override
|
||||
public String preCheck(UnifiedOrderRQ rq, PayOrder payOrder) {
|
||||
AliJsapiOrderRQ bizRQ = (AliJsapiOrderRQ) rq;
|
||||
if (StringUtils.isEmpty(bizRQ.getBuyerUserId())) {
|
||||
throw new BizException("[buyerUserId]不可为空");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AbstractRS pay(UnifiedOrderRQ rq, PayOrder payOrder, MchAppConfigContext mchAppConfigContext) throws Exception {
|
||||
AliJsapiOrderRQ bizRQ = (AliJsapiOrderRQ) rq;
|
||||
JeepluspayNormalMchParams normalMchParams = (JeepluspayNormalMchParams) configContextQueryService.queryNormalMchParams(mchAppConfigContext.getMchNo(), mchAppConfigContext.getAppId(), CS.IF_CODE.JEEPLUSPAY);
|
||||
// 构建请求数据
|
||||
PayOrderCreateRequest request = new PayOrderCreateRequest();
|
||||
PayOrderCreateReqModel model = new PayOrderCreateReqModel();
|
||||
model.setMchNo(normalMchParams.getMerchantNo()); // 商户号
|
||||
model.setAppId(normalMchParams.getAppId()); // 应用ID
|
||||
model.setMchOrderNo(payOrder.getPayOrderId()); // 商户订单号
|
||||
model.setWayCode(JeepluspayConfig.ALI_JSAPI); // 支付方式
|
||||
model.setAmount(payOrder.getAmount()); // 金额,单位分
|
||||
model.setCurrency(payOrder.getCurrency()); // 币种,目前只支持cny
|
||||
model.setClientIp(payOrder.getClientIp()); // 发起支付请求客户端的IP地址
|
||||
model.setSubject(payOrder.getSubject()); // 商品标题
|
||||
model.setBody(payOrder.getBody()); // 商品描述
|
||||
model.setNotifyUrl(getNotifyUrl()); // 异步通知地址
|
||||
JSONObject channelExtra = new JSONObject();
|
||||
channelExtra.put("buyerUserId", bizRQ.getBuyerUserId());
|
||||
model.setChannelExtra(channelExtra.toString()); // 支付宝用户ID
|
||||
request.setBizModel(model);
|
||||
// 构造函数响应数据
|
||||
AliJsapiOrderRS res = ApiResBuilder.buildSuccess(AliJsapiOrderRS.class);
|
||||
ChannelRetMsg channelRetMsg = new ChannelRetMsg();
|
||||
res.setChannelRetMsg(channelRetMsg);
|
||||
try {
|
||||
// 发起统一下单
|
||||
PayOrderCreateResponse response = new PayOrderCreateResponse();
|
||||
boolean checkSign = false;
|
||||
boolean isSuccess = false;
|
||||
if (normalMchParams.getSignType().equals(JeepluspayConfig.DEFAULT_SIGN_TYPE) || StringUtils.isEmpty(normalMchParams.getSignType())) {
|
||||
JeepayClient jeepayClient = JeepayClient.getInstance(normalMchParams.getAppId(), normalMchParams.getAppSecret(), Jeepay.getApiBase());
|
||||
response = jeepayClient.execute(request);
|
||||
checkSign = response.checkSign(normalMchParams.getAppSecret());
|
||||
isSuccess = response.isSuccess(normalMchParams.getAppSecret());
|
||||
|
||||
} else if (normalMchParams.getSignType().equals(JeepluspayConfig.SIGN_TYPE_RSA2)) {
|
||||
JeepayClient jeepayClient = JeepayClient.getInstance(normalMchParams.getAppId(), normalMchParams.getRsa2AppPrivateKey(), Jeepay.getApiBase());
|
||||
response = jeepayClient.executeByRSA2(request);
|
||||
checkSign = response.checkSignByRsa2(normalMchParams.getRsa2PayPublicKey());
|
||||
isSuccess = response.isSuccessByRsa2(normalMchParams.getRsa2PayPublicKey());
|
||||
}
|
||||
|
||||
if (checkSign) {
|
||||
channelRetMsg.setChannelOrderId(response.get().getPayOrderId());
|
||||
if (isSuccess) {
|
||||
// 下单成功
|
||||
JSONObject payData = response.getData().getJSONObject("payData");
|
||||
res.setAlipayTradeNo(payData.getString("alipayTradeNo"));
|
||||
res.setPayData(payData.toJSONString());
|
||||
channelRetMsg.setChannelState(ChannelRetMsg.ChannelState.WAITING);
|
||||
} else {
|
||||
channelRetMsg.setChannelState(ChannelRetMsg.ChannelState.CONFIRM_FAIL);
|
||||
channelRetMsg.setChannelErrCode(response.get().getErrCode());
|
||||
channelRetMsg.setChannelErrMsg(response.get().getErrMsg());
|
||||
}
|
||||
}
|
||||
} catch (JeepayException e) {
|
||||
channelRetMsg.setChannelState(ChannelRetMsg.ChannelState.CONFIRM_FAIL);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
}
|
@ -0,0 +1,122 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2031, 河北计全科技有限公司 (https://www.jeequan.com & jeequan@126.com).
|
||||
* <p>
|
||||
* 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
|
||||
* <p>
|
||||
* http://www.gnu.org/licenses/lgpl.html
|
||||
* <p>
|
||||
* 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.jeepluspay.payway;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.jeequan.jeepay.Jeepay;
|
||||
import com.jeequan.jeepay.JeepayClient;
|
||||
import com.jeequan.jeepay.core.constants.CS;
|
||||
import com.jeequan.jeepay.core.entity.PayOrder;
|
||||
import com.jeequan.jeepay.core.exception.BizException;
|
||||
import com.jeequan.jeepay.core.model.params.jeepluspay.JeepluspayConfig;
|
||||
import com.jeequan.jeepay.core.model.params.jeepluspay.JeepluspayNormalMchParams;
|
||||
import com.jeequan.jeepay.exception.JeepayException;
|
||||
import com.jeequan.jeepay.model.PayOrderCreateReqModel;
|
||||
import com.jeequan.jeepay.pay.channel.jeepluspay.JeepluspayPaymentService;
|
||||
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.AliLiteOrderRQ;
|
||||
import com.jeequan.jeepay.pay.rqrs.payorder.payway.AliLiteOrderRS;
|
||||
import com.jeequan.jeepay.pay.util.ApiResBuilder;
|
||||
import com.jeequan.jeepay.request.PayOrderCreateRequest;
|
||||
import com.jeequan.jeepay.response.PayOrderCreateResponse;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/*
|
||||
* 计全付 支付宝 小程序支付
|
||||
*
|
||||
* @author yr
|
||||
* @site https://www.jeequan.com
|
||||
* @date 2022/8/17 17:24
|
||||
*/
|
||||
@Service("jeepluspayPaymentByAliLiteService") //Service Name需保持全局唯一性
|
||||
public class AliLite extends JeepluspayPaymentService {
|
||||
|
||||
@Override
|
||||
public String preCheck(UnifiedOrderRQ rq, PayOrder payOrder) {
|
||||
AliLiteOrderRQ bizRQ = (AliLiteOrderRQ) rq;
|
||||
if (StringUtils.isEmpty(bizRQ.getBuyerUserId())) {
|
||||
throw new BizException("[buyerUserId]不可为空");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AbstractRS pay(UnifiedOrderRQ rq, PayOrder payOrder, MchAppConfigContext mchAppConfigContext) throws Exception {
|
||||
AliLiteOrderRQ bizRQ = (AliLiteOrderRQ) rq;
|
||||
JeepluspayNormalMchParams normalMchParams = (JeepluspayNormalMchParams) configContextQueryService.queryNormalMchParams(mchAppConfigContext.getMchNo(), mchAppConfigContext.getAppId(), CS.IF_CODE.JEEPLUSPAY);
|
||||
// 构建请求数据
|
||||
PayOrderCreateRequest request = new PayOrderCreateRequest();
|
||||
PayOrderCreateReqModel model = new PayOrderCreateReqModel();
|
||||
model.setMchNo(normalMchParams.getMerchantNo()); // 商户号
|
||||
model.setAppId(normalMchParams.getAppId()); // 应用ID
|
||||
model.setMchOrderNo(payOrder.getPayOrderId()); // 商户订单号
|
||||
model.setWayCode(JeepluspayConfig.WX_LITE); // 支付方式
|
||||
model.setAmount(payOrder.getAmount()); // 金额,单位分
|
||||
model.setCurrency(payOrder.getCurrency()); // 币种,目前只支持cny
|
||||
model.setClientIp(payOrder.getClientIp()); // 发起支付请求客户端的IP地址
|
||||
model.setSubject(payOrder.getSubject()); // 商品标题
|
||||
model.setBody(payOrder.getBody()); // 商品描述
|
||||
model.setNotifyUrl(getNotifyUrl()); // 异步通知地址
|
||||
JSONObject channelExtra = new JSONObject();
|
||||
channelExtra.put("buyerUserId", bizRQ.getBuyerUserId());
|
||||
model.setChannelExtra(channelExtra.toString()); // 支付宝用户ID
|
||||
request.setBizModel(model);
|
||||
// 构造函数响应数据
|
||||
AliLiteOrderRS res = ApiResBuilder.buildSuccess(AliLiteOrderRS.class);
|
||||
ChannelRetMsg channelRetMsg = new ChannelRetMsg();
|
||||
res.setChannelRetMsg(channelRetMsg);
|
||||
try {
|
||||
// 发起统一下单
|
||||
PayOrderCreateResponse response = new PayOrderCreateResponse();
|
||||
boolean checkSign = false;
|
||||
boolean isSuccess = false;
|
||||
if (normalMchParams.getSignType().equals(JeepluspayConfig.DEFAULT_SIGN_TYPE) || StringUtils.isEmpty(normalMchParams.getSignType())) {
|
||||
JeepayClient jeepayClient = JeepayClient.getInstance(normalMchParams.getAppId(), normalMchParams.getAppSecret(), Jeepay.getApiBase());
|
||||
response = jeepayClient.execute(request);
|
||||
checkSign = response.checkSign(normalMchParams.getAppSecret());
|
||||
isSuccess = response.isSuccess(normalMchParams.getAppSecret());
|
||||
|
||||
} else if (normalMchParams.getSignType().equals(JeepluspayConfig.SIGN_TYPE_RSA2)) {
|
||||
JeepayClient jeepayClient = JeepayClient.getInstance(normalMchParams.getAppId(), normalMchParams.getRsa2AppPrivateKey(), Jeepay.getApiBase());
|
||||
response = jeepayClient.executeByRSA2(request);
|
||||
checkSign = response.checkSignByRsa2(normalMchParams.getRsa2PayPublicKey());
|
||||
isSuccess = response.isSuccessByRsa2(normalMchParams.getRsa2PayPublicKey());
|
||||
}
|
||||
|
||||
if (checkSign) {
|
||||
channelRetMsg.setChannelOrderId(response.get().getPayOrderId());
|
||||
if (isSuccess) {
|
||||
// 下单成功
|
||||
JSONObject payData = response.getData().getJSONObject("payData");
|
||||
res.setAlipayTradeNo(payData.getString("alipayTradeNo"));
|
||||
res.setPayData(payData.toJSONString());
|
||||
channelRetMsg.setChannelState(ChannelRetMsg.ChannelState.WAITING);
|
||||
} else {
|
||||
channelRetMsg.setChannelState(ChannelRetMsg.ChannelState.CONFIRM_FAIL);
|
||||
channelRetMsg.setChannelErrCode(response.get().getErrCode());
|
||||
channelRetMsg.setChannelErrMsg(response.get().getErrMsg());
|
||||
}
|
||||
}
|
||||
} catch (JeepayException e) {
|
||||
channelRetMsg.setChannelState(ChannelRetMsg.ChannelState.CONFIRM_FAIL);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
}
|
@ -0,0 +1,117 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2031, 河北计全科技有限公司 (https://www.jeequan.com & jeequan@126.com).
|
||||
* <p>
|
||||
* 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
|
||||
* <p>
|
||||
* http://www.gnu.org/licenses/lgpl.html
|
||||
* <p>
|
||||
* 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.jeepluspay.payway;
|
||||
|
||||
import com.jeequan.jeepay.Jeepay;
|
||||
import com.jeequan.jeepay.JeepayClient;
|
||||
import com.jeequan.jeepay.core.constants.CS;
|
||||
import com.jeequan.jeepay.core.entity.PayOrder;
|
||||
import com.jeequan.jeepay.core.model.params.jeepluspay.JeepluspayConfig;
|
||||
import com.jeequan.jeepay.core.model.params.jeepluspay.JeepluspayNormalMchParams;
|
||||
import com.jeequan.jeepay.exception.JeepayException;
|
||||
import com.jeequan.jeepay.model.PayOrderCreateReqModel;
|
||||
import com.jeequan.jeepay.pay.channel.jeepluspay.JeepluspayPaymentService;
|
||||
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.AliPcOrderRS;
|
||||
import com.jeequan.jeepay.pay.util.ApiResBuilder;
|
||||
import com.jeequan.jeepay.request.PayOrderCreateRequest;
|
||||
import com.jeequan.jeepay.response.PayOrderCreateResponse;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/*
|
||||
* 计全付 支付宝 PC支付
|
||||
*
|
||||
* @author yr
|
||||
* @site https://www.jeequan.com
|
||||
* @date 2022/8/17 14:51
|
||||
*/
|
||||
@Service("jeepluspayPaymentByAliPcService") //Service Name需保持全局唯一性
|
||||
public class AliPc extends JeepluspayPaymentService {
|
||||
|
||||
@Override
|
||||
public String preCheck(UnifiedOrderRQ rq, PayOrder payOrder) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AbstractRS pay(UnifiedOrderRQ rq, PayOrder payOrder, MchAppConfigContext mchAppConfigContext) {
|
||||
JeepluspayNormalMchParams normalMchParams = (JeepluspayNormalMchParams) configContextQueryService.queryNormalMchParams(mchAppConfigContext.getMchNo(), mchAppConfigContext.getAppId(), CS.IF_CODE.JEEPLUSPAY);
|
||||
// 构建请求数据
|
||||
PayOrderCreateRequest request = new PayOrderCreateRequest();
|
||||
PayOrderCreateReqModel model = new PayOrderCreateReqModel();
|
||||
model.setMchNo(normalMchParams.getMerchantNo()); // 商户号
|
||||
model.setAppId(normalMchParams.getAppId()); // 应用ID
|
||||
model.setMchOrderNo(payOrder.getPayOrderId()); // 商户订单号
|
||||
model.setWayCode(JeepluspayConfig.ALI_PC); // 支付方式
|
||||
model.setAmount(payOrder.getAmount()); // 金额,单位分
|
||||
model.setCurrency(payOrder.getCurrency()); // 币种,目前只支持cny
|
||||
model.setClientIp(payOrder.getClientIp()); // 发起支付请求客户端的IP地址
|
||||
model.setSubject(payOrder.getSubject()); // 商品标题
|
||||
model.setBody(payOrder.getBody()); // 商品描述
|
||||
model.setNotifyUrl(getNotifyUrl()); // 异步通知地址
|
||||
request.setBizModel(model);
|
||||
// 构造函数响应数据
|
||||
AliPcOrderRS res = ApiResBuilder.buildSuccess(AliPcOrderRS.class);
|
||||
ChannelRetMsg channelRetMsg = new ChannelRetMsg();
|
||||
res.setChannelRetMsg(channelRetMsg);
|
||||
try {
|
||||
// 发起统一下单
|
||||
PayOrderCreateResponse response = new PayOrderCreateResponse();
|
||||
boolean checkSign = false;
|
||||
boolean isSuccess = false;
|
||||
if (normalMchParams.getSignType().equals(JeepluspayConfig.DEFAULT_SIGN_TYPE) || StringUtils.isEmpty(normalMchParams.getSignType())) {
|
||||
JeepayClient jeepayClient = JeepayClient.getInstance(normalMchParams.getAppId(), normalMchParams.getAppSecret(), Jeepay.getApiBase());
|
||||
response = jeepayClient.execute(request);
|
||||
checkSign = response.checkSign(normalMchParams.getAppSecret());
|
||||
isSuccess = response.isSuccess(normalMchParams.getAppSecret());
|
||||
|
||||
} else if (normalMchParams.getSignType().equals(JeepluspayConfig.SIGN_TYPE_RSA2)) {
|
||||
JeepayClient jeepayClient = JeepayClient.getInstance(normalMchParams.getAppId(), normalMchParams.getRsa2AppPrivateKey(), Jeepay.getApiBase());
|
||||
response = jeepayClient.executeByRSA2(request);
|
||||
checkSign = response.checkSignByRsa2(normalMchParams.getRsa2PayPublicKey());
|
||||
isSuccess = response.isSuccessByRsa2(normalMchParams.getRsa2PayPublicKey());
|
||||
}
|
||||
|
||||
if (checkSign) {
|
||||
channelRetMsg.setChannelOrderId(response.get().getPayOrderId());
|
||||
if (isSuccess) {
|
||||
// 下单成功
|
||||
String payUrl = response.getData().getString("payData");
|
||||
String payDataType = response.getData().getString("payDataType");
|
||||
if (CS.PAY_DATA_TYPE.FORM.equals(payDataType)) { //表单方式
|
||||
res.setFormContent(payUrl);
|
||||
} else if (CS.PAY_DATA_TYPE.CODE_IMG_URL.equals(payDataType)) { //二维码图片地址
|
||||
res.setCodeImgUrl(payUrl);
|
||||
} else { // 默认都为 payUrl方式
|
||||
res.setPayUrl(payUrl);
|
||||
}
|
||||
channelRetMsg.setChannelState(ChannelRetMsg.ChannelState.WAITING);
|
||||
} else {
|
||||
channelRetMsg.setChannelState(ChannelRetMsg.ChannelState.CONFIRM_FAIL);
|
||||
channelRetMsg.setChannelErrCode(response.get().getErrCode());
|
||||
channelRetMsg.setChannelErrMsg(response.get().getErrMsg());
|
||||
}
|
||||
}
|
||||
} catch (JeepayException e) {
|
||||
channelRetMsg.setChannelState(ChannelRetMsg.ChannelState.CONFIRM_FAIL);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
}
|
@ -0,0 +1,116 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2031, 河北计全科技有限公司 (https://www.jeequan.com & jeequan@126.com).
|
||||
* <p>
|
||||
* 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
|
||||
* <p>
|
||||
* http://www.gnu.org/licenses/lgpl.html
|
||||
* <p>
|
||||
* 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.jeepluspay.payway;
|
||||
|
||||
import com.jeequan.jeepay.Jeepay;
|
||||
import com.jeequan.jeepay.JeepayClient;
|
||||
import com.jeequan.jeepay.core.constants.CS;
|
||||
import com.jeequan.jeepay.core.entity.PayOrder;
|
||||
import com.jeequan.jeepay.core.model.params.jeepluspay.JeepluspayConfig;
|
||||
import com.jeequan.jeepay.core.model.params.jeepluspay.JeepluspayNormalMchParams;
|
||||
import com.jeequan.jeepay.exception.JeepayException;
|
||||
import com.jeequan.jeepay.model.PayOrderCreateReqModel;
|
||||
import com.jeequan.jeepay.pay.channel.jeepluspay.JeepluspayPaymentService;
|
||||
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.AliQrOrderRQ;
|
||||
import com.jeequan.jeepay.pay.rqrs.payorder.payway.AliQrOrderRS;
|
||||
import com.jeequan.jeepay.pay.util.ApiResBuilder;
|
||||
import com.jeequan.jeepay.request.PayOrderCreateRequest;
|
||||
import com.jeequan.jeepay.response.PayOrderCreateResponse;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/*
|
||||
* 计全付 支付宝 二维码支付
|
||||
*
|
||||
* @author yr
|
||||
* @site https://www.jeequan.com
|
||||
* @date 2022/8/15 09:46
|
||||
*/
|
||||
@Service("jeepluspayPaymentByAliQrService") //Service Name需保持全局唯一性
|
||||
public class AliQr extends JeepluspayPaymentService {
|
||||
|
||||
@Override
|
||||
public String preCheck(UnifiedOrderRQ rq, PayOrder payOrder) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AbstractRS pay(UnifiedOrderRQ rq, PayOrder payOrder, MchAppConfigContext mchAppConfigContext) throws Exception {
|
||||
AliQrOrderRQ aliQrOrderRQ = (AliQrOrderRQ) rq;
|
||||
JeepluspayNormalMchParams normalMchParams = (JeepluspayNormalMchParams) configContextQueryService.queryNormalMchParams(mchAppConfigContext.getMchNo(), mchAppConfigContext.getAppId(), CS.IF_CODE.JEEPLUSPAY);
|
||||
// 构建请求数据
|
||||
PayOrderCreateRequest request = new PayOrderCreateRequest();
|
||||
PayOrderCreateReqModel model = new PayOrderCreateReqModel();
|
||||
model.setMchNo(normalMchParams.getMerchantNo()); // 商户号
|
||||
model.setAppId(normalMchParams.getAppId()); // 应用ID
|
||||
model.setMchOrderNo(payOrder.getPayOrderId()); // 商户订单号
|
||||
model.setWayCode(JeepluspayConfig.ALI_QR); // 支付方式
|
||||
model.setAmount(payOrder.getAmount()); // 金额,单位分
|
||||
model.setCurrency(payOrder.getCurrency()); // 币种,目前只支持cny
|
||||
model.setClientIp(payOrder.getClientIp()); // 发起支付请求客户端的IP地址
|
||||
model.setSubject(payOrder.getSubject()); // 商品标题
|
||||
model.setBody(payOrder.getBody()); // 商品描述
|
||||
model.setNotifyUrl(getNotifyUrl()); // 异步通知地址
|
||||
request.setBizModel(model);
|
||||
// 构造函数响应数据
|
||||
AliQrOrderRS res = ApiResBuilder.buildSuccess(AliQrOrderRS.class);
|
||||
ChannelRetMsg channelRetMsg = new ChannelRetMsg();
|
||||
res.setChannelRetMsg(channelRetMsg);
|
||||
try {
|
||||
// 发起统一下单
|
||||
PayOrderCreateResponse response = new PayOrderCreateResponse();
|
||||
boolean checkSign = false;
|
||||
boolean isSuccess = false;
|
||||
if (normalMchParams.getSignType().equals(JeepluspayConfig.DEFAULT_SIGN_TYPE) || StringUtils.isEmpty(normalMchParams.getSignType())) {
|
||||
JeepayClient jeepayClient = JeepayClient.getInstance(normalMchParams.getAppId(), normalMchParams.getAppSecret(), Jeepay.getApiBase());
|
||||
response = jeepayClient.execute(request);
|
||||
checkSign = response.checkSign(normalMchParams.getAppSecret());
|
||||
isSuccess = response.isSuccess(normalMchParams.getAppSecret());
|
||||
|
||||
} else if (normalMchParams.getSignType().equals(JeepluspayConfig.SIGN_TYPE_RSA2)) {
|
||||
JeepayClient jeepayClient = JeepayClient.getInstance(normalMchParams.getAppId(), normalMchParams.getRsa2AppPrivateKey(), Jeepay.getApiBase());
|
||||
response = jeepayClient.executeByRSA2(request);
|
||||
checkSign = response.checkSignByRsa2(normalMchParams.getRsa2PayPublicKey());
|
||||
isSuccess = response.isSuccessByRsa2(normalMchParams.getRsa2PayPublicKey());
|
||||
}
|
||||
|
||||
if (checkSign) {
|
||||
channelRetMsg.setChannelOrderId(response.get().getPayOrderId());
|
||||
if (isSuccess) {
|
||||
// 下单成功
|
||||
// 二维码图片地址
|
||||
if (CS.PAY_DATA_TYPE.CODE_IMG_URL.equals(aliQrOrderRQ.getPayDataType())) {
|
||||
res.setCodeImgUrl(sysConfigService.getDBApplicationConfig().genScanImgUrl(response.get().getPayData()));
|
||||
} else {
|
||||
res.setCodeUrl(response.get().getPayData());
|
||||
}
|
||||
channelRetMsg.setChannelState(ChannelRetMsg.ChannelState.WAITING);
|
||||
} else {
|
||||
channelRetMsg.setChannelState(ChannelRetMsg.ChannelState.CONFIRM_FAIL);
|
||||
channelRetMsg.setChannelErrCode(response.get().getErrCode());
|
||||
channelRetMsg.setChannelErrMsg(response.get().getErrMsg());
|
||||
}
|
||||
}
|
||||
} catch (JeepayException e) {
|
||||
channelRetMsg.setChannelState(ChannelRetMsg.ChannelState.CONFIRM_FAIL);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
}
|
@ -0,0 +1,117 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2031, 河北计全科技有限公司 (https://www.jeequan.com & jeequan@126.com).
|
||||
* <p>
|
||||
* 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
|
||||
* <p>
|
||||
* http://www.gnu.org/licenses/lgpl.html
|
||||
* <p>
|
||||
* 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.jeepluspay.payway;
|
||||
|
||||
import com.jeequan.jeepay.Jeepay;
|
||||
import com.jeequan.jeepay.JeepayClient;
|
||||
import com.jeequan.jeepay.core.constants.CS;
|
||||
import com.jeequan.jeepay.core.entity.PayOrder;
|
||||
import com.jeequan.jeepay.core.model.params.jeepluspay.JeepluspayConfig;
|
||||
import com.jeequan.jeepay.core.model.params.jeepluspay.JeepluspayNormalMchParams;
|
||||
import com.jeequan.jeepay.exception.JeepayException;
|
||||
import com.jeequan.jeepay.model.PayOrderCreateReqModel;
|
||||
import com.jeequan.jeepay.pay.channel.jeepluspay.JeepluspayPaymentService;
|
||||
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.AliWapOrderRS;
|
||||
import com.jeequan.jeepay.pay.util.ApiResBuilder;
|
||||
import com.jeequan.jeepay.request.PayOrderCreateRequest;
|
||||
import com.jeequan.jeepay.response.PayOrderCreateResponse;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/*
|
||||
* 计全付 支付宝 wap支付
|
||||
*
|
||||
* @author yr
|
||||
* @site https://www.jeequan.com
|
||||
* @date 2022/8/17 14:46
|
||||
*/
|
||||
@Service("jeepluspayPaymentByAliWapService") //Service Name需保持全局唯一性
|
||||
public class AliWap extends JeepluspayPaymentService {
|
||||
|
||||
@Override
|
||||
public String preCheck(UnifiedOrderRQ rq, PayOrder payOrder) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AbstractRS pay(UnifiedOrderRQ rq, PayOrder payOrder, MchAppConfigContext mchAppConfigContext) {
|
||||
JeepluspayNormalMchParams normalMchParams = (JeepluspayNormalMchParams) configContextQueryService.queryNormalMchParams(mchAppConfigContext.getMchNo(), mchAppConfigContext.getAppId(), CS.IF_CODE.JEEPLUSPAY);
|
||||
// 构建请求数据
|
||||
PayOrderCreateRequest request = new PayOrderCreateRequest();
|
||||
PayOrderCreateReqModel model = new PayOrderCreateReqModel();
|
||||
model.setMchNo(normalMchParams.getMerchantNo()); // 商户号
|
||||
model.setAppId(normalMchParams.getAppId()); // 应用ID
|
||||
model.setMchOrderNo(payOrder.getPayOrderId()); // 商户订单号
|
||||
model.setWayCode(JeepluspayConfig.ALI_WAP); // 支付方式
|
||||
model.setAmount(payOrder.getAmount()); // 金额,单位分
|
||||
model.setCurrency(payOrder.getCurrency()); // 币种,目前只支持cny
|
||||
model.setClientIp(payOrder.getClientIp()); // 发起支付请求客户端的IP地址
|
||||
model.setSubject(payOrder.getSubject()); // 商品标题
|
||||
model.setBody(payOrder.getBody()); // 商品描述
|
||||
model.setNotifyUrl(getNotifyUrl()); // 异步通知地址
|
||||
request.setBizModel(model);
|
||||
// 构造函数响应数据
|
||||
AliWapOrderRS res = ApiResBuilder.buildSuccess(AliWapOrderRS.class);
|
||||
ChannelRetMsg channelRetMsg = new ChannelRetMsg();
|
||||
res.setChannelRetMsg(channelRetMsg);
|
||||
try {
|
||||
// 发起统一下单
|
||||
PayOrderCreateResponse response = new PayOrderCreateResponse();
|
||||
boolean checkSign = false;
|
||||
boolean isSuccess = false;
|
||||
if (normalMchParams.getSignType().equals(JeepluspayConfig.DEFAULT_SIGN_TYPE) || StringUtils.isEmpty(normalMchParams.getSignType())) {
|
||||
JeepayClient jeepayClient = JeepayClient.getInstance(normalMchParams.getAppId(), normalMchParams.getAppSecret(), Jeepay.getApiBase());
|
||||
response = jeepayClient.execute(request);
|
||||
checkSign = response.checkSign(normalMchParams.getAppSecret());
|
||||
isSuccess = response.isSuccess(normalMchParams.getAppSecret());
|
||||
|
||||
} else if (normalMchParams.getSignType().equals(JeepluspayConfig.SIGN_TYPE_RSA2)) {
|
||||
JeepayClient jeepayClient = JeepayClient.getInstance(normalMchParams.getAppId(), normalMchParams.getRsa2AppPrivateKey(), Jeepay.getApiBase());
|
||||
response = jeepayClient.executeByRSA2(request);
|
||||
checkSign = response.checkSignByRsa2(normalMchParams.getRsa2PayPublicKey());
|
||||
isSuccess = response.isSuccessByRsa2(normalMchParams.getRsa2PayPublicKey());
|
||||
}
|
||||
|
||||
if (checkSign) {
|
||||
channelRetMsg.setChannelOrderId(response.get().getPayOrderId());
|
||||
if (isSuccess) {
|
||||
// 下单成功
|
||||
String payUrl = response.getData().getString("payData");
|
||||
String payDataType = response.getData().getString("payDataType");
|
||||
if (CS.PAY_DATA_TYPE.FORM.equals(payDataType)) { //表单方式
|
||||
res.setFormContent(payUrl);
|
||||
} else if (CS.PAY_DATA_TYPE.CODE_IMG_URL.equals(payDataType)) { //二维码图片地址
|
||||
res.setCodeImgUrl(payUrl);
|
||||
} else { // 默认都为 payUrl方式
|
||||
res.setPayUrl(payUrl);
|
||||
}
|
||||
channelRetMsg.setChannelState(ChannelRetMsg.ChannelState.WAITING);
|
||||
} else {
|
||||
channelRetMsg.setChannelState(ChannelRetMsg.ChannelState.CONFIRM_FAIL);
|
||||
channelRetMsg.setChannelErrCode(response.get().getErrCode());
|
||||
channelRetMsg.setChannelErrMsg(response.get().getErrMsg());
|
||||
}
|
||||
}
|
||||
} catch (JeepayException e) {
|
||||
channelRetMsg.setChannelState(ChannelRetMsg.ChannelState.CONFIRM_FAIL);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
}
|
@ -0,0 +1,116 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2031, 河北计全科技有限公司 (https://www.jeequan.com & jeequan@126.com).
|
||||
* <p>
|
||||
* 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
|
||||
* <p>
|
||||
* http://www.gnu.org/licenses/lgpl.html
|
||||
* <p>
|
||||
* 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.jeepluspay.payway;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.jeequan.jeepay.Jeepay;
|
||||
import com.jeequan.jeepay.JeepayClient;
|
||||
import com.jeequan.jeepay.core.constants.CS;
|
||||
import com.jeequan.jeepay.core.entity.PayOrder;
|
||||
import com.jeequan.jeepay.core.model.params.jeepluspay.JeepluspayConfig;
|
||||
import com.jeequan.jeepay.core.model.params.jeepluspay.JeepluspayNormalMchParams;
|
||||
import com.jeequan.jeepay.exception.JeepayException;
|
||||
import com.jeequan.jeepay.model.PayOrderCreateReqModel;
|
||||
import com.jeequan.jeepay.pay.channel.jeepluspay.JeepluspayPaymentService;
|
||||
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.WxAppOrderRS;
|
||||
import com.jeequan.jeepay.pay.util.ApiResBuilder;
|
||||
import com.jeequan.jeepay.request.PayOrderCreateRequest;
|
||||
import com.jeequan.jeepay.response.PayOrderCreateResponse;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/*
|
||||
* 计全付 微信 app支付
|
||||
*
|
||||
* @author yr
|
||||
* @site https://www.jeequan.com
|
||||
* @date 2022/8/17 15:50
|
||||
*/
|
||||
@Service("jeepluspayPaymentByWxAppService") //Service Name需保持全局唯一性
|
||||
public class WxApp extends JeepluspayPaymentService {
|
||||
|
||||
@Override
|
||||
public String preCheck(UnifiedOrderRQ rq, PayOrder payOrder) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AbstractRS pay(UnifiedOrderRQ rq, PayOrder payOrder, MchAppConfigContext mchAppConfigContext) throws Exception {
|
||||
JeepluspayNormalMchParams normalMchParams = (JeepluspayNormalMchParams) configContextQueryService.queryNormalMchParams(mchAppConfigContext.getMchNo(), mchAppConfigContext.getAppId(), CS.IF_CODE.JEEPLUSPAY);
|
||||
// 构建请求数据
|
||||
PayOrderCreateRequest request = new PayOrderCreateRequest();
|
||||
PayOrderCreateReqModel model = new PayOrderCreateReqModel();
|
||||
model.setMchNo(normalMchParams.getMerchantNo()); // 商户号
|
||||
model.setAppId(normalMchParams.getAppId()); // 应用ID
|
||||
model.setMchOrderNo(payOrder.getPayOrderId()); // 商户订单号
|
||||
model.setWayCode(JeepluspayConfig.WX_APP); // 支付方式
|
||||
model.setAmount(payOrder.getAmount()); // 金额,单位分
|
||||
model.setCurrency(payOrder.getCurrency()); // 币种,目前只支持cny
|
||||
model.setClientIp(payOrder.getClientIp()); // 发起支付请求客户端的IP地址
|
||||
model.setSubject(payOrder.getSubject()); // 商品标题
|
||||
model.setBody(payOrder.getBody()); // 商品描述
|
||||
model.setNotifyUrl(getNotifyUrl()); // 异步通知地址
|
||||
JSONObject channelExtra = new JSONObject();
|
||||
channelExtra.put("payDataType", CS.PAY_DATA_TYPE.WX_APP);
|
||||
model.setChannelExtra(channelExtra.toString()); // 微信app支付参数
|
||||
request.setBizModel(model);
|
||||
// 构造函数响应数据
|
||||
WxAppOrderRS res = ApiResBuilder.buildSuccess(WxAppOrderRS.class);
|
||||
ChannelRetMsg channelRetMsg = new ChannelRetMsg();
|
||||
res.setChannelRetMsg(channelRetMsg);
|
||||
try {
|
||||
// 发起统一下单
|
||||
PayOrderCreateResponse response = new PayOrderCreateResponse();
|
||||
boolean checkSign = false;
|
||||
boolean isSuccess = false;
|
||||
if (normalMchParams.getSignType().equals(JeepluspayConfig.DEFAULT_SIGN_TYPE) || StringUtils.isEmpty(normalMchParams.getSignType())) {
|
||||
JeepayClient jeepayClient = JeepayClient.getInstance(normalMchParams.getAppId(), normalMchParams.getAppSecret(), Jeepay.getApiBase());
|
||||
response = jeepayClient.execute(request);
|
||||
checkSign = response.checkSign(normalMchParams.getAppSecret());
|
||||
isSuccess = response.isSuccess(normalMchParams.getAppSecret());
|
||||
|
||||
} else if (normalMchParams.getSignType().equals(JeepluspayConfig.SIGN_TYPE_RSA2)) {
|
||||
JeepayClient jeepayClient = JeepayClient.getInstance(normalMchParams.getAppId(), normalMchParams.getRsa2AppPrivateKey(), Jeepay.getApiBase());
|
||||
response = jeepayClient.executeByRSA2(request);
|
||||
checkSign = response.checkSignByRsa2(normalMchParams.getRsa2PayPublicKey());
|
||||
isSuccess = response.isSuccessByRsa2(normalMchParams.getRsa2PayPublicKey());
|
||||
}
|
||||
|
||||
if (checkSign) {
|
||||
channelRetMsg.setChannelOrderId(response.get().getPayOrderId());
|
||||
if (isSuccess) {
|
||||
// 下单成功
|
||||
JSONObject payData = response.getData().getJSONObject("payData");
|
||||
JSONObject resJSON = new JSONObject();
|
||||
resJSON.put("package", payData.toJSONString());
|
||||
res.setPayInfo(resJSON.toJSONString());
|
||||
channelRetMsg.setChannelState(ChannelRetMsg.ChannelState.WAITING);
|
||||
} else {
|
||||
channelRetMsg.setChannelState(ChannelRetMsg.ChannelState.CONFIRM_FAIL);
|
||||
channelRetMsg.setChannelErrCode(response.get().getErrCode());
|
||||
channelRetMsg.setChannelErrMsg(response.get().getErrMsg());
|
||||
}
|
||||
}
|
||||
} catch (JeepayException e) {
|
||||
channelRetMsg.setChannelState(ChannelRetMsg.ChannelState.CONFIRM_FAIL);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
}
|
@ -0,0 +1,119 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2031, 河北计全科技有限公司 (https://www.jeequan.com & jeequan@126.com).
|
||||
* <p>
|
||||
* 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
|
||||
* <p>
|
||||
* http://www.gnu.org/licenses/lgpl.html
|
||||
* <p>
|
||||
* 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.jeepluspay.payway;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.jeequan.jeepay.Jeepay;
|
||||
import com.jeequan.jeepay.JeepayClient;
|
||||
import com.jeequan.jeepay.core.constants.CS;
|
||||
import com.jeequan.jeepay.core.entity.PayOrder;
|
||||
import com.jeequan.jeepay.core.exception.BizException;
|
||||
import com.jeequan.jeepay.core.model.params.jeepluspay.JeepluspayConfig;
|
||||
import com.jeequan.jeepay.core.model.params.jeepluspay.JeepluspayNormalMchParams;
|
||||
import com.jeequan.jeepay.exception.JeepayException;
|
||||
import com.jeequan.jeepay.model.PayOrderCreateReqModel;
|
||||
import com.jeequan.jeepay.pay.channel.jeepluspay.JeepluspayPaymentService;
|
||||
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.AliBarOrderRS;
|
||||
import com.jeequan.jeepay.pay.rqrs.payorder.payway.WxBarOrderRQ;
|
||||
import com.jeequan.jeepay.pay.util.ApiResBuilder;
|
||||
import com.jeequan.jeepay.request.PayOrderCreateRequest;
|
||||
import com.jeequan.jeepay.response.PayOrderCreateResponse;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/*
|
||||
* 计全付 微信 bar
|
||||
*
|
||||
* @author yr
|
||||
* @site https://www.jeequan.com
|
||||
* @date 2022/8/16 18:37
|
||||
*/
|
||||
@Service("jeepluspayPaymentByWxBarService") //Service Name需保持全局唯一性
|
||||
public class WxBar extends JeepluspayPaymentService {
|
||||
|
||||
@Override
|
||||
public String preCheck(UnifiedOrderRQ rq, PayOrder payOrder) {
|
||||
WxBarOrderRQ bizRQ = (WxBarOrderRQ) rq;
|
||||
if (StringUtils.isEmpty(bizRQ.getAuthCode())) {
|
||||
throw new BizException("用户支付条码[authCode]不可为空");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AbstractRS pay(UnifiedOrderRQ rq, PayOrder payOrder, MchAppConfigContext mchAppConfigContext) throws Exception {
|
||||
WxBarOrderRQ bizRQ = (WxBarOrderRQ) rq;
|
||||
JeepluspayNormalMchParams normalMchParams = (JeepluspayNormalMchParams) configContextQueryService.queryNormalMchParams(mchAppConfigContext.getMchNo(), mchAppConfigContext.getAppId(), CS.IF_CODE.JEEPLUSPAY);
|
||||
// 构建请求数据
|
||||
PayOrderCreateRequest request = new PayOrderCreateRequest();
|
||||
PayOrderCreateReqModel model = new PayOrderCreateReqModel();
|
||||
model.setMchNo(normalMchParams.getMerchantNo()); // 商户号
|
||||
model.setAppId(normalMchParams.getAppId()); // 应用ID
|
||||
model.setMchOrderNo(payOrder.getPayOrderId()); // 商户订单号
|
||||
model.setWayCode(JeepluspayConfig.WX_BAR); // 支付方式
|
||||
model.setAmount(payOrder.getAmount()); // 金额,单位分
|
||||
model.setCurrency(payOrder.getCurrency()); // 币种,目前只支持cny
|
||||
model.setClientIp(payOrder.getClientIp()); // 发起支付请求客户端的IP地址
|
||||
model.setSubject(payOrder.getSubject()); // 商品标题
|
||||
model.setBody(payOrder.getBody()); // 商品描述
|
||||
model.setNotifyUrl(getNotifyUrl()); // 异步通知地址
|
||||
JSONObject channelExtra = new JSONObject();
|
||||
channelExtra.put("authCode", bizRQ.getAuthCode());
|
||||
model.setChannelExtra(channelExtra.toString()); // 用户付款码值
|
||||
request.setBizModel(model);
|
||||
// 构造函数响应数据
|
||||
AliBarOrderRS res = ApiResBuilder.buildSuccess(AliBarOrderRS.class);
|
||||
ChannelRetMsg channelRetMsg = new ChannelRetMsg();
|
||||
res.setChannelRetMsg(channelRetMsg);
|
||||
try {
|
||||
// 发起统一下单
|
||||
PayOrderCreateResponse response = new PayOrderCreateResponse();
|
||||
boolean checkSign = false;
|
||||
boolean isSuccess = false;
|
||||
if (normalMchParams.getSignType().equals(JeepluspayConfig.DEFAULT_SIGN_TYPE) || StringUtils.isEmpty(normalMchParams.getSignType())) {
|
||||
JeepayClient jeepayClient = JeepayClient.getInstance(normalMchParams.getAppId(), normalMchParams.getAppSecret(), Jeepay.getApiBase());
|
||||
response = jeepayClient.execute(request);
|
||||
checkSign = response.checkSign(normalMchParams.getAppSecret());
|
||||
isSuccess = response.isSuccess(normalMchParams.getAppSecret());
|
||||
|
||||
} else if (normalMchParams.getSignType().equals(JeepluspayConfig.SIGN_TYPE_RSA2)) {
|
||||
JeepayClient jeepayClient = JeepayClient.getInstance(normalMchParams.getAppId(), normalMchParams.getRsa2AppPrivateKey(), Jeepay.getApiBase());
|
||||
response = jeepayClient.executeByRSA2(request);
|
||||
checkSign = response.checkSignByRsa2(normalMchParams.getRsa2PayPublicKey());
|
||||
isSuccess = response.isSuccessByRsa2(normalMchParams.getRsa2PayPublicKey());
|
||||
}
|
||||
|
||||
if (checkSign) {
|
||||
channelRetMsg.setChannelOrderId(response.get().getPayOrderId());
|
||||
if (isSuccess) {
|
||||
// 下单成功
|
||||
channelRetMsg.setChannelState(ChannelRetMsg.ChannelState.CONFIRM_SUCCESS);
|
||||
} else {
|
||||
channelRetMsg.setChannelState(ChannelRetMsg.ChannelState.CONFIRM_FAIL);
|
||||
channelRetMsg.setChannelErrCode(response.get().getErrCode());
|
||||
channelRetMsg.setChannelErrMsg(response.get().getErrMsg());
|
||||
}
|
||||
}
|
||||
} catch (JeepayException e) {
|
||||
channelRetMsg.setChannelState(ChannelRetMsg.ChannelState.CONFIRM_FAIL);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
}
|
@ -0,0 +1,118 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2031, 河北计全科技有限公司 (https://www.jeequan.com & jeequan@126.com).
|
||||
* <p>
|
||||
* 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
|
||||
* <p>
|
||||
* http://www.gnu.org/licenses/lgpl.html
|
||||
* <p>
|
||||
* 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.jeepluspay.payway;
|
||||
|
||||
import com.jeequan.jeepay.Jeepay;
|
||||
import com.jeequan.jeepay.JeepayClient;
|
||||
import com.jeequan.jeepay.core.constants.CS;
|
||||
import com.jeequan.jeepay.core.entity.PayOrder;
|
||||
import com.jeequan.jeepay.core.model.params.jeepluspay.JeepluspayConfig;
|
||||
import com.jeequan.jeepay.core.model.params.jeepluspay.JeepluspayNormalMchParams;
|
||||
import com.jeequan.jeepay.exception.JeepayException;
|
||||
import com.jeequan.jeepay.model.PayOrderCreateReqModel;
|
||||
import com.jeequan.jeepay.pay.channel.jeepluspay.JeepluspayPaymentService;
|
||||
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.WxH5OrderRS;
|
||||
import com.jeequan.jeepay.pay.util.ApiResBuilder;
|
||||
import com.jeequan.jeepay.request.PayOrderCreateRequest;
|
||||
import com.jeequan.jeepay.response.PayOrderCreateResponse;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/*
|
||||
* 计全付 微信 H5 支付
|
||||
*
|
||||
* @author yr
|
||||
* @site https://www.jeequan.com
|
||||
* @date 2022/8/17 15:37
|
||||
*/
|
||||
@Service("jeepluspayPaymentByWxH5Service") //Service Name需保持全局唯一性
|
||||
public class WxH5 extends JeepluspayPaymentService {
|
||||
|
||||
@Override
|
||||
public String preCheck(UnifiedOrderRQ rq, PayOrder payOrder) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AbstractRS pay(UnifiedOrderRQ rq, PayOrder payOrder, MchAppConfigContext mchAppConfigContext) {
|
||||
JeepluspayNormalMchParams normalMchParams = (JeepluspayNormalMchParams) configContextQueryService.queryNormalMchParams(mchAppConfigContext.getMchNo(), mchAppConfigContext.getAppId(), CS.IF_CODE.JEEPLUSPAY);
|
||||
// 构建请求数据
|
||||
PayOrderCreateRequest request = new PayOrderCreateRequest();
|
||||
PayOrderCreateReqModel model = new PayOrderCreateReqModel();
|
||||
model.setMchNo(normalMchParams.getMerchantNo()); // 商户号
|
||||
model.setAppId(normalMchParams.getAppId()); // 应用ID
|
||||
model.setMchOrderNo(payOrder.getPayOrderId()); // 商户订单号
|
||||
model.setWayCode(JeepluspayConfig.WX_H5); // 支付方式
|
||||
model.setAmount(payOrder.getAmount()); // 金额,单位分
|
||||
model.setCurrency(payOrder.getCurrency()); // 币种,目前只支持cny
|
||||
model.setClientIp(payOrder.getClientIp()); // 发起支付请求客户端的IP地址
|
||||
model.setSubject(payOrder.getSubject()); // 商品标题
|
||||
model.setBody(payOrder.getBody()); // 商品描述
|
||||
model.setNotifyUrl(getNotifyUrl()); // 异步通知地址
|
||||
request.setBizModel(model);
|
||||
// 构造函数响应数据
|
||||
WxH5OrderRS res = ApiResBuilder.buildSuccess(WxH5OrderRS.class);
|
||||
ChannelRetMsg channelRetMsg = new ChannelRetMsg();
|
||||
res.setChannelRetMsg(channelRetMsg);
|
||||
try {
|
||||
// 发起统一下单
|
||||
PayOrderCreateResponse response = new PayOrderCreateResponse();
|
||||
boolean checkSign = false;
|
||||
boolean isSuccess = false;
|
||||
if (normalMchParams.getSignType().equals(JeepluspayConfig.DEFAULT_SIGN_TYPE) || StringUtils.isEmpty(normalMchParams.getSignType())) {
|
||||
JeepayClient jeepayClient = JeepayClient.getInstance(normalMchParams.getAppId(), normalMchParams.getAppSecret(), Jeepay.getApiBase());
|
||||
response = jeepayClient.execute(request);
|
||||
checkSign = response.checkSign(normalMchParams.getAppSecret());
|
||||
isSuccess = response.isSuccess(normalMchParams.getAppSecret());
|
||||
|
||||
} else if (normalMchParams.getSignType().equals(JeepluspayConfig.SIGN_TYPE_RSA2)) {
|
||||
JeepayClient jeepayClient = JeepayClient.getInstance(normalMchParams.getAppId(), normalMchParams.getRsa2AppPrivateKey(), Jeepay.getApiBase());
|
||||
response = jeepayClient.executeByRSA2(request);
|
||||
checkSign = response.checkSignByRsa2(normalMchParams.getRsa2PayPublicKey());
|
||||
isSuccess = response.isSuccessByRsa2(normalMchParams.getRsa2PayPublicKey());
|
||||
}
|
||||
|
||||
if (checkSign) {
|
||||
channelRetMsg.setChannelOrderId(response.get().getPayOrderId());
|
||||
if (isSuccess) {
|
||||
// 下单成功
|
||||
String payUrl = response.getData().getString("payData");
|
||||
String payDataType = response.getData().getString("payDataType");
|
||||
if (CS.PAY_DATA_TYPE.FORM.equals(payDataType)) { //表单方式
|
||||
res.setFormContent(payUrl);
|
||||
} else if (CS.PAY_DATA_TYPE.CODE_IMG_URL.equals(payDataType)) { //二维码图片地址
|
||||
res.setCodeImgUrl(payUrl);
|
||||
} else { // 默认都为 payUrl方式
|
||||
res.setPayUrl(payUrl);
|
||||
}
|
||||
// 支付中
|
||||
channelRetMsg.setChannelState(ChannelRetMsg.ChannelState.WAITING);
|
||||
} else {
|
||||
channelRetMsg.setChannelState(ChannelRetMsg.ChannelState.CONFIRM_FAIL);
|
||||
channelRetMsg.setChannelErrCode(response.get().getErrCode());
|
||||
channelRetMsg.setChannelErrMsg(response.get().getErrMsg());
|
||||
}
|
||||
}
|
||||
} catch (JeepayException e) {
|
||||
channelRetMsg.setChannelState(ChannelRetMsg.ChannelState.CONFIRM_FAIL);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
}
|
@ -0,0 +1,123 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2031, 河北计全科技有限公司 (https://www.jeequan.com & jeequan@126.com).
|
||||
* <p>
|
||||
* 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
|
||||
* <p>
|
||||
* http://www.gnu.org/licenses/lgpl.html
|
||||
* <p>
|
||||
* 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.jeepluspay.payway;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.jeequan.jeepay.Jeepay;
|
||||
import com.jeequan.jeepay.JeepayClient;
|
||||
import com.jeequan.jeepay.core.constants.CS;
|
||||
import com.jeequan.jeepay.core.entity.PayOrder;
|
||||
import com.jeequan.jeepay.core.exception.BizException;
|
||||
import com.jeequan.jeepay.core.model.params.jeepluspay.JeepluspayConfig;
|
||||
import com.jeequan.jeepay.core.model.params.jeepluspay.JeepluspayNormalMchParams;
|
||||
import com.jeequan.jeepay.exception.JeepayException;
|
||||
import com.jeequan.jeepay.model.PayOrderCreateReqModel;
|
||||
import com.jeequan.jeepay.pay.channel.jeepluspay.JeepluspayPaymentService;
|
||||
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.WxJsapiOrderRQ;
|
||||
import com.jeequan.jeepay.pay.rqrs.payorder.payway.WxJsapiOrderRS;
|
||||
import com.jeequan.jeepay.pay.util.ApiResBuilder;
|
||||
import com.jeequan.jeepay.request.PayOrderCreateRequest;
|
||||
import com.jeequan.jeepay.response.PayOrderCreateResponse;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/*
|
||||
* 计全付 微信 jsapi支付
|
||||
*
|
||||
* @author yr
|
||||
* @site https://www.jeequan.com
|
||||
* @date 2022/8/17 14:24
|
||||
*/
|
||||
@Service("jeepluspayPaymentByWxJsapiService") //Service Name需保持全局唯一性
|
||||
@Slf4j
|
||||
public class WxJsapi extends JeepluspayPaymentService {
|
||||
|
||||
@Override
|
||||
public String preCheck(UnifiedOrderRQ rq, PayOrder payOrder) {
|
||||
WxJsapiOrderRQ bizRQ = (WxJsapiOrderRQ) rq;
|
||||
if (StringUtils.isEmpty(bizRQ.getOpenid())) {
|
||||
throw new BizException("[openid]不可为空");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AbstractRS pay(UnifiedOrderRQ rq, PayOrder payOrder, MchAppConfigContext mchAppConfigContext) throws Exception {
|
||||
WxJsapiOrderRQ bizRQ = (WxJsapiOrderRQ) rq;
|
||||
JeepluspayNormalMchParams normalMchParams = (JeepluspayNormalMchParams) configContextQueryService.queryNormalMchParams(mchAppConfigContext.getMchNo(), mchAppConfigContext.getAppId(), CS.IF_CODE.JEEPLUSPAY);
|
||||
// 构建请求数据
|
||||
PayOrderCreateRequest request = new PayOrderCreateRequest();
|
||||
PayOrderCreateReqModel model = new PayOrderCreateReqModel();
|
||||
model.setMchNo(normalMchParams.getMerchantNo()); // 商户号
|
||||
model.setAppId(normalMchParams.getAppId()); // 应用ID
|
||||
model.setMchOrderNo(payOrder.getPayOrderId()); // 商户订单号
|
||||
model.setWayCode(JeepluspayConfig.WX_JSAPI); // 支付方式
|
||||
model.setAmount(payOrder.getAmount()); // 金额,单位分
|
||||
model.setCurrency(payOrder.getCurrency()); // 币种,目前只支持cny
|
||||
model.setClientIp(payOrder.getClientIp()); // 发起支付请求客户端的IP地址
|
||||
model.setSubject(payOrder.getSubject()); // 商品标题
|
||||
model.setBody(payOrder.getBody()); // 商品描述
|
||||
model.setNotifyUrl(getNotifyUrl()); // 异步通知地址
|
||||
JSONObject channelExtra = new JSONObject();
|
||||
channelExtra.put("openid", bizRQ.getOpenid());
|
||||
model.setChannelExtra(channelExtra.toString()); // 微信openId
|
||||
request.setBizModel(model);
|
||||
// 构造函数响应数据
|
||||
WxJsapiOrderRS res = ApiResBuilder.buildSuccess(WxJsapiOrderRS.class);
|
||||
ChannelRetMsg channelRetMsg = new ChannelRetMsg();
|
||||
res.setChannelRetMsg(channelRetMsg);
|
||||
try {
|
||||
// 发起统一下单
|
||||
PayOrderCreateResponse response = new PayOrderCreateResponse();
|
||||
boolean checkSign = false;
|
||||
boolean isSuccess = false;
|
||||
if (normalMchParams.getSignType().equals(JeepluspayConfig.DEFAULT_SIGN_TYPE) || StringUtils.isEmpty(normalMchParams.getSignType())) {
|
||||
JeepayClient jeepayClient = JeepayClient.getInstance(normalMchParams.getAppId(), normalMchParams.getAppSecret(), Jeepay.getApiBase());
|
||||
response = jeepayClient.execute(request);
|
||||
checkSign = response.checkSign(normalMchParams.getAppSecret());
|
||||
isSuccess = response.isSuccess(normalMchParams.getAppSecret());
|
||||
|
||||
} else if (normalMchParams.getSignType().equals(JeepluspayConfig.SIGN_TYPE_RSA2)) {
|
||||
JeepayClient jeepayClient = JeepayClient.getInstance(normalMchParams.getAppId(), normalMchParams.getRsa2AppPrivateKey(), Jeepay.getApiBase());
|
||||
response = jeepayClient.executeByRSA2(request);
|
||||
checkSign = response.checkSignByRsa2(normalMchParams.getRsa2PayPublicKey());
|
||||
isSuccess = response.isSuccessByRsa2(normalMchParams.getRsa2PayPublicKey());
|
||||
}
|
||||
|
||||
if (checkSign) {
|
||||
channelRetMsg.setChannelOrderId(response.get().getPayOrderId());
|
||||
if (isSuccess) {
|
||||
// 下单成功
|
||||
JSONObject payData = response.getData().getJSONObject("payData");
|
||||
res.setPayInfo(payData.toJSONString());
|
||||
channelRetMsg.setChannelState(ChannelRetMsg.ChannelState.WAITING);
|
||||
} else {
|
||||
channelRetMsg.setChannelState(ChannelRetMsg.ChannelState.CONFIRM_FAIL);
|
||||
channelRetMsg.setChannelErrCode(response.get().getErrCode());
|
||||
channelRetMsg.setChannelErrMsg(response.get().getErrMsg());
|
||||
}
|
||||
}
|
||||
} catch (JeepayException e) {
|
||||
channelRetMsg.setChannelState(ChannelRetMsg.ChannelState.CONFIRM_FAIL);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
}
|
@ -0,0 +1,123 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2031, 河北计全科技有限公司 (https://www.jeequan.com & jeequan@126.com).
|
||||
* <p>
|
||||
* 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
|
||||
* <p>
|
||||
* http://www.gnu.org/licenses/lgpl.html
|
||||
* <p>
|
||||
* 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.jeepluspay.payway;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.jeequan.jeepay.Jeepay;
|
||||
import com.jeequan.jeepay.JeepayClient;
|
||||
import com.jeequan.jeepay.core.constants.CS;
|
||||
import com.jeequan.jeepay.core.entity.PayOrder;
|
||||
import com.jeequan.jeepay.core.exception.BizException;
|
||||
import com.jeequan.jeepay.core.model.params.jeepluspay.JeepluspayConfig;
|
||||
import com.jeequan.jeepay.core.model.params.jeepluspay.JeepluspayNormalMchParams;
|
||||
import com.jeequan.jeepay.exception.JeepayException;
|
||||
import com.jeequan.jeepay.model.PayOrderCreateReqModel;
|
||||
import com.jeequan.jeepay.pay.channel.jeepluspay.JeepluspayPaymentService;
|
||||
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.WxLiteOrderRQ;
|
||||
import com.jeequan.jeepay.pay.rqrs.payorder.payway.WxLiteOrderRS;
|
||||
import com.jeequan.jeepay.pay.util.ApiResBuilder;
|
||||
import com.jeequan.jeepay.request.PayOrderCreateRequest;
|
||||
import com.jeequan.jeepay.response.PayOrderCreateResponse;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/*
|
||||
* 计全付 微信 小程序支付
|
||||
*
|
||||
* @author yr
|
||||
* @site https://www.jeequan.com
|
||||
* @date 2022/8/17 15:24
|
||||
*/
|
||||
@Service("jeepluspayPaymentByWxLiteService") //Service Name需保持全局唯一性
|
||||
@Slf4j
|
||||
public class WxLite extends JeepluspayPaymentService {
|
||||
|
||||
@Override
|
||||
public String preCheck(UnifiedOrderRQ rq, PayOrder payOrder) {
|
||||
WxLiteOrderRQ bizRQ = (WxLiteOrderRQ) rq;
|
||||
if (StringUtils.isEmpty(bizRQ.getOpenid())) {
|
||||
throw new BizException("[openid]不可为空");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AbstractRS pay(UnifiedOrderRQ rq, PayOrder payOrder, MchAppConfigContext mchAppConfigContext) throws Exception {
|
||||
WxLiteOrderRQ bizRQ = (WxLiteOrderRQ) rq;
|
||||
JeepluspayNormalMchParams normalMchParams = (JeepluspayNormalMchParams) configContextQueryService.queryNormalMchParams(mchAppConfigContext.getMchNo(), mchAppConfigContext.getAppId(), CS.IF_CODE.JEEPLUSPAY);
|
||||
// 构建请求数据
|
||||
PayOrderCreateRequest request = new PayOrderCreateRequest();
|
||||
PayOrderCreateReqModel model = new PayOrderCreateReqModel();
|
||||
model.setMchNo(normalMchParams.getMerchantNo()); // 商户号
|
||||
model.setAppId(normalMchParams.getAppId()); // 应用ID
|
||||
model.setMchOrderNo(payOrder.getPayOrderId()); // 商户订单号
|
||||
model.setWayCode(JeepluspayConfig.WX_LITE); // 支付方式
|
||||
model.setAmount(payOrder.getAmount()); // 金额,单位分
|
||||
model.setCurrency(payOrder.getCurrency()); // 币种,目前只支持cny
|
||||
model.setClientIp(payOrder.getClientIp()); // 发起支付请求客户端的IP地址
|
||||
model.setSubject(payOrder.getSubject()); // 商品标题
|
||||
model.setBody(payOrder.getBody()); // 商品描述
|
||||
model.setNotifyUrl(getNotifyUrl()); // 异步通知地址
|
||||
JSONObject channelExtra = new JSONObject();
|
||||
channelExtra.put("openid", bizRQ.getOpenid());
|
||||
model.setChannelExtra(channelExtra.toString()); // 微信openId
|
||||
request.setBizModel(model);
|
||||
// 构造函数响应数据
|
||||
WxLiteOrderRS res = ApiResBuilder.buildSuccess(WxLiteOrderRS.class);
|
||||
ChannelRetMsg channelRetMsg = new ChannelRetMsg();
|
||||
res.setChannelRetMsg(channelRetMsg);
|
||||
try {
|
||||
// 发起统一下单
|
||||
PayOrderCreateResponse response = new PayOrderCreateResponse();
|
||||
boolean checkSign = false;
|
||||
boolean isSuccess = false;
|
||||
if (normalMchParams.getSignType().equals(JeepluspayConfig.DEFAULT_SIGN_TYPE) || StringUtils.isEmpty(normalMchParams.getSignType())) {
|
||||
JeepayClient jeepayClient = JeepayClient.getInstance(normalMchParams.getAppId(), normalMchParams.getAppSecret(), Jeepay.getApiBase());
|
||||
response = jeepayClient.execute(request);
|
||||
checkSign = response.checkSign(normalMchParams.getAppSecret());
|
||||
isSuccess = response.isSuccess(normalMchParams.getAppSecret());
|
||||
|
||||
} else if (normalMchParams.getSignType().equals(JeepluspayConfig.SIGN_TYPE_RSA2)) {
|
||||
JeepayClient jeepayClient = JeepayClient.getInstance(normalMchParams.getAppId(), normalMchParams.getRsa2AppPrivateKey(), Jeepay.getApiBase());
|
||||
response = jeepayClient.executeByRSA2(request);
|
||||
checkSign = response.checkSignByRsa2(normalMchParams.getRsa2PayPublicKey());
|
||||
isSuccess = response.isSuccessByRsa2(normalMchParams.getRsa2PayPublicKey());
|
||||
}
|
||||
|
||||
if (checkSign) {
|
||||
channelRetMsg.setChannelOrderId(response.get().getPayOrderId());
|
||||
if (isSuccess) {
|
||||
// 下单成功
|
||||
JSONObject payData = response.getData().getJSONObject("payData");
|
||||
res.setPayInfo(payData.toJSONString());
|
||||
channelRetMsg.setChannelState(ChannelRetMsg.ChannelState.WAITING);
|
||||
} else {
|
||||
channelRetMsg.setChannelState(ChannelRetMsg.ChannelState.CONFIRM_FAIL);
|
||||
channelRetMsg.setChannelErrCode(response.get().getErrCode());
|
||||
channelRetMsg.setChannelErrMsg(response.get().getErrMsg());
|
||||
}
|
||||
}
|
||||
} catch (JeepayException e) {
|
||||
channelRetMsg.setChannelState(ChannelRetMsg.ChannelState.CONFIRM_FAIL);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
}
|
@ -0,0 +1,116 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2031, 河北计全科技有限公司 (https://www.jeequan.com & jeequan@126.com).
|
||||
* <p>
|
||||
* 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
|
||||
* <p>
|
||||
* http://www.gnu.org/licenses/lgpl.html
|
||||
* <p>
|
||||
* 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.jeepluspay.payway;
|
||||
|
||||
import com.jeequan.jeepay.Jeepay;
|
||||
import com.jeequan.jeepay.JeepayClient;
|
||||
import com.jeequan.jeepay.core.constants.CS;
|
||||
import com.jeequan.jeepay.core.entity.PayOrder;
|
||||
import com.jeequan.jeepay.core.model.params.jeepluspay.JeepluspayConfig;
|
||||
import com.jeequan.jeepay.core.model.params.jeepluspay.JeepluspayNormalMchParams;
|
||||
import com.jeequan.jeepay.exception.JeepayException;
|
||||
import com.jeequan.jeepay.model.PayOrderCreateReqModel;
|
||||
import com.jeequan.jeepay.pay.channel.jeepluspay.JeepluspayPaymentService;
|
||||
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.WxNativeOrderRQ;
|
||||
import com.jeequan.jeepay.pay.rqrs.payorder.payway.WxNativeOrderRS;
|
||||
import com.jeequan.jeepay.pay.util.ApiResBuilder;
|
||||
import com.jeequan.jeepay.request.PayOrderCreateRequest;
|
||||
import com.jeequan.jeepay.response.PayOrderCreateResponse;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/*
|
||||
* 计全付 微信 native支付
|
||||
*
|
||||
* @author yr
|
||||
* @site https://www.jeequan.com
|
||||
* @date 2022/8/11 15:37
|
||||
*/
|
||||
@Service("jeepluspayPaymentByWxNativeService") //Service Name需保持全局唯一性
|
||||
public class WxNative extends JeepluspayPaymentService {
|
||||
|
||||
@Override
|
||||
public String preCheck(UnifiedOrderRQ rq, PayOrder payOrder) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AbstractRS pay(UnifiedOrderRQ rq, PayOrder payOrder, MchAppConfigContext mchAppConfigContext) throws Exception {
|
||||
WxNativeOrderRQ bizRQ = (WxNativeOrderRQ) rq;
|
||||
JeepluspayNormalMchParams normalMchParams = (JeepluspayNormalMchParams) configContextQueryService.queryNormalMchParams(mchAppConfigContext.getMchNo(), mchAppConfigContext.getAppId(), CS.IF_CODE.JEEPLUSPAY);
|
||||
// 构建请求数据
|
||||
PayOrderCreateRequest request = new PayOrderCreateRequest();
|
||||
PayOrderCreateReqModel model = new PayOrderCreateReqModel();
|
||||
model.setMchNo(normalMchParams.getMerchantNo()); // 商户号
|
||||
model.setAppId(normalMchParams.getAppId()); // 应用ID
|
||||
model.setMchOrderNo(payOrder.getPayOrderId()); // 商户订单号
|
||||
model.setWayCode(JeepluspayConfig.WX_NATIVE); // 支付方式
|
||||
model.setAmount(payOrder.getAmount()); // 金额,单位分
|
||||
model.setCurrency(payOrder.getCurrency()); // 币种,目前只支持cny
|
||||
model.setClientIp(payOrder.getClientIp()); // 发起支付请求客户端的IP地址
|
||||
model.setSubject(payOrder.getSubject()); // 商品标题
|
||||
model.setBody(payOrder.getBody()); // 商品描述
|
||||
model.setNotifyUrl(getNotifyUrl()); // 异步通知地址
|
||||
request.setBizModel(model);
|
||||
// 构造函数响应数据
|
||||
WxNativeOrderRS res = ApiResBuilder.buildSuccess(WxNativeOrderRS.class);
|
||||
ChannelRetMsg channelRetMsg = new ChannelRetMsg();
|
||||
res.setChannelRetMsg(channelRetMsg);
|
||||
try {
|
||||
// 发起统一下单
|
||||
PayOrderCreateResponse response = new PayOrderCreateResponse();
|
||||
boolean checkSign = false;
|
||||
boolean isSuccess = false;
|
||||
if (normalMchParams.getSignType().equals(JeepluspayConfig.DEFAULT_SIGN_TYPE) || StringUtils.isEmpty(normalMchParams.getSignType())) {
|
||||
JeepayClient jeepayClient = JeepayClient.getInstance(normalMchParams.getAppId(), normalMchParams.getAppSecret(), Jeepay.getApiBase());
|
||||
response = jeepayClient.execute(request);
|
||||
checkSign = response.checkSign(normalMchParams.getAppSecret());
|
||||
isSuccess = response.isSuccess(normalMchParams.getAppSecret());
|
||||
|
||||
} else if (normalMchParams.getSignType().equals(JeepluspayConfig.SIGN_TYPE_RSA2)) {
|
||||
JeepayClient jeepayClient = JeepayClient.getInstance(normalMchParams.getAppId(), normalMchParams.getRsa2AppPrivateKey(), Jeepay.getApiBase());
|
||||
response = jeepayClient.executeByRSA2(request);
|
||||
checkSign = response.checkSignByRsa2(normalMchParams.getRsa2PayPublicKey());
|
||||
isSuccess = response.isSuccessByRsa2(normalMchParams.getRsa2PayPublicKey());
|
||||
}
|
||||
|
||||
if (checkSign) {
|
||||
channelRetMsg.setChannelOrderId(response.get().getPayOrderId());
|
||||
if (isSuccess) {
|
||||
// 下单成功
|
||||
// 二维码图片地址
|
||||
if (CS.PAY_DATA_TYPE.CODE_IMG_URL.equals(bizRQ.getPayDataType())) {
|
||||
res.setCodeImgUrl(sysConfigService.getDBApplicationConfig().genScanImgUrl(response.get().getPayData()));
|
||||
} else {
|
||||
res.setCodeUrl(response.get().getPayData());
|
||||
}
|
||||
channelRetMsg.setChannelState(ChannelRetMsg.ChannelState.WAITING);
|
||||
} else {
|
||||
channelRetMsg.setChannelState(ChannelRetMsg.ChannelState.CONFIRM_FAIL);
|
||||
channelRetMsg.setChannelErrCode(response.get().getErrCode());
|
||||
channelRetMsg.setChannelErrMsg(response.get().getErrMsg());
|
||||
}
|
||||
}
|
||||
} catch (JeepayException e) {
|
||||
channelRetMsg.setChannelState(ChannelRetMsg.ChannelState.CONFIRM_FAIL);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
}
|
@ -23,8 +23,8 @@ 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.AliBarOrderRS;
|
||||
import com.jeequan.jeepay.pay.rqrs.payorder.payway.WxBarOrderRQ;
|
||||
import com.jeequan.jeepay.pay.rqrs.payorder.payway.WxBarOrderRS;
|
||||
import com.jeequan.jeepay.pay.util.ApiResBuilder;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@ -72,7 +72,7 @@ public class WxBar extends XxpayPaymentService {
|
||||
paramMap.put("body", payOrder.getBody());
|
||||
paramMap.put("extra", bizRQ.getAuthCode());
|
||||
// 构造函数响应数据
|
||||
AliBarOrderRS res = ApiResBuilder.buildSuccess(AliBarOrderRS.class);
|
||||
WxBarOrderRS res = ApiResBuilder.buildSuccess(WxBarOrderRS.class);
|
||||
ChannelRetMsg channelRetMsg = new ChannelRetMsg();
|
||||
res.setChannelRetMsg(channelRetMsg);
|
||||
// 发起支付
|
||||
|
@ -98,6 +98,10 @@ public class UnifiedOrderRQ extends AbstractMchAppRQ {
|
||||
AliJsapiOrderRQ bizRQ = JSONObject.parseObject(StringUtils.defaultIfEmpty(this.channelExtra, "{}"), AliJsapiOrderRQ.class);
|
||||
BeanUtils.copyProperties(this, bizRQ);
|
||||
return bizRQ;
|
||||
}else if(CS.PAY_WAY_CODE.ALI_LITE.equals(wayCode)){
|
||||
AliLiteOrderRQ bizRQ = JSONObject.parseObject(StringUtils.defaultIfEmpty(this.channelExtra, "{}"), AliLiteOrderRQ.class);
|
||||
BeanUtils.copyProperties(this, bizRQ);
|
||||
return bizRQ;
|
||||
}else if(CS.PAY_WAY_CODE.QR_CASHIER.equals(wayCode)){
|
||||
QrCashierOrderRQ bizRQ = JSONObject.parseObject(StringUtils.defaultIfEmpty(this.channelExtra, "{}"), QrCashierOrderRQ.class);
|
||||
BeanUtils.copyProperties(this, bizRQ);
|
||||
@ -106,6 +110,10 @@ public class UnifiedOrderRQ extends AbstractMchAppRQ {
|
||||
WxJsapiOrderRQ bizRQ = JSONObject.parseObject(StringUtils.defaultIfEmpty(this.channelExtra, "{}"), WxJsapiOrderRQ.class);
|
||||
BeanUtils.copyProperties(this, bizRQ);
|
||||
return bizRQ;
|
||||
}else if(CS.PAY_WAY_CODE.WX_LITE.equals(wayCode)){
|
||||
WxLiteOrderRQ bizRQ = JSONObject.parseObject(StringUtils.defaultIfEmpty(this.channelExtra, "{}"), WxLiteOrderRQ.class);
|
||||
BeanUtils.copyProperties(this, bizRQ);
|
||||
return bizRQ;
|
||||
}else if(CS.PAY_WAY_CODE.WX_BAR.equals(wayCode)){
|
||||
WxBarOrderRQ bizRQ = JSONObject.parseObject(StringUtils.defaultIfEmpty(this.channelExtra, "{}"), WxBarOrderRQ.class);
|
||||
BeanUtils.copyProperties(this, bizRQ);
|
||||
|
@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2031, 河北计全科技有限公司 (https://www.jeequan.com & jeequan@126.com).
|
||||
* <p>
|
||||
* 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
|
||||
* <p>
|
||||
* http://www.gnu.org/licenses/lgpl.html
|
||||
* <p>
|
||||
* 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.rqrs.payorder.payway;
|
||||
|
||||
import com.jeequan.jeepay.core.constants.CS;
|
||||
import com.jeequan.jeepay.pay.rqrs.payorder.UnifiedOrderRQ;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
|
||||
/*
|
||||
* 支付方式: ALI_LITE
|
||||
*
|
||||
* @author terrfly
|
||||
* @site https://www.jeequan.com
|
||||
* @date 2021/6/8 17:34
|
||||
*/
|
||||
@Data
|
||||
public class AliLiteOrderRQ extends UnifiedOrderRQ {
|
||||
|
||||
/** 支付宝用户ID **/
|
||||
@NotBlank(message = "用户ID不能为空")
|
||||
private String buyerUserId;
|
||||
|
||||
/** 构造函数 **/
|
||||
public AliLiteOrderRQ(){
|
||||
this.setWayCode(CS.PAY_WAY_CODE.ALI_LITE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getChannelUserId(){
|
||||
return this.buyerUserId;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2031, 河北计全科技有限公司 (https://www.jeequan.com & jeequan@126.com).
|
||||
* <p>
|
||||
* 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
|
||||
* <p>
|
||||
* http://www.gnu.org/licenses/lgpl.html
|
||||
* <p>
|
||||
* 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.rqrs.payorder.payway;
|
||||
|
||||
import com.jeequan.jeepay.core.constants.CS;
|
||||
import com.jeequan.jeepay.core.utils.JsonKit;
|
||||
import com.jeequan.jeepay.pay.rqrs.payorder.UnifiedOrderRS;
|
||||
import lombok.Data;
|
||||
|
||||
/*
|
||||
* 支付方式: ALI_LITE
|
||||
*
|
||||
* @author terrfly
|
||||
* @site https://www.jeequan.com
|
||||
* @date 2021/6/8 17:34
|
||||
*/
|
||||
@Data
|
||||
public class AliLiteOrderRS extends UnifiedOrderRS {
|
||||
|
||||
/** 调起支付插件的支付宝订单号 **/
|
||||
private String alipayTradeNo;
|
||||
|
||||
@Override
|
||||
public String buildPayDataType(){
|
||||
return CS.PAY_DATA_TYPE.ALI_APP;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String buildPayData(){
|
||||
return JsonKit.newJson("alipayTradeNo", alipayTradeNo).toString();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2031, 河北计全科技有限公司 (https://www.jeequan.com & jeequan@126.com).
|
||||
* <p>
|
||||
* 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
|
||||
* <p>
|
||||
* http://www.gnu.org/licenses/lgpl.html
|
||||
* <p>
|
||||
* 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.rqrs.payorder.payway;
|
||||
|
||||
import com.jeequan.jeepay.core.constants.CS;
|
||||
import com.jeequan.jeepay.pay.rqrs.payorder.UnifiedOrderRQ;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
|
||||
/*
|
||||
* 支付方式: WX_LITE
|
||||
*
|
||||
* @author zhuxiao
|
||||
* @site https://www.jeequan.com
|
||||
* @date 2021/6/8 17:34
|
||||
*/
|
||||
@Data
|
||||
public class WxLiteOrderRQ extends UnifiedOrderRQ {
|
||||
|
||||
/** 微信openid **/
|
||||
@NotBlank(message = "openid不能为空")
|
||||
private String openid;
|
||||
|
||||
/** 标志是否为 subMchLiteAppId的对应 openId, 0-否, 1-是, 默认否 **/
|
||||
private Byte isSubOpenId;
|
||||
|
||||
/** 构造函数 **/
|
||||
public WxLiteOrderRQ(){
|
||||
this.setWayCode(CS.PAY_WAY_CODE.WX_LITE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getChannelUserId() {
|
||||
return this.openid;
|
||||
}
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2031, 河北计全科技有限公司 (https://www.jeequan.com & jeequan@126.com).
|
||||
* <p>
|
||||
* 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
|
||||
* <p>
|
||||
* http://www.gnu.org/licenses/lgpl.html
|
||||
* <p>
|
||||
* 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.rqrs.payorder.payway;
|
||||
|
||||
import com.jeequan.jeepay.core.constants.CS;
|
||||
import com.jeequan.jeepay.pay.rqrs.payorder.UnifiedOrderRS;
|
||||
import lombok.Data;
|
||||
|
||||
/*
|
||||
* 支付方式: WX_LITE
|
||||
*
|
||||
* @author zhuxiao
|
||||
* @site https://www.jeequan.com
|
||||
* @date 2021/6/8 17:34
|
||||
*/
|
||||
@Data
|
||||
public class WxLiteOrderRS extends UnifiedOrderRS {
|
||||
|
||||
/** 预支付数据包 **/
|
||||
private String payInfo;
|
||||
|
||||
@Override
|
||||
public String buildPayDataType(){
|
||||
return CS.PAY_DATA_TYPE.WX_APP;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String buildPayData(){
|
||||
return payInfo;
|
||||
}
|
||||
|
||||
}
|
BIN
libs/jeepay-sdk-java-pls-1.0.0.jar
Normal file
BIN
libs/jeepay-sdk-java-pls-1.0.0.jar
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user