wechat:
#公众号appid
mpAppId:
#商户号
mchId:
#商户api v2 秘钥
mchKey:
#证书地址
keyPath: wxpay.p12
#回调地址
notifyUrl:
#小程序appid
miniAppId: x
#小程序秘钥
miniAppSecret: x
#app appid
appAppId: x
alipay:
appId:
privateKey:
aliPayPublicKey:
notifyUrl:
returnUrl:
sandbox: false #是否使用沙箱
@Data
@Accessors(chain = true)
public class PayParam {
@ApiModelProperty("支付类型 WXPAY_NATIVE 微信Native支付 ALIPAY_PC 支付宝pc")
@NotBlank
private BestPayTypeEnum payType;
@ApiModelProperty("支付金额")
@NotNull
private BigDecimal amount;
}
PayRequest prq = new PayRequest();
//支付类型
prq.setPayTypeEnum(param.getPayType());
//金额
prq.setOrderAmount(param.getAmount().doubleValue());
prq.setOrderName("订单名称");
prq.setAttach("备注");
prq.setOrderId(this.generateOrderId());
//申请支付订单
PayResponse prs = this.bestPayService.pay(prq);
注意:一定要自己使用demo做支付宝pc扫码支付测试
<html>
<head></head>
<body>
<script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<script>
$(function () {
$.ajax({
method: "post",
headers: {
"token": "xxxxxx"
},
url: "http://localhost:8700/xxxxxx",
data: JSON.stringify({
"amount": 0.01,
"payType": "ALIPAY_PC"
}),
contentType: "application/json",
dataType: "json",
success: function (res) {
let formBody = res.data.body; //支付宝支付成功后返回的表单
const div = document.createElement('div');
div.innerHTML = formBody;
document.body.appendChild(div);
document.forms[0].submit();
}
});
});
</script>
</body>
</html>