Exemplo n.º 1
0
        public async Task <IActionResult> PrePay([FromBody] PrePaymentModel request)
        {
            try
            {
                await _paymentRequestService.PrePayAsync(Mapper.Map <PaymentCommand>(request));

                return(NoContent());
            }
            catch (InsufficientFundsException e)
            {
                _log.ErrorWithDetails(e, new
                {
                    e.AssetId,
                    e.WalletAddress
                });

                return(BadRequest(ErrorResponse.Create(e.Message)));
            }
            catch (PaymentRequestNotFoundException e)
            {
                _log.ErrorWithDetails(e, new
                {
                    e.PaymentRequestId,
                    e.MerchantId,
                    e.WalletAddress
                });

                return(NotFound(ErrorResponse.Create(e.Message)));
            }
            catch (AssetNetworkNotDefinedException e)
            {
                _log.ErrorWithDetails(e, new { e.AssetId });

                return(StatusCode((int)HttpStatusCode.NotImplemented, ErrorResponse.Create(e.Message)));
            }
            catch (MultipleDefaultMerchantWalletsException e)
            {
                _log.ErrorWithDetails(e, new
                {
                    e.MerchantId,
                    e.AssetId,
                    e.PaymentDirection
                });

                return(NotFound(ErrorResponse.Create(e.Message)));
            }
            catch (DefaultMerchantWalletNotFoundException e)
            {
                _log.ErrorWithDetails(e, new
                {
                    e.MerchantId,
                    e.AssetId,
                    e.PaymentDirection
                });

                return(NotFound(ErrorResponse.Create(e.Message)));
            }
            catch (WalletNotFoundException e)
            {
                _log.ErrorWithDetails(e, new { e.WalletAddress });

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