code review 支付宝 wap 的逻辑
This commit is contained in:
parent
a1105ffdc7
commit
6cadafb3f1
@ -6,8 +6,6 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.time.Duration;
|
||||
|
||||
@ConfigurationProperties(prefix = "yudao.pay")
|
||||
@Validated
|
||||
@ -25,11 +23,11 @@ public class PayProperties {
|
||||
* 退款回调地址
|
||||
* 注意点,同 {@link #payNotifyUrl} 属性
|
||||
*/
|
||||
@NotNull(message = "短信发送频率不能为空")
|
||||
@NotEmpty(message = "短信发送频率不能为空")
|
||||
@URL(message = "退款回调地址的格式必须是 URL")
|
||||
private String refundNotifyUrl;
|
||||
|
||||
|
||||
// TODO @jason:改成 payReturnUrl 。另外,可以加个 @NotEmpty,避免未填写
|
||||
/**
|
||||
* 支付完成的返回地址
|
||||
*/
|
||||
|
@ -6,12 +6,15 @@ import lombok.ToString;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
// TODO @jason:NotifyDataDTO=》PayNotifyDataDTO。另外注释记得加起来哈
|
||||
@Data
|
||||
@ToString
|
||||
@Builder
|
||||
public class NotifyDataDTO {
|
||||
|
||||
// TODO @jason:这个字段,改成 body
|
||||
private String origData;
|
||||
// TODO @jason:这个字段如果暂时没用,可以去掉。
|
||||
//1:xml 2:form
|
||||
private int format;
|
||||
|
||||
|
@ -44,13 +44,15 @@ public class PayOrderUnifiedReqDTO {
|
||||
@Length(max = 128, message = "商品描述信息长度不能超过128")
|
||||
private String body;
|
||||
/**
|
||||
* 支付结果的回调地址
|
||||
* 支付结果的 notify 回调地址
|
||||
*/
|
||||
@NotEmpty(message = "支付结果的回调地址不能为空")
|
||||
@URL(message = "支付结果的回调地址必须是 URL 格式")
|
||||
@URL(message = "支付结果的 notify 回调地址必须是 URL 格式")
|
||||
private String notifyUrl;
|
||||
|
||||
@URL(message = "支付结果的return 必须是 URL 格式")
|
||||
/**
|
||||
* 支付结果的 return 回调地址
|
||||
*/
|
||||
@URL(message = "支付结果的 return 回调地址必须是 URL 格式")
|
||||
private String returnUrl;
|
||||
|
||||
// ========== 订单相关字段 ==========
|
||||
|
@ -19,7 +19,7 @@ public class AlipayPayCodeMapping extends AbstractPayCodeMapping {
|
||||
return GlobalErrorCodeConstants.SUCCESS;
|
||||
}
|
||||
// alipay wap api code 返回为null, 暂时定为-9999
|
||||
if(Objects.equals(apiCode, "-9999")){
|
||||
if(Objects.equals(apiCode, "-9999")){ // TODO @jason:空格要注意哈。if () {
|
||||
return GlobalErrorCodeConstants.SUCCESS;
|
||||
}
|
||||
return null;
|
||||
|
@ -51,6 +51,7 @@ public class AlipayWapPayClient extends AbstractPayClient<AlipayPayClientConfig>
|
||||
model.setTotalAmount(calculateAmount(reqDTO.getAmount()).toString());
|
||||
model.setProductCode("QUICK_WAP_PAY"); // TODO 芋艿:这里咋整
|
||||
//TODO 芋艿:这里咋整 jason @芋艿 可以去掉吧,
|
||||
// TODO @jason: 这个支付方式,需要有 sellerId 么?
|
||||
//model.setSellerId("2088102147948060");
|
||||
model.setTimeExpire(DateUtil.format(reqDTO.getExpireTime(),"yyyy-MM-dd HH:mm:ss"));
|
||||
// TODO 芋艿:userIp
|
||||
@ -76,7 +77,7 @@ public class AlipayWapPayClient extends AbstractPayClient<AlipayPayClientConfig>
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// TODO @jason: 注释记得补下哈
|
||||
/**
|
||||
* //https://opendocs.alipay.com/open/203/105286
|
||||
* @param data 通知结果
|
||||
@ -92,4 +93,5 @@ public class AlipayWapPayClient extends AbstractPayClient<AlipayPayClientConfig>
|
||||
.successTime(DateUtil.parse(params.get("notify_time"), "yyyy-MM-dd HH:mm:ss"))
|
||||
.data(data.getOrigData()).build();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -79,13 +79,14 @@ public class PayOrderController {
|
||||
@PostMapping(value = "/notify/alipay-wap/{channelId}", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
|
||||
@ApiOperation("支付宝wap页面回调")
|
||||
public String notifyAliPayWapPayOrder(@PathVariable("channelId") Long channelId,
|
||||
@RequestParam Map<String, String> params,
|
||||
@RequestBody String originData) throws Exception {
|
||||
@RequestParam Map<String, String> params,
|
||||
@RequestBody String originData) throws Exception {
|
||||
//TODO @jason 校验 是否支付宝调用。 使用 支付宝publickey payclient 或许加一个校验方法
|
||||
payOrderCoreService.notifyPayOrder(channelId, PayChannelEnum.ALIPAY_WAP.getCode(), NotifyDataDTO.builder().params(params).origData(originData).build());
|
||||
return "success";
|
||||
}
|
||||
|
||||
// TODO @jason 如果有些字段不注释,可以删除哈。不然 IDEA 会报警
|
||||
/**
|
||||
* https://opendocs.alipay.com/open/203/105285#%E5%89%8D%E5%8F%B0%E5%9B%9E%E8%B7%B3%E5%8F%82%E6%95%B0%E8%AF%B4%E6%98%8E
|
||||
* @param channelId
|
||||
|
@ -14,6 +14,7 @@
|
||||
<div id="dynamic_form"></div>
|
||||
</body>
|
||||
<script>
|
||||
// TODO @jason:copy 过来后,有些注释要改过来哈
|
||||
let shopOrderId = undefined;
|
||||
let payOrderId = undefined;
|
||||
let server = 'http://127.0.0.1:28080';
|
||||
|
Loading…
Reference in New Issue
Block a user