Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New to the CF scene
    Join Date
    Jun 2011
    Posts
    8
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Javascript paypal Interaction

    Note: I'm not sure where to post this: Web design or Javascript. Since I'm writing this program in Javascript with HTML5, I am posting it here.

    I was recently asked by some friends if I could design a website for their non-profit fundraiser.

    The general concept is:

    1. People pay to submit a name to "the roster"
    2. People pay to submit a vote for which name they want to win.
    3. The Roster and votes are updated with a 'graphical' progress bar that shows the new names on the list and how many paid votes it has.
    My problem is that I can't figure out how to do Step 3 without doing it manually, as "Submitting a Name" and "Voting" are actually 'paypal' purchases, and I am not even sure if it is possible for me to do Step 3 automatically, at least using Javascript and HTML5 on it's own, after the user's payment has been confirmed and they can now vote--just because all of that happens on paypal's end, between the user, the merchant and paypal.

    Questions:

    1. Is it and How, if so, possible using Javascript and HTML5, to have a contest where people pay cash and the roster/leger automatically updates to reflect this (without anything like php or some other server side language...).
    2. Is there any predefined javascript code or scripts out there for the above 3 tasks?
    3. Any ideas for a more 'efficient' voting fundraiser project--

    For example, one alternative I thought to circumvent the "Verified" purchase problem was to create 'Tickets' with unique IDs and have them purchase a Ticket, and they can submit their ID number in a select area, once that ID number is submitted, they would be asked...who would you like to vote for, or if they'd like to submit their name...but I'm not sure how efficient that is either.

    With that all said

    Experience Level:

    I have a 'little' experience programming web pages and using Javascript, I don't have a lot of confidence in myself, but I'm in a game development course where programming is a requirement. So I've had experience making games in Javascript, CSS3 and HTML5 and basic assigned websites.

    When I was asked to do this project I thought I've had to do more complicated things in class than put up a 'list' of names, to vote for, but the addition of 'real money' has thrown me in for a loop (combined with this being my first 'out on my own' project since the programming courses, so lots of nervousness!).

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,028
    Thanks
    75
    Thanked 4,325 Times in 4,291 Posts
    No, you can't do this with HTML and JS, alone.

    The problem is, each user's computer will know about what "votes" they made, but how will Joe's computer know what Anne did???

    You *MUST* do this with server-side code: PHP/ASP/JSP.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #3
    New to the CF scene
    Join Date
    Jun 2011
    Posts
    8
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Old Pedant View Post
    No, you can't do this with HTML and JS, alone.

    The problem is, each user's computer will know about what "votes" they made, but how will Joe's computer know what Anne did???

    You *MUST* do this with server-side code: PHP/ASP/JSP.
    Thanks that is what I thought, as Javascript and HTML5 seems to focus on making things interactive not dealing with it past the server. (I was hoping that was ignorance on my part). With that out of the way is it plausible to create a variable that holds an array of unique "IDs", that an if/else statement would look for, ex. "If one of the special IDs" proceed to X, return true; else return false;

    My updated question is: This leaves me with "can my Javascript be permanently changed or affected by the user" for example if a user puts in a unique "ID", can the Javascript code 'reflect' that by if programmed to, removing that ID from the code altogether (or does that get into server-side), or would that "ID" have to be able to be used again by someone else with that code, or even by themselves (they could plug the code in several times)--i.e. would Javascript be unable to change that making the system riddled with an opportunity for abuse?
    Last edited by Ifna; 09-02-2013 at 12:26 AM.

  • #4
    New to the CF scene
    Join Date
    Jun 2011
    Posts
    8
    Thanks
    1
    Thanked 0 Times in 0 Posts
    (deleted)
    Last edited by Ifna; 09-02-2013 at 12:12 AM. Reason: double post

  • #5
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,592
    Thanks
    0
    Thanked 645 Times in 635 Posts
    Quote Originally Posted by Ifna View Post
    My updated question is: This leaves me with "can my Javascript be permanently changed or affected by the user" for example if a user puts in a unique "ID", can the Javascript code 'reflect' that by if programmed to, removing that ID from the code altogether (or does that get into server-side), or would that "ID" have to be able to be used again by someone else with that code, or even by themselves (they could plug the code in several times)--i.e. would Javascript be unable to change that making the system riddled with an opportunity for abuse?
    Your visitor has complete control over what JavaScript runs. They can decide not to run any JavaScript. They can add their own JavaScript that changes the values that your script uses after the page has loaded. They caneven turn on the JavaScript debugger and step through the code changing any values immediately before the statement that uses them runs.

    Any JavaScript you provide is for the convenience of your visitor. The code to do all of the validations for your purposes needs to be done on the server where your visitor can't bypass or change it.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • #6
    New to the CF scene
    Join Date
    Jun 2011
    Posts
    8
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Thanks for clarifications, I am now clear that Javascript has no chances whatsoever of being used to automatically validate & update -once- it goes to the Paypal server.

    I am no longer clear on the repercussions of using Javascript, within this current concept; Javascript is being used only to affect (1) the visual elements and navigation of the page & how the user interacts (example, being sent to a paypal shopping cart). (2) A visual reference to where we are in our goal, like a 'Progress Meter'. (3) This progress meter is updated manually (on our end) to reflect that so other users can see after we ourselves verify and approve the purchase.

    At a glance this sounds 100% doable to me, but my concern now is that an 'average user' can accidentally manipulate the page with globally reaching affects just based on what I am translating from your post:

    1. Are you saying that the average user (not a code savvy person) can change the code permanently not just on their end but so that it affects everyone...,even if they are not given that ability (ex. no Ticket ID). And if they did do this, wouldn't that boarder on hacking, and is that another can of worms entirely that any average user website is vulnerable to?
    Last edited by Ifna; 09-02-2013 at 01:24 PM.

  • #7
    New to the CF scene
    Join Date
    Jun 2011
    Posts
    8
    Thanks
    1
    Thanked 0 Times in 0 Posts
    (Never mind) this problem is solved. The design they had in mind is slightly flawed and more complicated than it needs to be as a result of that flaw, within the restrictions they wanted, (as it was inspired by another contest which upon examining it I realized was extremely simple, their list didn't automatically update to add new names to be voted upon at any time regardless of advantage, it was predefined). Thank you guys (gender neutral) for all of your help!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •