public Response <string> PayFromUser(PaymentRequestDTO dto, int UserId) { var response = new Response <string>(); string CardId = null; try { var Order = _orderRepository.GetbyidwithInclude(a => a.Id == dto.PromoOrderId && a.DateDeleted == null, "User"); if (Order == null) { response.AddValidationError("", "Order doesnot exist."); return(response); } if (dto.CardId == "" || dto.CardId == null) { var cardresponse = _cardService.Create(dto.CardDetail, UserId); if (cardresponse.HasError) { response.ErrorMessage = cardresponse.ErrorMessage; return(response); } CardId = cardresponse.Data; } else { CardId = _cardRepository.GetById(a => a.StripeCardId == dto.CardId && a.DateDeleted == null).StripeCardId; } var userResponse = _userRepository.GetbyidwithInclude(a => a.Id == UserId && a.DateDeleted == null, "Roles,Address"); if (userResponse == null) { response.AddValidationError("", "PromoOrder doesnot exist."); return(response); } //Add Charge double amt = Order.Net + Order.Fee; double centamt = amt * 100; double charge = (centamt * 2.9 / 100); // 2.9 % of service price double centchanrge = (0.3 * 100); // 0.30 Fixed Charge double totalCharg = charge + centchanrge; double finalamount = centamt + totalCharg; var responsepayment = _baseServices.Payment(new PaymentDTO { Amount = Convert.ToInt64(Math.Ceiling(finalamount)), Currency = "usd", CustomerId = userResponse.Stripe_CustomerId, CardId = CardId, Desciption = "Pay for Test", Metadata = new Dictionary <string, string> { { "OrderId", Order.Id.ToString() }, { "Service Title", "" }, { "Discount", Order.Discount.ToString() }, { "Fee", Order.Fee.ToString() } }, address = userResponse.Address }); if (!responsepayment.Success) { response.ErrorMessage = responsepayment.ErrorMessage; return(response); } if (responsepayment.Success && responsepayment.Data != null && responsepayment.Data.Status == "succeeded") { Order.PaymentStaus = PaymentStaus.Completed; } else if (responsepayment.Success && responsepayment.Data != null && responsepayment.Data.Status == "pending") { Order.PaymentStaus = PaymentStaus.Pending; } else if (responsepayment.Success && responsepayment.Data != null && responsepayment.Data.Status == "failed") { Order.PaymentStaus = PaymentStaus.Reject; } Order.ChargeId = responsepayment.Data.Id; _orderRepository.Update(Order); response.Data = responsepayment.Data.Id; response.Success = true; } catch (Exception ex) { HandleException(response, ex); } return(response); }