From d02f8a3e2f6f8900a32c0cfdd538a4034eea4a73 Mon Sep 17 00:00:00 2001 From: erio Date: Tue, 7 Apr 2026 01:49:45 +0800 Subject: [PATCH] fix(payment): structured error responses + disable provider card hint overlay - Backend: PENDING_ORDERS error uses reason+metadata per CLAUDE.md spec - Block disabling provider when it has pending orders - ProviderCard: remove bottom hint area, use opacity + title tooltip instead --- backend/cmd/server/VERSION | 2 +- .../service/payment_config_service.go | 16 +++++++++++++-- .../src/components/payment/ProviderCard.vue | 20 ++++++++----------- 3 files changed, 23 insertions(+), 15 deletions(-) diff --git a/backend/cmd/server/VERSION b/backend/cmd/server/VERSION index 5937c07da5..4192764a15 100644 --- a/backend/cmd/server/VERSION +++ b/backend/cmd/server/VERSION @@ -1 +1 @@ -0.1.108.48 +0.1.108.49 diff --git a/backend/internal/service/payment_config_service.go b/backend/internal/service/payment_config_service.go index 1ad6cc2af4..94a3d99f33 100644 --- a/backend/internal/service/payment_config_service.go +++ b/backend/internal/service/payment_config_service.go @@ -392,12 +392,24 @@ func (s *PaymentConfigService) UpdateProviderInstance(ctx context.Context, id in return nil, fmt.Errorf("check pending orders: %w", err) } if count > 0 { - return nil, infraerrors.Conflict("PENDING_ORDERS", - fmt.Sprintf("this instance has %d in-progress orders; changing credentials may break payment callbacks — wait for orders to complete or disable the instance first", count)) + return nil, infraerrors.Conflict("PENDING_ORDERS", "instance has pending orders"). + WithMetadata(map[string]string{"count": strconv.Itoa(count)}) } } } + // Block disabling a provider that has pending orders + if req.Enabled != nil && !*req.Enabled { + count, err := s.countPendingOrders(ctx, id) + if err != nil { + return nil, fmt.Errorf("check pending orders: %w", err) + } + if count > 0 { + return nil, infraerrors.Conflict("PENDING_ORDERS", "instance has pending orders"). + WithMetadata(map[string]string{"count": strconv.Itoa(count)}) + } + } + u := s.entClient.PaymentProviderInstance.UpdateOneID(id) if req.Name != nil { u.SetName(*req.Name) diff --git a/frontend/src/components/payment/ProviderCard.vue b/frontend/src/components/payment/ProviderCard.vue index 127a2bd4dd..08bf1a3ef6 100644 --- a/frontend/src/components/payment/ProviderCard.vue +++ b/frontend/src/components/payment/ProviderCard.vue @@ -1,11 +1,14 @@