diff --git a/src/__tests__/app/api/user-route.test.ts b/src/__tests__/app/api/user-route.test.ts index cc78262..015212f 100644 --- a/src/__tests__/app/api/user-route.test.ts +++ b/src/__tests__/app/api/user-route.test.ts @@ -102,4 +102,13 @@ describe('GET /api/user', () => { expect(data.config.enabledPaymentTypes).toEqual(['alipay', 'wxpay', 'stripe']); expect(mockQueryMethodLimits).toHaveBeenCalledWith(['alipay', 'wxpay', 'stripe']); }); + + it('falls back to supported payment types when ENABLED_PAYMENT_TYPES is undefined', async () => { + const response = await GET(createRequest()); + const data = await response.json(); + + expect(response.status).toBe(200); + expect(data.config.enabledPaymentTypes).toEqual(['alipay', 'wxpay', 'stripe']); + expect(mockQueryMethodLimits).toHaveBeenCalledWith(['alipay', 'wxpay', 'stripe']); + }); }); diff --git a/src/app/api/user/route.ts b/src/app/api/user/route.ts index c35481a..36bf7f8 100644 --- a/src/app/api/user/route.ts +++ b/src/app/api/user/route.ts @@ -55,12 +55,12 @@ export async function GET(request: NextRequest) { const env = getEnv(); initPaymentProviders(); const supportedTypes = paymentRegistry.getSupportedTypes(); - const [user, configuredEnabledTypes, balanceDisabledVal] = await Promise.all([ + const [user, configuredPaymentTypesRaw, balanceDisabledVal] = await Promise.all([ getUser(userId), getSystemConfig('ENABLED_PAYMENT_TYPES'), getSystemConfig('BALANCE_PAYMENT_DISABLED'), ]); - const enabledTypes = resolveEnabledPaymentTypes(supportedTypes, configuredEnabledTypes); + const enabledTypes = resolveEnabledPaymentTypes(supportedTypes, configuredPaymentTypesRaw); const methodLimits = await queryMethodLimits(enabledTypes); const balanceDisabled = balanceDisabledVal === 'true';