Selaa lähdekoodia

🛠️ fix: billing session error handling for subscription-first fallback.

Aligns the error variable types in the subscription-first path so that quota fallback checks use the correct NewAPIError.
This prevents build failures and preserves the intended wallet fallback when subscription pre-consume returns an insufficient quota error.
t0ng7u 4 viikkoa sitten
vanhempi
commit
10c5f5f906
1 muutettua tiedostoa jossa 7 lisäystä ja 7 poistoa
  1. 7 7
      service/billing_session.go

+ 7 - 7
service/billing_session.go

@@ -323,19 +323,19 @@ func NewBillingSession(c *gin.Context, relayInfo *relaycommon.RelayInfo, preCons
 	case "subscription_first":
 		fallthrough
 	default:
-		hasSub, err := model.HasActiveUserSubscription(relayInfo.UserId)
-		if err != nil {
-			return nil, types.NewError(err, types.ErrorCodeQueryDataError, types.ErrOptionWithSkipRetry())
+		hasSub, subCheckErr := model.HasActiveUserSubscription(relayInfo.UserId)
+		if subCheckErr != nil {
+			return nil, types.NewError(subCheckErr, types.ErrorCodeQueryDataError, types.ErrOptionWithSkipRetry())
 		}
 		if !hasSub {
 			return tryWallet()
 		}
-		session, err := trySubscription()
-		if err != nil {
-			if err.GetErrorCode() == types.ErrorCodeInsufficientUserQuota {
+		session, apiErr := trySubscription()
+		if apiErr != nil {
+			if apiErr.GetErrorCode() == types.ErrorCodeInsufficientUserQuota {
 				return tryWallet()
 			}
-			return nil, err
+			return nil, apiErr
 		}
 		return session, nil
 	}