2024-11-21 12:18:28 +08:00
|
|
|
package pay
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"net/http"
|
2025-04-09 15:58:06 +08:00
|
|
|
|
|
|
|
"github.com/smartwalle/alipay/v3"
|
|
|
|
|
2025-04-27 12:17:18 +08:00
|
|
|
"tyc-server/app/main/api/internal/svc"
|
2024-11-21 12:18:28 +08:00
|
|
|
|
|
|
|
"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 {
|
2025-05-27 18:35:01 +08:00
|
|
|
err := l.svcCtx.PayService.HandlePaymentCallback(l.ctx, "alipay", r)
|
2024-11-21 12:18:28 +08:00
|
|
|
if err != nil {
|
|
|
|
logx.Errorf("支付宝支付回调,%+v", err)
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
alipay.ACKNotification(w)
|
|
|
|
return nil
|
|
|
|
}
|