mirror of https://gitee.com/stylefeng/roses
【7.0.4】整理支付代码
parent
1f3a58c356
commit
2b8ec525b6
|
@ -11,10 +11,4 @@
|
|||
|
||||
<artifactId>pay-api</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
</properties>
|
||||
|
||||
|
||||
</project>
|
|
@ -38,36 +38,34 @@ public interface PayApi {
|
|||
/**
|
||||
* PC网页支付
|
||||
*
|
||||
* @param orderName 订单名称
|
||||
* @param orderName 订单名称
|
||||
* @param outTradeNo 商家订单编号
|
||||
* @param total 金额
|
||||
* @param returnUrl 付款完成后跳转页面
|
||||
* @param total 金额
|
||||
* @param returnUrl 付款完成后跳转页面
|
||||
* @return 支付页面
|
||||
* @author huziyang
|
||||
* @date 2021/04/20 20:43
|
||||
*/
|
||||
String page(String orderName, String outTradeNo, String total, String returnUrl);
|
||||
|
||||
|
||||
/**
|
||||
* 手机支付
|
||||
*
|
||||
* @param orderName 订单名称
|
||||
* @param orderName 订单名称
|
||||
* @param outTradeNo 商家订单编号
|
||||
* @param total 金额
|
||||
* @param quitUrl 中途退出时返回的页面
|
||||
* @param returnUrl 付款完成后跳转页面
|
||||
* @param total 金额
|
||||
* @param quitUrl 中途退出时返回的页面
|
||||
* @param returnUrl 付款完成后跳转页面
|
||||
* @return 支付页面
|
||||
* @author huziyang
|
||||
* @date 2021/04/20 20:43
|
||||
*/
|
||||
String wap(String orderName, String outTradeNo, String total, String quitUrl, String returnUrl);
|
||||
|
||||
|
||||
/**
|
||||
* 退款
|
||||
*
|
||||
* @param outTradeNo 商家订单编号
|
||||
* @param outTradeNo 商家订单编号
|
||||
* @param refundAmount 退款金额
|
||||
* @return 退款结果
|
||||
* @author huziyang
|
||||
|
@ -75,5 +73,4 @@ public interface PayApi {
|
|||
*/
|
||||
TradeRefundResponse refund(String outTradeNo, String refundAmount);
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -42,7 +42,6 @@ public interface PayConstants {
|
|||
*/
|
||||
String PAY_EXCEPTION_STEP_CODE = "80";
|
||||
|
||||
|
||||
/**
|
||||
* 退款成功的返回码
|
||||
*/
|
||||
|
|
|
@ -25,7 +25,10 @@
|
|||
package cn.stylefeng.roses.kernel.pay.api.pojo;
|
||||
|
||||
import cn.stylefeng.roses.kernel.pay.api.constants.PayConstants;
|
||||
import lombok.*;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 退款响应
|
||||
|
@ -37,7 +40,7 @@ import lombok.*;
|
|||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class TradeRefundResponse{
|
||||
public class TradeRefundResponse {
|
||||
|
||||
/**
|
||||
* 退款状态码
|
||||
|
@ -88,12 +91,12 @@ public class TradeRefundResponse{
|
|||
* 初始化一个新创建的 TradeRefundResponse对象
|
||||
*
|
||||
* @param code 状态码
|
||||
* @param msg 描述
|
||||
* @param msg 描述
|
||||
* @param data 对象值
|
||||
* @author huziyang
|
||||
* @date 2021/04/20 20:43
|
||||
*/
|
||||
public TradeRefundResponse(String code, String msg, Object data){
|
||||
public TradeRefundResponse(String code, String msg, Object data) {
|
||||
this.code = code;
|
||||
this.msg = msg;
|
||||
this.data = data;
|
||||
|
@ -102,17 +105,16 @@ public class TradeRefundResponse{
|
|||
/**
|
||||
* 返回错误信息
|
||||
*
|
||||
* @param msg 描述
|
||||
* @param msg 描述
|
||||
* @param data 对象值
|
||||
* @return TradeRefundResponse对象
|
||||
* @author huziyang
|
||||
* @date 2021/04/20 20:43
|
||||
*/
|
||||
public static TradeRefundResponse error(String msg, Object data){
|
||||
return new TradeRefundResponse(PayConstants.REFUND_ERROR_CODE,msg,data);
|
||||
public static TradeRefundResponse error(String msg, Object data) {
|
||||
return new TradeRefundResponse(PayConstants.REFUND_ERROR_CODE, msg, data);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 返回错误信息
|
||||
*
|
||||
|
@ -121,9 +123,8 @@ public class TradeRefundResponse{
|
|||
* @author huziyang
|
||||
* @date 2021/04/20 20:43
|
||||
*/
|
||||
public static TradeRefundResponse error(String msg){
|
||||
return error(msg,null);
|
||||
public static TradeRefundResponse error(String msg) {
|
||||
return error(msg, null);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -11,25 +11,20 @@
|
|||
|
||||
<artifactId>pay-sdk-alipay</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<!--支付模块的api-->
|
||||
<dependency>
|
||||
<groupId>cn.stylefeng.roses</groupId>
|
||||
<artifactId>pay-api</artifactId>
|
||||
<version>7.0.4</version>
|
||||
<version>${roses.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!--阿里支付sdk-->
|
||||
<dependency>
|
||||
<groupId>com.alipay.sdk</groupId>
|
||||
<artifactId>alipay-easysdk</artifactId>
|
||||
<version>2.2.0</version>
|
||||
<version>${alipay.version}</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
|
|
@ -48,7 +48,7 @@ public class AlipayConfig implements ApplicationRunner {
|
|||
|
||||
/**
|
||||
* 私钥
|
||||
*/
|
||||
*/
|
||||
@Value("${alipay.merchantPrivateKey}")
|
||||
private String merchantPrivateKey;
|
||||
|
||||
|
@ -132,5 +132,4 @@ public class AlipayConfig implements ApplicationRunner {
|
|||
return config;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -33,4 +33,5 @@ package cn.stylefeng.roses.kernel.pay.alipay.constants;
|
|||
public interface AlipayConstants {
|
||||
|
||||
String ALIPAY_REFUND_SUCCESS_CODE = "10000";
|
||||
|
||||
}
|
||||
|
|
|
@ -38,36 +38,34 @@ public interface AlipayService {
|
|||
/**
|
||||
* PC网页支付
|
||||
*
|
||||
* @param orderName 订单名称
|
||||
* @param orderName 订单名称
|
||||
* @param outTradeNo 商家订单编号
|
||||
* @param total 金额
|
||||
* @param returnUrl 付款完成后跳转页面
|
||||
* @param total 金额
|
||||
* @param returnUrl 付款完成后跳转页面
|
||||
* @return 支付页面
|
||||
* @author huziyang
|
||||
* @date 2021/04/20 20:43
|
||||
*/
|
||||
String page(String orderName, String outTradeNo, String total, String returnUrl);
|
||||
|
||||
|
||||
/**
|
||||
* 手机支付
|
||||
*
|
||||
* @param orderName 订单名称
|
||||
* @param orderName 订单名称
|
||||
* @param outTradeNo 商家订单编号
|
||||
* @param total 金额
|
||||
* @param quitUrl 中途退出时返回的页面
|
||||
* @param returnUrl 付款完成后跳转页面
|
||||
* @param total 金额
|
||||
* @param quitUrl 中途退出时返回的页面
|
||||
* @param returnUrl 付款完成后跳转页面
|
||||
* @return 支付页面
|
||||
* @author huziyang
|
||||
* @date 2021/04/20 20:43
|
||||
*/
|
||||
String wap(String orderName, String outTradeNo, String total, String quitUrl, String returnUrl);
|
||||
|
||||
|
||||
/**
|
||||
* 退款
|
||||
*
|
||||
* @param outTradeNo 商家订单编号
|
||||
* @param outTradeNo 商家订单编号
|
||||
* @param refundAmount 退款金额
|
||||
* @return 退款结果
|
||||
* @author huziyang
|
||||
|
@ -75,5 +73,4 @@ public interface AlipayService {
|
|||
*/
|
||||
TradeRefundResponse refund(String outTradeNo, String refundAmount);
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -44,7 +44,6 @@ import org.springframework.stereotype.Service;
|
|||
@Slf4j
|
||||
public class AlipayServiceImpl implements AlipayService, PayApi {
|
||||
|
||||
|
||||
@Override
|
||||
public String page(String orderName, String outTradeNo, String total, String returnUrl) {
|
||||
try {
|
||||
|
@ -58,7 +57,7 @@ public class AlipayServiceImpl implements AlipayService, PayApi {
|
|||
@Override
|
||||
public String wap(String orderName, String outTradeNo, String total, String quitUrl, String returnUrl) {
|
||||
try {
|
||||
return Factory.Payment.Wap().pay(orderName, outTradeNo, total, quitUrl, returnUrl).body;
|
||||
return Factory.Payment.Wap().pay(orderName, outTradeNo, total, quitUrl, returnUrl).body;
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage());
|
||||
return e.getMessage();
|
||||
|
@ -69,7 +68,7 @@ public class AlipayServiceImpl implements AlipayService, PayApi {
|
|||
public TradeRefundResponse refund(String outTradeNo, String refundAmount) {
|
||||
try {
|
||||
AlipayTradeRefundResponse response = Factory.Payment.Common().refund(outTradeNo, refundAmount);
|
||||
if (AlipayConstants.ALIPAY_REFUND_SUCCESS_CODE.equals(response.getCode())){
|
||||
if (AlipayConstants.ALIPAY_REFUND_SUCCESS_CODE.equals(response.getCode())) {
|
||||
return TradeRefundResponse.builder()
|
||||
.code(PayConstants.REFUND_SUCCESS_CODE)
|
||||
.msg(response.getMsg())
|
||||
|
@ -82,10 +81,11 @@ public class AlipayServiceImpl implements AlipayService, PayApi {
|
|||
.data(response)
|
||||
.build();
|
||||
}
|
||||
return TradeRefundResponse.error(response.msg,response);
|
||||
return TradeRefundResponse.error(response.msg, response);
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage());
|
||||
return TradeRefundResponse.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -11,18 +11,15 @@
|
|||
|
||||
<artifactId>pay-spring-boot-starter</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<!--alipay api模块的sdk-->
|
||||
<dependency>
|
||||
<groupId>cn.stylefeng.roses</groupId>
|
||||
<artifactId>pay-sdk-alipay</artifactId>
|
||||
<version>7.0.4</version>
|
||||
<version>${roses.version}</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
|
@ -49,6 +49,5 @@ public class GunsPayAutoConfiguration {
|
|||
return new AlipayServiceImpl();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
<alipay.version>2.2.0</alipay.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
|
@ -28,7 +29,7 @@
|
|||
<dependency>
|
||||
<groupId>cn.stylefeng.roses</groupId>
|
||||
<artifactId>kernel-a-rule</artifactId>
|
||||
<version>7.0.4</version>
|
||||
<version>${roses.version}</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
|
Loading…
Reference in New Issue