public async Task <IActionResult> Edit(int id, [Bind("PaypalID,correoPaypal,psswrdPaypal,tiendaOnlineUserID")] Paypal paypal)
        {
            if (id != paypal.PaypalID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(paypal);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PaypalExists(paypal.PaypalID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["tiendaOnlineUserID"] = new SelectList(_context.Users, "Id", "Id", paypal.tiendaOnlineUserID);
            return(View(paypal));
        }
Ejemplo n.º 2
0
        static void Main()
        {
            //#warning  Paypal API not yet working
            var paypalApi = new PaypalAPI();

            paypalApi.GetPaymentList();

            SetConsoleUp();
            NameValueCollection appSettings = ConfigurationManager.AppSettings;
            Paypal paypal = new Paypal();

            MasterDetails[] recordsMs = paypal.LoadPaypalFile(appSettings["PaypalFilePath"]);
            Core.Generator  generator = new Generator();
            var             mList     = generator.Generate(appSettings, recordsMs);

            if (mList != null && mList.Count > 0)
            {
                Magento magento = new Magento();
                magento.SaveMagentoFile(appSettings["MagentoFilePath"], appSettings["HeaderRow"], mList);
                Console.WriteLine(Process.Summary.ToString());
                Console.WriteLine("{0} records generated into new file {1}", mList.Count, appSettings["MagentoFilePath"]);
            }
            else
            {   //todo output summary?
                Console.WriteLine("No records generated. \r\nCheck application settings in app.config.\r\n");
            }
            Console.WriteLine("Press any key...");
            Console.ReadLine();
        }
Ejemplo n.º 3
0
        private void Window_Loaded_1(object sender, RoutedEventArgs e)
        {
            //DownloadStatusGrid.DataContext = Lists;
            DownloadStatusGrid.ItemsSource = Lists.Entries;
            if (!_settings.IsDevelopment)
            {
                var firstTimeString = (_settings.FirstTime ? "mixpanel.track('Installed', {Version:'" + _settings.Version + "'});" : "");
                var paypalHtml      = Properties.Resources.TrackerHtml.Replace("|0|", _settings.ApplicationConfiguration.Guid.ToString()).Replace("|1|", firstTimeString).Replace("|2|", _settings.Version);
                Paypal.NavigateToString(paypalHtml);
            }
            var uri = new Uri(Url.Text);

            Navigate(uri);
            //Task.Factory.StartNew(() => {
            //    while (true) {
            //        IHTMLDocument3 doc = null;
            //        string url = null;
            //        Dispatcher.Invoke(DispatcherPriority.Normal, new Action(() => {
            //            url = Url.Text;
            //            doc = Browser.Document as IHTMLDocument3;
            //        }));
            //        if (doc == null) return;
            //        var html = doc.documentElement.outerHTML;
            //        var prevCount = (_youtubeEntry == null) ? 0 : _youtubeEntry.Entries.Count;
            //        var youtubeEntry = YoutubeEntry.Create(new Uri(url), html);
            //        if (youtubeEntry != null && youtubeEntry.Entries.Count != prevCount) {
            //            Dispatcher.Invoke(DispatcherPriority.Background, new Action(() => {
            //                _youtubeEntry = youtubeEntry;
            //                Loading();
            //            }));
            //        }
            //        Thread.Sleep(500);
            //    }
            //});
        }
Ejemplo n.º 4
0
        public ActionResult PostToPayPal(string item, string amount)
        {
            Paypal paypal = new Paypal();

            paypal.cmd      = "_xclick";
            paypal.business = ConfigurationManager.AppSettings["BusinessAccountKey"];

            bool useSandbox = Convert.ToBoolean(ConfigurationManager.AppSettings["UseSandBox"]);

            if (useSandbox)
            {
                ViewBag.ActionUrl = "https://www.sandbox.paypal.com/cgi-bin/webscr";
            }
            else
            {
                ViewBag.ActionUrl = "https://www.paypal.com/cgi-bin/webscr";
            }

            paypal.cancel_return = ConfigurationManager.AppSettings["CancelURL"];
            paypal.@return       = ConfigurationManager.AppSettings["ReturnURL"]; // + "&PaymentId=1"; can append order Id here
            paypal.notify_url    = ConfigurationManager.AppSettings["NotifyURL"]; // +"?PaymentId=1"; to maintain database logic

            paypal.currency_code = ConfigurationManager.AppSettings["CurrencyCode"];

            paypal.item_name = item;
            paypal.amount    = amount;

            return(View(paypal));
        }
Ejemplo n.º 5
0
        //Init Order
        public ActionResult Order(Order _order)
        {
            if (Session[Constants.SESSION_CART] == null)
            {
                RedirectToAction("Index", "Home");
            }
            Paypal pp        = new Paypal();
            string strReturn = pp.GetPayPalResponse(Request.QueryString["tx"]);

            ViewBag.tx = Request.QueryString["tx"];
            if (ViewBag.tx == null)
            {
                return(HttpNotFound());
            }
            else
            {
                OrderDetail _orderDetails = new OrderDetail();
                _order        = GetOrder();
                _orderDetails = GetOrderDetails(_order);
                db.Orders.Add(_order);
                db.SaveChanges();
                Session[Constants.SESSION_CART] = null;
                return(View());
            }
        }
        private void Button1_Click(object sender, EventArgs e)
        {
            var form1 = new Paypal();

            form1.Closed += (s, args) => this.Close();
            form1.Show();
            this.Hide();
        }
Ejemplo n.º 7
0
        public void MixpanelTrack(string action, object obj = null)
        {
            if (_settings.IsDevelopment)
            {
                return;
            }
            var objText = (obj == null) ? "" : ", " + JsonConvert.SerializeObject(obj);
            var cmd     = "mixpanel.track('" + action + "'" + objText + ");";

            Paypal.InvokeScript("trackEval", cmd);
        }
Ejemplo n.º 8
0
        public async Task <IActionResult> AddPaypal(Paypal paypal)
        {
            var result = await _publicTransportRepository.SavePaypalInfo(paypal);

            if (result)
            {
                return(Ok());
            }

            return(BadRequest("Could not add the paypal!"));
        }
        public async Task <IActionResult> Create([Bind("PaypalID,correoPaypal,psswrdPaypal,tiendaOnlineUserID")] Paypal paypal)
        {
            if (ModelState.IsValid)
            {
                _context.Add(paypal);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["tiendaOnlineUserID"] = new SelectList(_context.Users, "Id", "Id", paypal.tiendaOnlineUserID);
            return(View(paypal));
        }
Ejemplo n.º 10
0
        private async Task <Order> PaypalTransaction(IDbConnection c, IDbTransaction t, string publicKey, string secretKey, string apiUrl)
        {
            var request = new OrdersCreateRequest();

            request.Prefer("return=representation");
            request.RequestBody(Paypal.BuildOrderRequestBody(apiUrl));
            var response = await Paypal.client(publicKey, secretKey).Execute(request);

            // var statusCode = response.StatusCode;
            Order order = response.Result <Order>();

            return(order);
        }
Ejemplo n.º 11
0
        public ActionResult Purchase(int passId, string Cancel = null)
        {
            var pass = db.getClassPasse(passId);

            // veryfy paypal successfull before
            //getting the apiContext
            APIContext apiContext = Paypal.GetAPIContext();

            try
            {
                string payerId = Request.Params["PayerID"];
                if (string.IsNullOrEmpty(payerId))
                {
                    string baseURI = Request.Url.Scheme + "://" + Request.Url.Authority + "/Passes/Purchases?passId=" + pass.Pass_Id + "&";

                    var guid = Convert.ToString((new Random()).Next(100000));

                    var createdPayment = CreatePayment(apiContext, baseURI + "guid=" + guid, pass);

                    var    links             = createdPayment.links.GetEnumerator();
                    string paypalRedirectUrl = null;
                    while (links.MoveNext())
                    {
                        Links lnk = links.Current;
                        if (lnk.rel.ToLower().Trim().Equals("approval_url"))
                        {
                            paypalRedirectUrl = lnk.href;
                        }
                    }
                    Session.Add(guid, createdPayment.id);
                    return(Redirect(paypalRedirectUrl));
                }
                else
                {
                    var guid            = Request.Params["guid"];
                    var executedPayment = ExecutePayment(apiContext, payerId, Session[guid] as string);

                    if (executedPayment.state.ToLower() != "approved")
                    {
                        return(View("FailureView"));
                    }
                }
            }
            catch (Exception e)
            {
                Debug.WriteLine(e);
                return(View("FailureView"));
            }

            return(View("FailureView"));
        }
Ejemplo n.º 12
0
        private async Task <Order> PaypalCapture(IDbConnection c, IDbTransaction t, string publicKey, string secretKey, string apiUrl, string orderId)
        {
            // Construct a request object and set desired parameters
            // Replace ORDER-ID with the approved order id from create order
            var request = new OrdersCaptureRequest(orderId);

            request.RequestBody(new OrderActionRequest());
            var response = await Paypal.client(publicKey, secretKey).Execute(request);

            // var statusCode = response.StatusCode;
            Order result = response.Result <Order>();

            return(result);
        }
        public IBookGateway GetBookGateway(string type)
        {
            IBookGateway returnvalue = null;

            if (type.ToLower() == "paypal")
            {
                returnvalue = new Paypal();
            }
            else if (type.ToLower() == "stripnet")
            {
                returnvalue = new StripNet();
            }
            return(returnvalue);
        }
Ejemplo n.º 14
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!Page.IsPostBack)
     {
         pe = (Paypal)Session["myOrderingEntity"];
         NombreLibro.InnerText = pe.ItemName;
         PrecioLibro.InnerText = pe.Amount;
         this.BusinessValue    = pe.Business;
         this.ItemNameValue    = pe.ItemName;
         this.ItemNumberValue  = pe.ItemNumber;
         this.AmountValue      = pe.Amount;
         this.NoShippingValue  = pe.NoShipping;
         this.QuantityValue    = pe.Quantity;
     }
 }
        public static void Run()
        {
            Console.WriteLine("=-=-=-=ChainOfResponsibility=-=-=-=");

            var bank    = new Bank(100);       // Bank with balance 100
            var paypal  = new Paypal(200);     // Paypal with balance 200
            var bitcoin = new Bitcoin(300);    // Bitcoin with balance 300

            bank.SetNext(paypal);
            paypal.SetNext(bitcoin);

            // Let's try to pay using the first priority i.e. bank
            bank.Pay(259);

            Console.WriteLine("----------------------------------" + Environment.NewLine);
        }
Ejemplo n.º 16
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //Recivimos el json, verificar si mandamos mas datos.
            string json = Request.QueryString["details"];
            //Instancia al using para deserealizar json
            JavaScriptSerializer js = new JavaScriptSerializer();
            //Instancia de la clase paypal
            paypal oUser = js.Deserialize <paypal>(json);

            //Logica para convertir a Byte lo que recivimos de la base 64
            byte[] data = System.Convert.FromBase64String(oUser.status);
            //Lo volvemos al lenguaje español
            oUser.status = System.Text.ASCIIEncoding.ASCII.GetString(data);
            //Se aplica lo mismo
            data     = System.Convert.FromBase64String(oUser.id);
            oUser.id = System.Text.ASCIIEncoding.ASCII.GetString(data);
            //Listo ya funciona
            pe = (Paypal)Session["myOrderingEntity"];
            string idVenta     = pe.idVenta;
            string orderStatus = oUser.status;
            string orderID     = oUser.id;

            if (orderStatus == "COMPLETED")
            {
                //Rutina para actualizar tabla
                try
                {
                    books.UpdEstatusVentaPaypal(idVenta, orderID);
                    //Label1.Text = "Tu compra ha sido autorizada con el siguiente número de orden: " + orderID +", ya puedes descargar el libro";
                    Response.Redirect("~/Forms/MisCompras.aspx");
                }
                catch (Exception ex)
                {
                    Label1.Text = "Algo salió mal " + ex.Message;
                    throw;
                }
            }
            else
            {
                Label1.Text         = orderStatus;
                btnRegresar.Visible = true;
                ScriptManager.RegisterStartupScript(this, GetType(), "Popup", "NoProcess();", true);
            }
        }
Ejemplo n.º 17
0
        public async Task <JsonResult> PagoConCuentaPayPal(int IdMembresia)
        {
            try
            {
                Paypal paypal = new Paypal();
                //Membresia mem = await ApiHelper.GET_By_ID<Membresia>("Membresia/GetMembresia", IdMembresia, GetAuthToken);
                Membresia mem = await ApiHelper.GET_By_ID <Membresia>("Membresia/GetMembresia", IdMembresia, GetAuthToken);

                string guid = Convert.ToString((new Random()).Next(100000));
                Session[guid]           = null;
                Session[guid + "memId"] = null;
                string  CancelURL = Request.Url.Scheme + "://" + Request.Url.Authority + ConfigurationManager.AppSettings["CancelURL"];
                string  ReturnURL = Request.Url.Scheme + "://" + Request.Url.Authority + ConfigurationManager.AppSettings["ReturnURL"] + "?guid=" + guid;
                Payment pago      = paypal.CrearPagoMembresia(mem.Nombre, (mem.Precio - (mem.Descuento == null ? 0 : mem.Descuento)).ToString(), "Membresía CamajanDeportivo (" + mem.Nombre + ")", null, CancelURL, ReturnURL);
                var     links     = pago.links.GetEnumerator();

                string paypalRedirectUrl = null;

                while (links.MoveNext())
                {
                    Links lnk = links.Current;

                    if (lnk.rel.ToLower().Trim().Equals("approval_url"))
                    {
                        //saving the payapalredirect URL to which user will be redirected for payment
                        paypalRedirectUrl = lnk.href;
                    }
                }

                // saving the paymentID in the key guid
                Session.Add(guid, pago.id);
                Session.Add(guid + "memId", IdMembresia);
                return(Json(new { result = "OK", url = paypalRedirectUrl }));
            }
            catch (Exception)
            {
                return(Json(new { result = "ERROR", Message = "Ha ocurrido un error al realizar el pago utilizando Paypal. Favor intente más tarde. \\n\\nSi el problema persiste contacte el administrador." }));

                throw;
            }
        }
Ejemplo n.º 18
0
        public ActionResult Purchases(string Cancel = null)
        {
            int passId = Int32.Parse(Request.QueryString["passId"]);
            var pass   = db.getClassPasse(passId);

            // veryfy paypal successfull before
            //getting the apiContext
            APIContext apiContext = Paypal.GetAPIContext();

            try
            {
                string payerId = Request.Params["PayerID"];

                var guid            = Request.Params["guid"];
                var executedPayment = ExecutePayment(apiContext, payerId, Session[guid] as string);

                if (executedPayment.state.ToLower() != "approved")
                {
                    return(View("FailureView"));
                }
            }
            catch (Exception e)
            {
                Debug.WriteLine(e);
                return(View("FailureView"));
            }

            int userId = Int32.Parse(Session["Uid"].ToString());

            //todo update all field correctly later on

            // create purchase log
            Pass_Log pl = db.processPurchase(pass, userId, "ONLINE");

            Yoga_User u = db.getUserById(userId);

            EmailSender.sendPurchaseConfirmation(u, pl, "Online");
            // todo success message with receipt etc.

            return(View("SuccessView"));
        }
Ejemplo n.º 19
0
    public IEnumerator Start()
    {
        if (!settings.fastLoad)
        {
            InitUrl();

            if (string.IsNullOrEmpty(_Loader.ip))
            {
                yield return(Download(mainSite + "scripts/getip.php", s => _Loader.ip = s.text));
            }
            if (string.IsNullOrEmpty(_Loader.country))
            {
                yield return(Download(mainSite + "scripts/country.php", s => _Loader.country = s.text));
            }
            owner.ip      = _Loader.ip;
            owner.country = _Loader.country;

            web.Download("scripts/count.php?platform=" + platformPrefix + "&version=" + bs.settings.version);
            web.Download("scripts/getItems.php?id=" + deviceUniqueIdentifier, delegate(WWW w) { Paypal.SetPaypalItems(w.text.SplitString().ToList()); });
            StartCoroutine(LoadSettings());
        }
        LoadFriends();
        if (Application.isEditor)
        {
            PhotonNetwork.player.accType = AccType.Dev;
        }
        PhotonNetwork.player.deviceId = deviceUniqueIdentifier;
        if (!isDebug)
        {
            _LoaderMusic.LoadMusic(settings.serv.music);
        }
        //player = photonPlayer;
        photonPlayer.varParse.UpdateValues();
        yield return(null);
    }
Ejemplo n.º 20
0
 public OnlineStore(Paypal paymentProcessor)
 {
     this.paymentProcessor = paymentProcessor;
 }
Ejemplo n.º 21
0
        public async Task <ActionResult> ProcesarPagoPaypal()
        {
            bool ocurrioError = false;
            Task <MembresiaUsuario> membresia = null;

            if (Request.Params["guid"] != null && Request.Params["guid"] != "" && Request.Params["paymentId"] != null && Request.Params["paymentId"] != "" &&
                Request.Params["token"] != null && Request.Params["token"] != "" && Request.Params["PayerID"] != null && Request.Params["PayerID"] != "")
            {
                try
                {
                    Membresia memActual = await ApiHelper.GET_By_ID <Membresia>("Membresia/GetMembresia", int.Parse(Session[Request.Params["guid"] + "memId"].ToString()), GetAuthToken);

                    MembresiaUsuario memUsuario = new MembresiaUsuario();
                    memUsuario.IdMembresia       = memActual.IdMembresia;
                    memUsuario.Nombre            = memActual.Nombre;
                    memUsuario.MontoTransaccion  = (memActual.Precio - (memActual.Descuento == null ? Convert.ToDecimal(0) : Convert.ToDecimal(memActual.Descuento)));
                    memUsuario.Precio            = memActual.Precio;
                    memUsuario.Duracion          = memActual.Duracion;
                    memUsuario.Promocion         = memActual.Promocion;
                    memUsuario.IdUsuario         = GetUserDecrypted.IdUsuario;
                    memUsuario.Descuento         = memActual.Descuento;
                    memUsuario.Activa            = true;
                    memUsuario.FechaExpiracion   = DateTime.Now.AddDays(memActual.Duracion + (memActual.Promocion == null ? 0 : Convert.ToInt32(memActual.Promocion)));
                    memUsuario.IdTransaccionPago = Request.Params["paymentId"].ToString();
                    memUsuario.Renovada          = false;
                    HttpResponseMessage result = await ApiHelper.POST <MembresiaUsuario>("MembresiaUsuarios/PostMembresiaUsuario", memUsuario, GetAuthToken);

                    membresia = result.Content.ReadAsAsync <MembresiaUsuario>();
                    if (result.IsSuccessStatusCode)
                    {
                        try
                        {
                            Paypal paypal        = new Paypal();
                            var    pagoEjecutado = paypal.ProcesarPagoMembresia(Request.Params["PayerID"], Request.Params["paymentId"]);
                            if (pagoEjecutado.state.ToLower() == "approved")
                            {
                                ViewBag.GUID             = Session[Request.Params["guid"]].ToString();
                                ViewBag.PaymentID        = Request.Params["paymentId"].ToString();
                                ViewBag.PaymentSucessful = true;
                            }
                            else
                            {
                                string razon = pagoEjecutado.failure_reason;
                            }

                            Session[Request.Params["guid"]]           = null;
                            Session[Request.Params["guid"] + "memId"] = null;
                        }
                        catch (PayPal.PaymentsException pay)
                        {
                            ocurrioError = true;
                            throw;
                        }
                        catch (PayPal.PayPalException ex)
                        {
                            ocurrioError = true;
                            throw;
                        }
                    }
                    else
                    {
                        throw new Exception("Ha ocurrido un error al procesar la transacción. Si el problema persiste contacte su administrador.");
                        //return Json(new { result="ERROR",Message="Ha ocurrido un error al procesar la transacción. Si el problema persiste contacte su administrador."});
                    }
                }
                catch (Exception)
                {
                    ocurrioError      = true;
                    ViewBag.GUID      = "";
                    ViewBag.PaymentID = "";
                }
            }
            else
            {
                ocurrioError = true;
            }
            if (!ocurrioError)
            {
                return(Redirect("../Membresia/ListarMisMembresias?paymentId=" + Request.Params["paymentId"]));
            }
            else
            {
                //TODO si ocurrio un error
                if (membresia != null)
                {
                    await ApiHelper.DELETE("MembresiaUsuarios/DeleteMembresiaUsuario", membresia.Result.IdMembresiaUsuario, GetAuthToken);
                }
                return(Redirect("../Home/Membresias?error=true"));
            }

            //var membresias = await ApiHelper.GET_ListById<Membresia>("MembresiaUsuarios/GetMembresiasUsuarioById", GetUserDecrypted.IdUsuario, GetAuthToken);
            //return Json(membresias, JsonRequestBehavior.AllowGet);
        }
Ejemplo n.º 22
0
        public async Task <bool> SavePaypalInfo(Paypal paypal)
        {
            _context.Paypals.Add(paypal);

            return(await SaveAll());
        }