Ejemplo n.º 1
0
        public RedirectToRouteResult Create(CreatePaymentViewModel viewModel)
        {
            CreatePaymentModel model = new CreatePaymentModel();

            model.balanceSheetId = viewModel.balanceSheetId;
            model.Expenses       = new List <ExpenseModel>();

            for (int i = 0; i < viewModel.Expenses.Count; i++)
            {
                var item = viewModel.Expenses[i];
                if (item.Paid)
                {
                    ExpenseModel expenseModel = new ExpenseModel()
                    {
                        ExpenseId = item.Id, Paid = item.Paid, ChargeableId = item.ChargeableId
                    };
                    model.Expenses.Add(expenseModel);
                }
            }


            _createPaymentCommand.Execute(model);

            return(RedirectToAction("Detail", "balanceSheet", model.balanceSheetId));
        }
        /// <summary>
        /// Creates the specified model.
        /// </summary>
        /// <param name="model">The model.</param>
        /// <autogeneratedoc />
        public async Task Create(CreatePaymentModel model)
        {
            var paymentRequest = _mapper.Map <PaymentRequest>(model);

            paymentRequest.RedirectUrl = _configuration["DefaultRedirectUrl"];

            await _paymentClient.CreatePaymentAsync(paymentRequest);
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> CreatePayment(CreatePaymentModel model)
        {
            model.BindId(m => m.Id);

            await _paymentService.ArticlePaymentAsync(model.Id, model.UserId, model.ArticleId);

            return(NoContent());
        }
Ejemplo n.º 4
0
        public ViewResult Create()
        {
            CreatePaymentModel model = new CreatePaymentModel()
            {
                Amount   = 10,
                Currency = Currency.EUR
            };

            return(View(model));
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Authorize a payment when an order has been created by a customer
 /// Publishes a CreatePaymentModel to the broker
 /// TODO: Implement payment details
 /// </summary>
 /// <param name="o"></param>
 public async Task AuthorizePaymentForOrder(Order o)
 {
     var pm = new CreatePaymentModel
     {
         OrderId = o.Id,
         PaymentDetails =
             null, // TODO: Include paymentDetails when the order is created to parse on to paymentAPI
     };
     Console.WriteLine($"[Create Payment] Order id: {pm.OrderId}");
     await _bus.PublishAsync(pm);
 }
Ejemplo n.º 6
0
        public async Task <IActionResult> Create(CreatePaymentModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View());
            }

            await _paymentStorageClient.Create(model);

            return(RedirectToAction(nameof(this.Index)));
        }
Ejemplo n.º 7
0
        private async Task <string> Confirm3DSecureInternalAsync(CreatePaymentModel model, CreatePaymentResultResponse createPayment)
        {
            Guard.ArgumentNotNull(model, nameof(model));
            Guard.ArgumentNotNull(createPayment, nameof(createPayment));

            return(await this.client.PostFormData(new ThreeDsRequest
            {
                PaReq = createPayment.PaReq,
                PostUrl = createPayment.Url
            }));
        }
Ejemplo n.º 8
0
        /// <summary>
        /// создаем платеж
        /// </summary>
        public ResultModel CreatePayment(CreatePaymentModel model)
        {
            try {
                using (var db = new TestDbEntities()) {
                    if (UserId == -1)
                    {
                        return(new ResultModel(Error));
                    }
                    var user = db.UserProfile.First(a => a.UserId == UserId);

                    if (string.IsNullOrEmpty(model.AccountForNumber) || user.AccountNumber == model.AccountForNumber)
                    {
                        Error = "Account number is wrong";
                        return(new ResultModel(Error));
                    }

                    if (model.Sum == 0 || user.Budget < model.Sum)
                    {
                        Error = "Sum is wrong";
                        return(new ResultModel(Error));
                    }

                    var userFor = db.UserProfile.FirstOrDefault(a => a.AccountNumber == model.AccountForNumber);
                    if (userFor == null)
                    {
                        Error  = "AccountNumber is wrong!";
                        UserId = -1;
                        return(new ResultModel(Error));
                    }

                    user.Budget    = user.Budget - model.Sum;
                    userFor.Budget = userFor.Budget + model.Sum;

                    var payment = new Payments()
                    {
                        Name        = model.PaymentName,
                        Note        = model.PaymentNote ?? "",
                        PaymentDate = DateTime.Now,
                        Status      = model.Status,
                        Sum         = model.Sum,
                        UserForId   = userFor.UserId,
                        UserId      = UserId
                    };

                    db.Payments.Add(payment);
                    db.SaveChanges();
                    return(new ResultModel(true));
                }
            } catch (Exception ex) {
                Error = ex.Message;
                return(new ResultModel(Error));
            }
        }
        public async Task <CreatePaymentResponse> CreatePayment(CreatePaymentModel model)
        {
            var createPaymentResult = await _paymentAppService.CreatePayment(new CreatePaymentDto
            {
                PaymentPeriodType              = model.PaymentPeriodType,
                EditionId                      = model.EditionId,
                EditionPaymentType             = model.EditionPaymentType,
                SubscriptionPaymentGatewayType = model.Gateway
            });

            return(createPaymentResult);
        }
Ejemplo n.º 10
0
        static async Task Main(string[] args)
        {
            Console.WriteLine("Please enter message type:\ncpm: CreatePaymentModel\nror: RestaurantOrderRequestModel\ndr: DeliveryRequest");
            var type = Console.ReadLine();

            var bus = RabbitHutch.CreateBus("host=localhost:5672;virtualhost=/;username=admin;password=admin;timeout=120;persistentMessages=false");

            Console.WriteLine($"Created bus..");

            if (type == "cpm")
            {
                var p = new CreatePaymentModel()
                {
                    OrderId        = "123456",
                    PaymentDetails = new PaymentDetails()
                    {
                        CardHolder       = "Stefan Olsen",
                        CardNumber       = "123456789000",
                        ExpireMonth      = 07,
                        ExpireYear       = 21,
                        CardSecurityCode = 619
                    }
                };
                await bus.PublishAsync(p);
            }

            if (type == "ror")
            {
                var p = new RestaurantOrderRequestModel()
                {
                    Order = new OrderDTO()
                    {
                        Id           = "5e3294c243a4bd51b4786ffb",
                        RestaurantId = "5e3294c243a4bd51b4786ffa"
                    }
                };
                await bus.PublishAsync(p);
            }

            if (type == "dr")
            {
                var p = new DeliveryRequest()
                {
                    OrderId         = "123456",
                    DeliveryAddress = "Storegade 12, 6700 Esbjerg",
                    PickupTime      = DateTime.Now
                };
                await bus.PublishAsync(p);
            }

            Console.WriteLine($"done!");
            Console.ReadLine();
        }
Ejemplo n.º 11
0
        public async void CreatePayment(CreatePaymentModel model)
        {
            Console.WriteLine($"[Creating new Payment] for order: {model.OrderId}");
            var payment = new Payment()
            {
                Status  = PaymentStatus.Created,
                OrderId = model.OrderId
            };
            await _payments.InsertOneAsync(payment);

            AuthorizePayment(payment);
        }
Ejemplo n.º 12
0
        public IActionResult Index()
        {
            var request = new CreatePaymentModel
            {
                Amount         = 123,
                Country        = "CYP",
                Currency       = "USD",
                Cvv            = 123,
                CardExpiryDate = 1123,
                CardNumber     = "4111111111111111",
                CardHolder     = "TEST TESTER"
            };

            return(View(request));
        }
Ejemplo n.º 13
0
        private async Task <CreatePaymentResponse> CreatePaymentInternalAsync(CreatePaymentModel model)
        {
            Guard.ArgumentNotNull(model, nameof(model));

            return(await this.client.CreatePaymentAsync(new CreatePaymentRequest
            {
                Amount = model.Amount,
                Country = model.Country,
                Currency = model.Currency,
                Cvv = model.Cvv,
                CardHolder = model.CardHolder,
                CardNumber = model.CardNumber,
                OrderId = model.OrderId,
                CardExpiryDate = model.CardExpiryDate
            }));
        }
Ejemplo n.º 14
0
        public async Task <IActionResult> Index(CreatePaymentModel request)
        {
            var paymentRequest = new CreatePaymentRequest
            {
                OrderId        = Guid.NewGuid(),
                Amount         = request.Amount,
                Country        = request.Country,
                Currency       = request.Currency,
                CardHolder     = request.CardHolder,
                CardNumber     = request.CardNumber,
                CardExpiryDate = request.CardExpiryDate,
                Cvv            = request.Cvv
            };

            try
            {
                var response = await _paymentApiClient.CreatePaymentAsync(paymentRequest);

                var termUrl = Url.Action("Confirm", "Payment", new { transactionId = response.TransactionId }, HttpContext.Request.Scheme);
                var paymentRedirectModel = new PaymentRedirectModel
                {
                    PaReq   = response.PaReq,
                    TermUrl = termUrl,
                    MD      = "Order-1",
                    Method  = response.Method,
                    Url     = "https://dumdumpay.site/secure" // why it returns "http://dummypay.host/secure?
                };

                return(View("PaymentRedirect", paymentRedirectModel));
            }
            catch (Exception e)
            {
                _logger.LogError(e, "An error happened while calling Payment Api");

                if (e is ApiException apiEx)
                {
                    ViewBag.Error = apiEx.GetErrorDescription();
                }
                else
                {
                    ViewBag.Error = e.Message;
                }

                return(View(request));
            }
        }
Ejemplo n.º 15
0
        public async Task <ConfirmPaymentInfo> CreatePaymentAsync(CreatePaymentModel model)
        {
            Guard.ArgumentNotNull(model, nameof(model));

            this.logger.LogTrace($"Start process payment. {model.ToJson()}");
            var createPayment = await this.CreatePaymentInternalAsync(model);

            this.logger.LogTrace($"Start 3D Secure: {createPayment.ToJson()}");
            var threeDSecure = await this.Confirm3DSecureInternalAsync(model, createPayment.Result);

            this.logger.LogTrace($"Start confirm payment.");
            var confirmPayment = await this.ConfirmPaymentInternalAsync(createPayment.Result, threeDSecure);

            this.logger.LogTrace($"Check payment status.");
            await this.EnsurePaymentStatusInternalAsync(confirmPayment.Result.TransactionId, confirmPayment.Result.Status);

            this.logger.LogTrace($"The payment was provided successfully.");
            return(this.MapToResult(confirmPayment.Result));
        }
Ejemplo n.º 16
0
 public IActionResult OnPost(CreatePaymentModel model)
 {
     try
     {
         if (!model.IsValid())
         {
             return(null);
         }
         var res = createPaymentCommand.CreatePayment(model);
         TempData["SucessMessage"] = "Donation Done, Thanks to you For Your Donation...";
         return(RedirectToPage("Donate"));
     }
     catch (Exception ex)
     {
         ErrorHandling errorHandling = new ErrorHandling();
         var           res           = errorHandling.GetErrorMessage(ex);
         TempData["ErrorMessage"] = res;
         return(null);
     }
 }
Ejemplo n.º 17
0
        public async Task <JsonResult> CreatePayment(CreatePaymentModel model)
        {
            var paymentId = await _paymentAppService.CreatePayment(new CreatePaymentDto
            {
                PaymentPeriodType              = model.PaymentPeriodType,
                EditionId                      = model.EditionId,
                EditionPaymentType             = model.EditionPaymentType,
                RecurringPaymentEnabled        = model.RecurringPaymentEnabled.HasValue && model.RecurringPaymentEnabled.Value,
                SubscriptionPaymentGatewayType = model.Gateway,
                SuccessUrl                     = _webUrlService.GetSiteRootAddress().EnsureEndsWith('/') + "Payment/" + model.EditionPaymentType + "Succeed",
                ErrorUrl = _webUrlService.GetSiteRootAddress().EnsureEndsWith('/') + "Payment/PaymentFailed"
            });

            return(Json(new AjaxResponse
            {
                TargetUrl = Url.Action("Purchase", model.Gateway.ToString(), new
                {
                    paymentId = paymentId,
                    isUpgrade = model.EditionPaymentType == EditionPaymentType.Upgrade
                })
            }));
        }
Ejemplo n.º 18
0
        public object Post(CreatePaymentModel model)
        {
            var manager = new PaymentManager(model.Apikey);

            return(manager.CreatePayment(model));
        }