public void PaymentCallBack(FormCollection collection)
        {
            int             orderId = _paymentService.GetOrderIdFor(collection);
            GetOrderRequest request = new GetOrderRequest()
            {
                OrderId = orderId
            };

            GetOrderResponse response = _orderService.GetOrder(request);

            OrderPaymentRequest orderPaymentRequest =
                response.Order.ConvertToOrderPaymentRequest();

            TransactionResult transactionResult =
                _paymentService.HandleCallBack(orderPaymentRequest, collection);

            if (transactionResult.PaymentOk)
            {
                SetOrderPaymentRequest paymentRequest = new SetOrderPaymentRequest();
                paymentRequest.Amount          = transactionResult.Amount;
                paymentRequest.PaymentToken    = transactionResult.PaymentToken;
                paymentRequest.PaymentMerchant = transactionResult.PaymentMerchant;
                paymentRequest.OrderId         = orderId;

                _orderService.SetOrderPayment(paymentRequest);
            }
            else
            {
                LoggingFactory.GetLogger().Log(String.Format(
                                                   "Payment not ok for order id {0}, payment token {1}",
                                                   orderId, transactionResult.PaymentToken));
            }
        }
Example #2
0
        public OrderPaymentResponse ProcessPayment(OrderPaymentRequest request)
        {
            OrderPaymentResponse response = new OrderPaymentResponse();

            try
            {
                dynamic zuoraResp = SubscriptionManager.MakePayment(request);
                if (zuoraResp.Errors.Count == 0)
                {
                    response.PaymentId = zuoraResp.PaymentId;
                    response.Sucessful = true;
                }
                else
                {
                    response.Errors    = zuoraResp.Errors;
                    response.Sucessful = false;
                }
            }
            catch (Exception e)
            {
                throw e;
            }

            return(response);
        }
Example #3
0
        public async Task PaymentCallBack(IFormCollection collection)
        {
            int             orderId = _paymentService.GetOrderIdFor(collection);
            GetOrderRequest request = new GetOrderRequest
            {
                OrderId = orderId
            };
            GetOrderResponse    response            = _orderService.GetOrder(request);
            OrderPaymentRequest orderPaymentRequest = _mapper.Map <OrderView, OrderPaymentRequest>(response.Order);
            TransactionResult   transactionResult   = await _paymentService.HandleCallBack(orderPaymentRequest, collection);

            if (transactionResult.PaymentOk)
            {
                SetOrderPaymentRequest paymentRequest = new SetOrderPaymentRequest();
                paymentRequest.Amount          = transactionResult.Amount;
                paymentRequest.PaymentToken    = transactionResult.PaymentToken;
                paymentRequest.PaymentMerchant = transactionResult.PaymentMerchant;
                paymentRequest.OrderId         = orderId;
                paymentRequest.CustomerEmail   = _cookieAuthentication.GetAuthenticationToken();

                _orderService.SetOrderPayment(paymentRequest);
            }
            else
            {
                _logger.LogWarning(string.Format("Payment not ok for order id {0}, payment token {1}", orderId, transactionResult.PaymentToken));
            }
        }
Example #4
0
        public async Task <TransactionResult> HandleCallBack(OrderPaymentRequest orderRequest, IFormCollection collection)
        {
            TransactionResult transactionResult = new TransactionResult();
            string            response          = await ValidatePaymentNotification(collection);

            if (response == "VERIFIED")
            {
                string  sAmountPaid   = collection["mc_gross"];
                string  transactionId = collection["txn_id"];
                decimal amountPaid    = 0;

                decimal.TryParse(sAmountPaid, out amountPaid);

                if (orderRequest.Total == amountPaid)
                {
                    transactionResult.PaymentToken    = transactionId;
                    transactionResult.Amount          = amountPaid;
                    transactionResult.PaymentMerchant = "PayPal";
                    transactionResult.PaymentOk       = true;
                }
                else
                {
                    transactionResult.PaymentToken    = transactionId;
                    transactionResult.Amount          = amountPaid;
                    transactionResult.PaymentMerchant = "PayPal";
                    transactionResult.PaymentOk       = false;
                }
            }

            return(transactionResult);
        }
Example #5
0
        public IHttpActionResult OrderPayment([FromBody] OrderPaymentRequest request)
        {
            string requestModel = JsonConvert.SerializeObject(request);

            fileWriter("OrderPayment", requestModel);
            //string documentContents = getDocumentContents(Request.InputStream);
            //fileWriter("TransactionCreationFromStream", documentContents);
            return(Ok());
        }
Example #6
0
        public IActionResult CreatePaymentFor(int orderId)
        {
            GetOrderRequest request = new GetOrderRequest
            {
                OrderId = orderId
            };
            GetOrderResponse    response            = _orderService.GetOrder(request);
            OrderPaymentRequest orderPaymentRequest = _mapper.Map <OrderView, OrderPaymentRequest>(response.Order);
            PaymentPostData     paymentPostData     = _paymentService.GeneratePostDataFor(orderPaymentRequest);

            return(View("PaymentPost", paymentPostData));
        }
        public ActionResult CreatePaymentFor(int orderId)
        {
            GetOrderRequest request = new GetOrderRequest()
            {
                OrderId = orderId
            };

            GetOrderResponse    response            = _orderService.GetOrder(request);
            OrderPaymentRequest orderPaymentRequest = response.Order.ConvertToOrderPaymentRequest();

            PaymentPostData paymentPostData = _paymentService.GeneratePostDataFor(orderPaymentRequest);


            return(View("PaymentPost", paymentPostData));
        }
        public PaymentPostData CreatePaymentPostData(int orderId)
        {
            GetOrderRequest request = new GetOrderRequest()
            {
                OrderId = orderId
            };

            GetOrderResponse    response            = _orderService.GetOrder(request);
            OrderPaymentRequest orderPaymentRequest =
                response.Order.ConvertToOrderPaymentRequest();

            PaymentPostData paymentPostData =
                _paymentService.GeneratePostDataFor(orderPaymentRequest);

            return(paymentPostData);
        }
        public ActionResult <PaymentPostData> CreatePaymentFor(int orderId)
        {
            var request = new GetOrderRequest()
            {
                OrderId = orderId
            };

            GetOrderResponse    response            = _orderService.GetOrder(request);
            OrderPaymentRequest orderPaymentRequest =
                DTOs.OrderMapper.ConvertToOrderPaymentRequest(response.Order);

            PaymentPostData paymentPostData =
                _paymentService.GeneratePostDataFor(orderPaymentRequest);

            return(paymentPostData);
        }
Example #10
0
        public async Task <long> PayTheOrder(OrderPaymentRequest orderPaymentRequest)
        {
            var order = await this.repository.Get <Order>(_ => _.Id == orderPaymentRequest.OrderId);

            var orderPayment = new OrderPayment()
            {
                OrderId       = orderPaymentRequest.OrderId,
                Amount        = orderPaymentRequest.Amount,
                PaymentMethod = orderPaymentRequest.PaymentMethod,
                PaymentTime   = DateTime.UtcNow
            };

            order.PaidAmount   += orderPayment.Amount;
            order.OrderStatusId = (order.TotalPayable - order.PaidAmount) < 0.001M ? (short)OrderStatuses.Paid : (short)OrderStatuses.Pending;

            await repository.Insert <OrderPayment>(orderPayment);

            await repository.Save();

            return(order.Id);
        }
Example #11
0
        public ActionResult Payment(OrderRequestFromClient request)
        {
            OrderPaymentRequest order = null;

            if (request.photoProcessId != null && request.photoProcessId.Count > 0 && request.sessionId != null)
            {
                order = new OrderPaymentRequest()
                {
                    //sessionId = request.sessionId,
                    //photoProcessId = request.photoProcessId,

                    //orderId = Guid.NewGuid().ToString(),
                    //userId = User.Identity.GetUserId(),
                    //amount = 15,
                    //currency = 933,
                    //description = "texttext",
                    //failUrl = "payment/fail",
                    //returnUrl = "payment/success"
                };


                // запрос и обработка ответа

                // сохранение в БД

                //success
                return(Redirect("https://172.22.147.38/payment/merchants/Testing/payment_ru.html?mdOrder=4f788e8f-2c04-4a82-a40d-c5bf7caadf53"));

                //error
                return(Redirect("/Payment/Error"));
            }
            else
            {
                int id = 2;
                return(RedirectToAction("Error", "Payment", new { id = id }));
            }
        }
Example #12
0
        public PaymentPostData GeneratePostDataFor(OrderPaymentRequest orderRequest)
        {
            PaymentPostData     paymentPostData  = new PaymentPostData();
            NameValueCollection postDataAndValue = new NameValueCollection();

            paymentPostData.PostDataAndValue = postDataAndValue;
            // When a real PayPal account is used, the form should be sent to
            // https://www.paypal.com/cgi-bin/webscr.
            // For testing use "https://www.sandbox.paypal.com/cgi-bin/webscr"
            paymentPostData.PaymentPostToUrl = _configuration["PayPalPaymentPostToUrl"];

            // For shopping cart purchases.
            postDataAndValue.Add("cmd", "_cart");
            // Indicates the use of third- party shopping cart.
            postDataAndValue.Add("upload", "1");
            // This is the seller’s e-mail address.
            // You must supply your own address here!!!
            postDataAndValue.Add("business", _configuration["PayPalBusinessEmail"]);
            // This field does not take part in the shopping process.
            // It simply will be passed to the IPN script at the time
            // of transaction confirmation.
            postDataAndValue.Add("custom", orderRequest.Id.ToString());
            // This parameter represents the default currency code.
            postDataAndValue.Add("currency_code", orderRequest.CurrencyCode);
            postDataAndValue.Add("first_name", orderRequest.CustomerFirstName);
            postDataAndValue.Add("last_name", orderRequest.CustomerSecondName);
            postDataAndValue.Add("address1", orderRequest.DeliveryAddressAddressLine);
            postDataAndValue.Add("city", orderRequest.DeliveryAddressCity);
            postDataAndValue.Add("state", orderRequest.DeliveryAddressState);
            postDataAndValue.Add("country", orderRequest.DeliveryAddressCountry);
            postDataAndValue.Add("zip", orderRequest.DeliveryAddressZipCode);
            // This is the URL where the user will be redirected after the payment
            // is successfully performed. If this parameter is not passed, the buyer
            // remains on the PayPal site.
            postDataAndValue.Add("return", _httpContextAccessor?.HttpContext?.Resolve("/Payment/PaymentComplete"));
            // This is the URL where the user will be redirected when
            // he cancels the payment.
            // If the parameter is not passed, the buyer remains on the PayPal site.
            postDataAndValue.Add("cancel_return", _httpContextAccessor?.HttpContext?.Resolve("/Payment/PaymentCancel"));
            // This is the URL where PayPal will pass information about the
            // transaction (IPN). If the parameter is not passed, the value from
            // the account settings will be used. If this value is not defined in
            // the account settings, IPN will not be used.
            postDataAndValue.Add("notify_url", _httpContextAccessor?.HttpContext?.Resolve("/Payment/PaymentCallBack"));

            int itemIndex = 1;

            foreach (OrderItemPaymentRequest item in orderRequest.Items)
            {
                postDataAndValue.Add("item_name_" + itemIndex.ToString(), item.ProductName);
                postDataAndValue.Add("amount_" + itemIndex.ToString(), item.Price.ToString());
                postDataAndValue.Add("item_number_" + itemIndex.ToString(), item.Id.ToString());
                postDataAndValue.Add("quantity_" + itemIndex.ToString(), item.Qty.ToString());

                itemIndex++;
            }

            postDataAndValue.Add("handling_cart", orderRequest.ShippingCharge.ToString());
            postDataAndValue.Add("address_override", "1");

            return(paymentPostData);
        }
Example #13
0
        public async Task <IActionResult> PayTheOrder(OrderPaymentRequest orderPaymentRequest)
        {
            var orderId = await orderService.PayTheOrder(orderPaymentRequest);

            return(Ok(orderId));
        }
Example #14
0
 public async Task <PaymentResponse> CreateOrderPaymentAsync(string orderId, OrderPaymentRequest createOrderPaymentRequest)
 {
     return(await this.PostAsync <PaymentResponse>($"orders/{orderId}/payments", createOrderPaymentRequest).ConfigureAwait(false));
 }
Example #15
0
 public dynamic MakePayment(OrderPaymentRequest request)
 {
     return(zuoraClient.PostPayment(request));
 }
Example #16
0
 public Task <PaymentResponse> CreateOrderPaymentAsync(string orderId, OrderPaymentRequest createOrderPaymentRequest) =>
 ClientService.PostAsync <PaymentResponse>($"orders/{orderId}/payments", createOrderPaymentRequest);
 public OrderPaymentResponse PostPayment(OrderPaymentRequest request)
 {
     return(Service.ProcessPayment(request));
 }