Example #1
0
        public async Task <IActionResult> CancelAsync(
            [Required, RowKey] string merchantId,
            [Required, RowKey] string paymentRequestId)
        {
            try
            {
                await _paymentRequestService.CancelAsync(merchantId, paymentRequestId);

                return(NoContent());
            }
            catch (Exception e)
            {
                _log.ErrorWithDetails(e, new
                {
                    merchantId,
                    paymentRequestId
                });

                if (e is PaymentRequestNotFoundException notFoundEx)
                {
                    _log.ErrorWithDetails(notFoundEx, new
                    {
                        notFoundEx.WalletAddress,
                        notFoundEx.MerchantId,
                        notFoundEx.PaymentRequestId
                    });

                    return(NotFound(ErrorResponse.Create(notFoundEx.Message)));
                }

                if (e is NotAllowedStatusException notAllowedEx)
                {
                    _log.ErrorWithDetails(notAllowedEx,
                                          new { status = notAllowedEx.Status.ToString() });

                    return(BadRequest(ErrorResponse.Create(notAllowedEx.Message)));
                }

                throw;
            }
        }
Example #2
0
        public async Task <IActionResult> CancelAsync(string merchantId, string paymentRequestId)
        {
            try
            {
                await _paymentRequestService.CancelAsync(merchantId, paymentRequestId);

                return(NoContent());
            }
            catch (Exception ex)
            {
                await _log.WriteErrorAsync(nameof(CancelAsync), new
                {
                    merchantId,
                    paymentRequestId
                }.ToJson(), ex);

                if (ex is PaymentRequestNotFoundException notFoundEx)
                {
                    await _log.WriteErrorAsync(nameof(CancelAsync), new
                    {
                        notFoundEx.WalletAddress,
                        notFoundEx.MerchantId,
                        notFoundEx.PaymentRequestId
                    }.ToJson(), notFoundEx);

                    return(NotFound(ErrorResponse.Create(notFoundEx.Message)));
                }

                if (ex is NotAllowedStatusException notAllowedEx)
                {
                    await _log.WriteErrorAsync(nameof(CancelAsync),
                                               new { status = notAllowedEx.Status.ToString() }.ToJson(), notAllowedEx);

                    return(BadRequest(ErrorResponse.Create(notAllowedEx.Message)));
                }

                throw;
            }
        }