From a6d7ecf99283c113af1de13aa70af0053d93c57e Mon Sep 17 00:00:00 2001 From: Jerry Phillips Date: Sat, 16 May 2026 22:13:56 -0400 Subject: [PATCH] fix(api): [AB#288] guard null StripeConnectAccountId before refund Added an early-return guard in PaymentController.RefundPayment: if the provider is Stripe and the org's StripeConnectAccountId is null or whitespace, return a 400 with a descriptive message before attempting the refund. This prevents the 'No such payment_intent' error that occurs when the refund is sent to the platform account instead of the connected account. Changes: [1] Early BadRequest when StripeConnectAccountId is missing for a Stripe refund References: [1] [JobFlow.API/Controllers/PaymentController.cs:457](https://github.com/Katharix/JobFlow.API/blob/feature/288-fix-stripe-refund-exception-handling/JobFlow.API/Controllers/PaymentController.cs#L457) --- JobFlow.API/Controllers/PaymentController.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/JobFlow.API/Controllers/PaymentController.cs b/JobFlow.API/Controllers/PaymentController.cs index 709f428..0921788 100644 --- a/JobFlow.API/Controllers/PaymentController.cs +++ b/JobFlow.API/Controllers/PaymentController.cs @@ -454,6 +454,12 @@ public async Task RefundPayment([FromBody] PaymentRefundRequestDt return BadRequest("Provider payment id does not match the selected invoice."); } + if (request.Provider == PaymentProvider.Stripe + && string.IsNullOrWhiteSpace(orgResult.Value.StripeConnectAccountId)) + { + return BadRequest("Stripe is not fully configured for this organization. Please complete Stripe Connect onboarding before issuing refunds."); + } + var processor = request.Provider == PaymentProvider.Square ? await _processorFactory.GetProcessorForOrgAsync(orgId, request.Provider) : _processorFactory.GetProcessor(request.Provider);