mirror of
https://github.com/QuantumNous/new-api.git
synced 2026-03-30 04:20:47 +00:00
Merge pull request #2879 from QuantumNous/fix/subscription-preference-fallback
✨ chore: Improve subscription billing fallback and UI states
This commit is contained in:
@@ -323,12 +323,19 @@ func NewBillingSession(c *gin.Context, relayInfo *relaycommon.RelayInfo, preCons
|
||||
case "subscription_first":
|
||||
fallthrough
|
||||
default:
|
||||
session, err := trySubscription()
|
||||
if err != nil {
|
||||
if err.GetErrorCode() == types.ErrorCodeInsufficientUserQuota {
|
||||
hasSub, subCheckErr := model.HasActiveUserSubscription(relayInfo.UserId)
|
||||
if subCheckErr != nil {
|
||||
return nil, types.NewError(subCheckErr, types.ErrorCodeQueryDataError, types.ErrOptionWithSkipRetry())
|
||||
}
|
||||
if !hasSub {
|
||||
return tryWallet()
|
||||
}
|
||||
session, apiErr := trySubscription()
|
||||
if apiErr != nil {
|
||||
if apiErr.GetErrorCode() == types.ErrorCodeInsufficientUserQuota {
|
||||
return tryWallet()
|
||||
}
|
||||
return nil, err
|
||||
return nil, apiErr
|
||||
}
|
||||
return session, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user