public IActionResult ProcessPayment(PaymentRequest model) { try { if (model == null) { _logger.LogError(Constants.NULL_REQUEST); return(StatusCode((int)HttpStatusCode.BadRequest, Constants.NULL_REQUEST)); } if (!ModelState.IsValid) { _logger.LogError(Constants.INVALID_REQUEST); return(StatusCode((int)HttpStatusCode.BadRequest, Constants.INVALID_REQUEST)); } var request = _mapper.Map <PaymentRequestModel>(model); var created = _paymentManager.StorePayment(request); var response = _paymentGatewayManager.ProcessPayment(model); created.PaymentState = (response == true) ? PaymentStatus.processed : PaymentStatus.failed; _paymentManager.UpdatePayment(created); return(StatusCode((int)HttpStatusCode.OK, request)); } catch (Exception ex) { _logger.LogError(Constants.PROCESSING_ERROR + ex.Message); return(StatusCode((int)HttpStatusCode.InternalServerError, Constants.INTERNAL_SERVER_ERROR)); } }
public void FinalizeOrder(OrderDetails details) { inventory.Update(details.ProductNo); costing.ApplyDiscounts(details.Price, details.DiscountPercent); logistic.ShipProduct(details.ProductName, details.AddressLine1); orderVerify.VerifyShippingAddress(details.PinCode); payment.ProcessPayment(details.CardNo, details.Price); }
public bool ProcessOrder3() { //Do some other things here, then process payment bool success = _paymentGateway.ProcessPayment(); return(success); }
internal void ProcessPayment(User user, PaymentDetails paymentDetails) { if (!_userValidationService.ValidateUser(user)) { throw new UserInvalidException(); } _paymentGatewayObject.ProcessPayment(paymentDetails); }
/// <summary> /// making the order /// </summary> /// <param name="orderDetails"></param> public void FinalizeOrder(OrderDetails orderDetails) { inventory.Update(orderDetails.ProductNo); orderVerify.VerifyShippingAddress(orderDetails.PinCode); orderDetails.Price = costManger.ApplyDiscounts(orderDetails.Price, orderDetails.DiscountPercent); paymentGateWay.VerifyCardDetails(orderDetails.CardNo); paymentGateWay.ProcessPayment(orderDetails.CardNo, orderDetails.Price); logistics.ShipProduct(orderDetails.ProductName, string.Format($"{orderDetails.AddressLine1}, {orderDetails.AddressLine2} - {orderDetails.PinCode}.")); }
public async Task <PaymentStatus> ProcessPayment(Payment payment) { if (CanProcessPayment(payment)) { return(await HandlePayment(payment)); } return(await NextGateway.ProcessPayment(payment)); }
public PaymentStatusVM ProcessPaymentRequest(PaymentRequestVM paymentRequest) { GatewayFactory gatewayFactory = new GatewayFactory(unitOfWork); IPaymentGateway paymentGateway = gatewayFactory.GetPaymentGateway(paymentRequest.Amount); PaymentInfo pi = mapper.Map <PaymentRequestVM, PaymentInfo>(paymentRequest); return(paymentGateway.ProcessPayment(pi)); }
public bool Update(Order order) { if (_paymentGateWay.VerifyCardDetails(order)) { _costManger.ApplyDiscounts(order); _paymentGateWay.ProcessPayment(order); return(InternalUpdate(order)); } return(false); }
private PayStateDto ProcessPaymentStateDto(IPaymentGateway payGateway, PayRequestDto payReqDto, Payment payEntity) { var paymentSateDto = payGateway.ProcessPayment(payReqDto); var payStEntity = new PaymentState() { Payment = payEntity, PayId = payEntity.PayId, CreatedDate = paymentSateDto.PaymentStateDate, State = paymentSateDto.PayState.ToString() }; payStEntity = payStateRepo.Create(payStEntity); return(paymentSateDto); }
public async Task <PaymentState> ProcessPaymentState(IPaymentGateway paymentGateway, int id) { var State = paymentGateway.ProcessPayment(); var paymentState = new PaymentState { paymentState = State.paymentState, PaymentId = id }; await _unitOfWork.paymentStates.Add(paymentState); return(State); }
private async Task <PaymentStateDto> ProcessPaymentStateDto(IPaymentGateway paymentGateway, PaymentRequestDto paymentRequestDto, Payment paymentEntity) { var paymentStateDto = paymentGateway.ProcessPayment(paymentRequestDto); var paymentStateEntityProcessed = new PaymentState() { Payment = paymentEntity, PaymentId = paymentEntity.PaymentId, CreatedDate = paymentStateDto.PaymentStateDate, State = paymentStateDto.PaymentState.ToString() }; paymentStateEntityProcessed = await _paymentStateRepository.Create(paymentStateEntityProcessed); return(paymentStateDto); }
public async Task <bool> ProcessPayment(ProcessPaymentModel model) { try { //Adding Payment var payment = new Payment { CreditCardNumber = model.CreditCardNumber, CardHolder = model.CardHolder, ExpirationDate = model.ExpirationDate, SecurityCode = model.SecurityCode, Amount = model.Amount }; _uow.Add(payment); await _uow.CommitAsync(); //Adding Payment Status as Initial - Pending var paymentStatus = new PaymentStatus { PaymentId = payment.Id, StatusId = (int)TransactionStatus.Pending }; _uow.Add(paymentStatus); paymentStatus = new PaymentStatus() { PaymentId = payment.Id }; var factory = new PaymentGatewayFactory(); IPaymentGateway paymentGateway = factory.GetPaymentGateway(model.Amount); if (await paymentGateway.ProcessPayment()) { paymentStatus.StatusId = (int)TransactionStatus.Processed; } else { paymentStatus.StatusId = (int)TransactionStatus.Failed; } _uow.Add(paymentStatus); await _uow.CommitAsync(); return(true); } catch (Exception ex) { throw new BadRequestException(ex.Message); } }
private PaymentStateViewModel ProcessPayment(IPaymentGateway gateway, Payment entity) { var request = gateway.ProcessPayment(); var paymentState = new PaymentState() { PaymentId = entity.Id, CreatedDate = request.CreatedDate, State = request.State, Id = new Guid() }; db.PaymentStates.Add(paymentState); return(request); }
/// <summary> /// Processes the payment. /// </summary> private void ProcessPayment() { // If total is 0, we do not need to proceed if (OrderGroup.Total == 0) { return; } // Start Charging! PaymentMethodDto methods = PaymentManager.GetPaymentMethods(Thread.CurrentThread.CurrentCulture.Name); foreach (OrderForm orderForm in OrderGroup.OrderForms) { foreach (Payment payment in orderForm.Payments) { PaymentMethodDto.PaymentMethodRow[] rows = (PaymentMethodDto.PaymentMethodRow[])methods.PaymentMethod.Select(String.Format("PaymentMethodId = '{0}'", payment.PaymentMethodId)); // If we couldn't find payment method specified, generate an error if (rows == null || rows.Length == 0) { throw new MissingMethodException(String.Format("Specified payment method \"{0}\" has not been defined.", payment.PaymentMethodId)); } Logger.Debug(String.Format("Getting the type \"{0}\".", rows[0].ClassName)); Type type = Type.GetType(rows[0].ClassName); if (type == null) { throw new TypeLoadException(String.Format("Specified payment method class \"{0}\" can not be created.", rows[0].ClassName)); } Logger.Debug(String.Format("Creating instance of \"{0}\".", type.Name)); IPaymentGateway provider = (IPaymentGateway)Activator.CreateInstance(type); provider.Settings = CreateSettings(rows[0]); string message = ""; Logger.Debug(String.Format("Processing the payment.")); if (!provider.ProcessPayment(payment, ref message)) { throw new PaymentException(PaymentException.ErrorType.ProviderError, "", String.Format(message)); } Logger.Debug(String.Format("Payment processed.")); PostProcessPayment(payment); // TODO: add message to transaction log } } }
public ActionResult Post([FromBody] PaymentRequest request) { try { var response = _paymentGateway.ProcessPayment(request); if (response == null) { return(StatusCode((int)HttpStatusCode.NotFound)); } return(StatusCode((int)HttpStatusCode.OK, response)); } catch (Exception ex) { _logger.LogError("Error Processing Payment", ex); return(StatusCode((int)HttpStatusCode.BadRequest)); } }
public override void MakePayment(IPaymentGateway paymentGateway) { paymentGateway.ProcessPayment("G Pay Payment processed"); }
public void SubmitPayment(decimal amount) { _mPaymentGateway.ProcessPayment(amount, this); }
/// <summary> /// Processes the payment. /// </summary> private void ProcessPayment() { // If total is 0, we do not need to proceed if (OrderGroup.Total == 0 || OrderGroup is PaymentPlan) { return; } // Start Charging! PaymentMethodDto methods = PaymentManager.GetPaymentMethods(/*Thread.CurrentThread.CurrentCulture.Name*/ String.Empty); foreach (OrderForm orderForm in OrderGroup.OrderForms) { foreach (Payment payment in orderForm.Payments) { if (this.Payment != null && !this.Payment.Equals(payment)) { continue; } //Do not process payments with status Processing and Fail var paymentStatus = PaymentStatusManager.GetPaymentStatus(payment); if (paymentStatus != PaymentStatus.Pending) { continue; } PaymentMethodDto.PaymentMethodRow paymentMethod = methods.PaymentMethod.FindByPaymentMethodId(payment.PaymentMethodId); // If we couldn't find payment method specified, generate an error if (paymentMethod == null) { throw new MissingMethodException(String.Format("Specified payment method \"{0}\" has not been defined.", payment.PaymentMethodId)); } Logger.Debug(String.Format("Getting the type \"{0}\".", paymentMethod.ClassName)); Type type = Type.GetType(paymentMethod.ClassName); if (type == null) { throw new TypeLoadException(String.Format("Specified payment method class \"{0}\" can not be created.", paymentMethod.ClassName)); } Logger.Debug(String.Format("Creating instance of \"{0}\".", type.Name)); IPaymentGateway provider = (IPaymentGateway)Activator.CreateInstance(type); provider.Settings = CreateSettings(paymentMethod); string message = ""; Logger.Debug(String.Format("Processing the payment.")); if (provider.ProcessPayment(payment, ref message)) { Mediachase.Commerce.Orders.Managers.PaymentStatusManager.ProcessPayment(payment); } else { throw new PaymentException(PaymentException.ErrorType.ProviderError, "", String.Format(message)); } Logger.Debug(String.Format("Payment processed.")); PostProcessPayment(payment); // TODO: add message to transaction log } } }
public bool ProcessOrder() { bool success = _paymentGateway.ProcessPayment(); return(success); }
public override void MakePayment(IPaymentGateway paymentGateway) { paymentGateway.ProcessPayment("Debit card payment"); }