Ejemplo n.º 1
0
        public async Task <AddPaymentResponse> AddPaymentAsync(AddPaymentRequest request)
        {
            var result = false;

            try
            {
                var account = await accountDataAccess.GetByUserCurrencyAsync(request.UserId, request.CurrencyId);

                if (account == null)
                {
                    result = await accountDataAccess.SaveOrUpdateAsync(new Domain.Models.Account
                    {
                        UserId     = request.UserId,
                        CurrencyId = request.CurrencyId,
                        Balance    = request.Amount
                    });
                }
                else
                {
                    account.Balance += request.Amount;
                    result           = await accountDataAccess.SaveOrUpdateAsync(account);
                }
            }
            catch (Exception ex)
            {
                //TODO: AddToLog
            }

            return(new AddPaymentResponse
            {
                IsSuccess = result
            });
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Payment([FromBody] AddPaymentRequest request)
        {
            var result = await _paymentService.Pay(request);

            if (result.Succeeded)
            {
                return(Ok(result.Data));
            }
            return(BadRequest(result.ErrorMessage));
        }
Ejemplo n.º 3
0
        public async Task AddPayment(Payment payment)
        {
            var request = new AddPaymentRequest
            {
                Id         = payment.Id,
                MerchantId = payment.MerchantId,
                Status     = payment.Status
            };

            await _merchantApi.AddPayment(request);
        }
Ejemplo n.º 4
0
        public void AddPayment(AddPaymentRequest request)
        {
            Payment model = this._paymentRepository.FindBy(request.Id);

            if (model == null)
            {
                throw new EntityIsInvalidException <string>(request.Id.ToString());
            }
            this._paymentRepository.Add(model);
            this._uow.Commit();
        }
Ejemplo n.º 5
0
        public void AddPayment([FromBody] AddPaymentRequest request)
        {
            if (request == null)
            {
                throw new ArgumentNullException(nameof(request));
            }

            var paymentDate = new DateTime(request.Year, request.Month, 20);

            CommandProcessor.Execute(
                new AddPaymentCommand(request.PaymentTypeId, request.Amount, paymentDate, request.Description));
        }
Ejemplo n.º 6
0
 public IHttpActionResult Add(AddPaymentRequest request)
 {
     try
     {
         _paymentService.Add(request.ContractNumber, request.Sum);
         return(Ok());
     }
     catch (BankClientException ex)
     {
         return(BadRequest(ex.Message));
     }
     catch (Exception ex)
     {
         return(InternalServerError(ex));
     }
 }
Ejemplo n.º 7
0
        public async Task <IResponse <int> > Pay(AddPaymentRequest request)
        {
            var s = await Auth();

            var client = new RestClient($"{_georgianCardUrl}/payment/start.wsm?" +
                                        $"&lang={_lang}" +
                                        $"&page_id={request.PageId}" +
                                        $"&merch_id={_merchantId}" +
                                        $"&preauth={_preAuth}" +
                                        $"&back_url_s={_backUrlSuccess}{request.OrderId}" +
                                        $"&back_url_f={_backUrlFail}{request.OrderId}");

            var restRequest = new RestRequest(Method.GET);
            //restRequest.AddHeader("lang", request.Lang);
            //restRequest.AddHeader("page_id", request.PageId);
            //restRequest.AddHeader("merch_id", request.MerchantId);
            //restRequest.AddHeader("preauth", request.PreAuth);

            IRestResponse response = client.Execute(restRequest);

            return(new Response <int>(response.IsSuccessful ? 1 : 0));
        }
Ejemplo n.º 8
0
        public CommunicationResponse AddPayment([FromBody] AddPaymentRequest paymentRequest)
        {
            var response = new CommunicationResponse();

            try
            {
                if (_userService.AuthenticateSession(Request.Headers["Authorization"].ToString()) == false)
                {
                    response.AddError("The authorization credentails were invalid", ErrorCode.SESSION_INVALID);
                    return(response);
                }

                var payment = new Payment
                {
                    Amount   = paymentRequest.Amount,
                    DatePaid = paymentRequest.Created,
                    PersonId = paymentRequest.PersonId
                };
                PaymentValidator.CheckIfValidPayment(payment, paymentRequest.BillId);
                _billRepository.AddPayment(payment, paymentRequest.BillId);

                response.Notifications = new List <string>
                {
                    "The payment has been added"
                };
            }
            catch (ErrorCodeException exception)
            {
                response.AddError($"An unexpected exception occured: {exception}", paymentRequest, exception.Code);
            }
            catch (Exception exception)
            {
                response.AddError($"An unexpected exception occured: {exception}", paymentRequest);
            }

            return(response);
        }
Ejemplo n.º 9
0
 public async Task <IActionResult> AddPaymentOption([FromBody] AddPaymentRequest request, CancellationToken cancellationToken = default)
 {
     return(Ok(await Mediator.Send(request, cancellationToken)));
 }
 public Task <AddPaymentRequest> AddPayment(AddPaymentRequest request)
 {
     throw new NotImplementedException();
 }
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='request'>
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task<AddPaymentResponse> AddPaymentByRequestAsync( this IPaymentProfile operations, AddPaymentRequest request, CancellationToken cancellationToken = default(CancellationToken))
 {
     var _result = await operations.AddPaymentByRequestWithHttpMessagesAsync(request, null, cancellationToken).ConfigureAwait(false);
     return _result.Body;
 }
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='request'>
 /// </param>
 public static AddPaymentResponse AddPaymentByRequest(this IPaymentProfile operations, AddPaymentRequest request)
 {
     return Task.Factory.StartNew(s => ((IPaymentProfile)s).AddPaymentByRequestAsync(request), operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult();
 }
Ejemplo n.º 13
0
 public async Task <AddPaymentResponse> AddPaymentAsync([FromBody] AddPaymentRequest request)
 {
     return(await accountService.AddPaymentAsync(request));
 }