|
@@ -12,6 +12,7 @@ import com.yonge.toolset.payment.base.model.ClosePayment;
|
|
import com.yonge.toolset.payment.base.model.OpenAuth;
|
|
import com.yonge.toolset.payment.base.model.OpenAuth;
|
|
import com.yonge.toolset.payment.base.model.Payment;
|
|
import com.yonge.toolset.payment.base.model.Payment;
|
|
import com.yonge.toolset.payment.base.model.RefundBill;
|
|
import com.yonge.toolset.payment.base.model.RefundBill;
|
|
|
|
+import com.yonge.toolset.payment.core.props.PaymentProperties;
|
|
import com.yonge.toolset.payment.core.service.SysConfigPaymentService;
|
|
import com.yonge.toolset.payment.core.service.SysConfigPaymentService;
|
|
import com.yonge.toolset.utils.string.StringUtil;
|
|
import com.yonge.toolset.utils.string.StringUtil;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.Logger;
|
|
@@ -28,6 +29,8 @@ public class AdapayTemplate implements PaymentTemplate {
|
|
private final static Logger log = LoggerFactory.getLogger(AdapayTemplate.class);
|
|
private final static Logger log = LoggerFactory.getLogger(AdapayTemplate.class);
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
|
|
+ private PaymentProperties paymentProperties;
|
|
|
|
+ @Autowired
|
|
private SysConfigPaymentService configPaymentService;
|
|
private SysConfigPaymentService configPaymentService;
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -36,7 +39,7 @@ public class AdapayTemplate implements PaymentTemplate {
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public BaseResult<Payment> executePayment(Payment payment){
|
|
|
|
|
|
+ public BaseResult<Payment> executePayment(Payment payment) {
|
|
Map<String, Object> paymentMap = new HashMap<>();
|
|
Map<String, Object> paymentMap = new HashMap<>();
|
|
paymentMap.put("order_no", payment.getPaymentNo());
|
|
paymentMap.put("order_no", payment.getPaymentNo());
|
|
paymentMap.put("app_id", configPaymentService.getPaymentConfig(payment.getOpenType(), AdapayConstant.APP_ID).getParamValue());
|
|
paymentMap.put("app_id", configPaymentService.getPaymentConfig(payment.getOpenType(), AdapayConstant.APP_ID).getParamValue());
|
|
@@ -48,8 +51,11 @@ public class AdapayTemplate implements PaymentTemplate {
|
|
paymentMap.put("description", payment.getDescription());
|
|
paymentMap.put("description", payment.getDescription());
|
|
paymentMap.put("device_info", payment.getDeviceInfo());
|
|
paymentMap.put("device_info", payment.getDeviceInfo());
|
|
paymentMap.put("expend", payment.getExpend());
|
|
paymentMap.put("expend", payment.getExpend());
|
|
- paymentMap.put("notify_url",
|
|
|
|
- StringUtil.isEmpty(payment.getNotifyUrl()) ? configPaymentService.getPaymentConfig(payment.getOpenType(), AdapayConstant.NOTIFY_URL).getParamValue() : payment.getNotifyUrl());
|
|
|
|
|
|
+ paymentMap.put("notify_url", paymentProperties.getNotifyUrl()
|
|
|
|
+ + "/" + payment.getOpenType().getCode()
|
|
|
|
+ + "/" + payment.getPayChannel().getCode()
|
|
|
|
+ + "/executePayment"
|
|
|
|
+ );
|
|
|
|
|
|
log.info("汇付[创建支付对象] Req:{}", JSONObject.toJSONString(paymentMap));
|
|
log.info("汇付[创建支付对象] Req:{}", JSONObject.toJSONString(paymentMap));
|
|
//调用sdk方法,创建支付,得到支付对象
|
|
//调用sdk方法,创建支付,得到支付对象
|
|
@@ -103,9 +109,11 @@ public class AdapayTemplate implements PaymentTemplate {
|
|
paymentParams.put("payment_id", closePayment.getId());
|
|
paymentParams.put("payment_id", closePayment.getId());
|
|
paymentParams.put("reason", closePayment.getReason());
|
|
paymentParams.put("reason", closePayment.getReason());
|
|
paymentParams.put("expend", closePayment.getExpend());
|
|
paymentParams.put("expend", closePayment.getExpend());
|
|
- paymentParams.put("notify_url",
|
|
|
|
- StringUtil.isEmpty(closePayment.getNotifyUrl()) ? configPaymentService.getPaymentConfig(closePayment.getOpenType(), AdapayConstant.NOTIFY_URL).getParamValue() : closePayment.getNotifyUrl());
|
|
|
|
-
|
|
|
|
|
|
+ paymentParams.put("notify_url", paymentProperties.getNotifyUrl()
|
|
|
|
+ + "/" + closePayment.getOpenType().getCode()
|
|
|
|
+ + "/" + closePayment.getPayChannel().getCode()
|
|
|
|
+ + "/closePayment"
|
|
|
|
+ );
|
|
Map<String, Object> res;
|
|
Map<String, Object> res;
|
|
try {
|
|
try {
|
|
res = com.huifu.adapay.model.Payment.close(paymentParams);
|
|
res = com.huifu.adapay.model.Payment.close(paymentParams);
|
|
@@ -126,13 +134,15 @@ public class AdapayTemplate implements PaymentTemplate {
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public BaseResult<RefundBill> refundPayment(RefundBill refundBill) {
|
|
|
|
|
|
+ public BaseResult<RefundBill> refundPayment(RefundBill refundBill) {
|
|
Map<String, Object> refundParams = new HashMap<>(10);
|
|
Map<String, Object> refundParams = new HashMap<>(10);
|
|
refundParams.put("refund_amt", refundBill.getRefundAmt());
|
|
refundParams.put("refund_amt", refundBill.getRefundAmt());
|
|
refundParams.put("refund_order_no", refundBill.getRefundNo());
|
|
refundParams.put("refund_order_no", refundBill.getRefundNo());
|
|
- refundParams.put("notify_url",
|
|
|
|
- StringUtil.isEmpty(refundBill.getNotifyUrl()) ? configPaymentService.getPaymentConfig(refundBill.getOpenType(), AdapayConstant.NOTIFY_URL).getParamValue() : refundBill.getNotifyUrl());
|
|
|
|
-
|
|
|
|
|
|
+ refundParams.put("notify_url", paymentProperties.getNotifyUrl()
|
|
|
|
+ + "/" + refundBill.getOpenType().getCode()
|
|
|
|
+ + "/" + refundBill.getPayChannel().getCode()
|
|
|
|
+ + "/refundPayment"
|
|
|
|
+ );
|
|
Map<String, Object> res;
|
|
Map<String, Object> res;
|
|
try {
|
|
try {
|
|
res = Refund.create(refundBill.getId(), refundParams);
|
|
res = Refund.create(refundBill.getId(), refundParams);
|