package logic import ( "context" "fmt" "lone-services/pkg/utils" userpb "lone-services/rpc/user/pb" "lone-services/services/payment/internal/svc" ) func loadOpenID(ctx context.Context, userSvcName string, userID int64) (string, error) { if userSvcName == utils.StringEmpty { return utils.StringEmpty, fmt.Errorf("user service not configured") } if userID < utils.NumberOne { return utils.StringEmpty, fmt.Errorf("invalid user id") } cli, err := svc.GetRpcClient(userSvcName) if err != nil { return utils.StringEmpty, err } info, err := userpb.NewUserClient(cli.Conn()).InternalGetUserInfo(ctx, &userpb.InternalGetUserInfoReq{ UserId: userID, CredentialType: "openid", }) if err != nil { return utils.StringEmpty, err } if info == nil || info.Identifier == utils.StringEmpty { return utils.StringEmpty, fmt.Errorf("openid credential not found") } return info.Identifier, nil }