public async Task <IActionResult> Refund(string paymentRequestId, [FromQuery] string destinationAddress) { if (!paymentRequestId.IsValidPaymentRequestId()) { return(BadRequest(PaymentErrorResponseModel.Create(PaymentErrorType.InvalidPaymentId))); } try { PaymentRequestDetailsModel paymentRequestDetails = await _paymentRequestService.RefundAsync( new RefundRequest { MerchantId = _headersHelper.MerchantId, PaymentRequestId = paymentRequestId, DestinationAddress = destinationAddress }); return(Ok(paymentRequestDetails.ToStatusApiModel())); } catch (Exception ex) { _log.Error(ex, null, $@"request: { new { paymentRequestId, destinationAddress }.ToJson() }"); if (ex is PayInternal.Client.Exceptions.RefundErrorResponseException refundEx) { return(BadRequest(refundEx.ToErrorModel())); } return(BadRequest(PaymentErrorResponseModel.Create(PaymentErrorType.RefundIsNotAvailable))); } }