diff --git a/JobFlow.Infrastructure/PaymentGateways/Stripe/StripePaymentProcessor.cs b/JobFlow.Infrastructure/PaymentGateways/Stripe/StripePaymentProcessor.cs index 0529490..49719e2 100644 --- a/JobFlow.Infrastructure/PaymentGateways/Stripe/StripePaymentProcessor.cs +++ b/JobFlow.Infrastructure/PaymentGateways/Stripe/StripePaymentProcessor.cs @@ -151,16 +151,28 @@ public async Task RefundPaymentAsync(PaymentRefundReques requestOptions = new RequestOptions { StripeAccount = request.ConnectedAccountId }; } - var refund = await refundService.CreateAsync(options, requestOptions); - - return new PaymentOperationResult + try { - Success = refund.Status == "succeeded", - ProviderPaymentId = refund.Id, - Amount = request.Amount, - Currency = request.Currency, - Message = refund.Status - }; + var refund = await refundService.CreateAsync(options, requestOptions); + return new PaymentOperationResult + { + Success = refund.Status == "succeeded", + ProviderPaymentId = refund.Id, + Amount = request.Amount, + Currency = request.Currency, + Message = refund.Status + }; + } + catch (StripeException ex) + { + return new PaymentOperationResult + { + Success = false, + Amount = request.Amount, + Currency = request.Currency, + Message = ex.StripeError?.Message ?? ex.Message + }; + } } public async Task AdjustPaymentAsync(PaymentAdjustmentRequest request)