Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

异步验签回调返回"fail"不会重试 #423

Open
xinhaohaohaohao opened this issue Sep 27, 2024 · 1 comment
Open

异步验签回调返回"fail"不会重试 #423

xinhaohaohaohao opened this issue Sep 27, 2024 · 1 comment

Comments

@xinhaohaohaohao
Copy link

我使用新版沙箱做网页支付异步回调测试,支付成功后会成功回调,但是当我写死"fail",测试支付宝服务器重新发送回调请求却收不到

router.POST("/payment/handler/async", notifyHandler)

func notifyHandler(ctx *gin.Context) {
// 从请求中解析通知内容
r := ctx.Request
noti, err := alipay.ParseNotifyToBodyMap(r)
if err != nil {
xlog.Errorf("ParseNotifyToBodyMap error: %v", err)
ctx.String(http.StatusBadRequest, "%s", "fail")
//w.WriteHeader(http.StatusBadRequest)
return
}

// 验证通知是否来自支付宝
ok, err := alipay.VerifySignWithCert("./沙箱默认应用:2088721045264951/alipayPublicCert.crt", noti)
if err != nil {
	xlog.Errorf("VerifySignWithCert error: %v", err)
	ctx.String(http.StatusBadRequest, "s", "fail")
	//w.WriteHeader(http.StatusBadRequest)
	return
}
if !ok {
	xlog.Error("Sign not matched")
	ctx.String(http.StatusBadRequest, "%s", "fail")
	//w.WriteHeader(http.StatusBadRequest)
	return
}

// 处理业务逻辑,例如更新订单状态
tradeStatus := noti.Get("trade_status")
outTradeNo := noti.Get("out_trade_no")
fmt.Println("交易状态:", tradeStatus)
fmt.Println("订单号:", outTradeNo)

// 返回给支付宝成功通知

ctx.String(http.StatusOK, "%s", "fail")
//w.Write([]byte("success"))

}

@iGoogle-ink
Copy link
Member

@xinhaohaohaohao 会不会支付宝沙箱就不支持重试呢?这个情况我没尝试过,条件不允许哎

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants