tyc-server/app/main/api/internal/logic/pay/alipaycallbacklogic.go
2025-05-27 18:35:01 +08:00

37 lines
759 B
Go

package pay
import (
"context"
"net/http"
"github.com/smartwalle/alipay/v3"
"tyc-server/app/main/api/internal/svc"
"github.com/zeromicro/go-zero/core/logx"
)
type AlipayCallbackLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewAlipayCallbackLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AlipayCallbackLogic {
return &AlipayCallbackLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *AlipayCallbackLogic) AlipayCallback(w http.ResponseWriter, r *http.Request) error {
err := l.svcCtx.PayService.HandlePaymentCallback(l.ctx, "alipay", r)
if err != nil {
logx.Errorf("支付宝支付回调,%+v", err)
return nil
}
alipay.ACKNotification(w)
return nil
}