|
|
|
PayPal Developer Community >
Forums >
Technical Discussion >
Basic Website Payments >
Re: Getting form variables
|
|
|
|
|
|
|
|
Re: Getting form variables
[ Edited ]
|
|
Wombat
Ace Developer
Posts: 1571
Registered: 02-14-2008

Message 2 of 8

Viewed 11,207 times
|

|
You would capture all that info from the buyer BEFORE any PayPal processing or even BEFORE a pay now button appears.
I believe you would follow something like this...
* You will need a pre payment form (nothing to do with PayPal) to capture that information,
* test for correct input value ranges or types,
* then if input checking passes ok generate the form code for a Buy Now button dynamically.
* generate a carry-over string concatenated with the applicable &name=value pairs,
* urlencode that string and place it as a value for the special PayPal form "custom" hidden tag,
*# generate an ID and place that ID as the "invoice" PayPal form hidden tag value.
To capture that information SECURELY and RELIABLY you would need to use the IPN process allowing the discreet transparent logic processing of the IPN script to save the PayPal returned data in some way identified by the unique buyer ID (*# above). You would UNencode that returned "custom" value.
Note the invoice tag is unique in itself in that one invoice value once used in a transaction, pass or fail, can never be used in another transaction (blocked by PayPal).
The "custom" tag is special in that PayPal merely return whatever you have sent as a value (the buyer never ses the result).
You will use (eventually when development nearly complete) the EWP process to hide all information in the form from prying eyes.
Should be an idea or two in that for you. Regards,
Message Edited by Wombat on 03-07-2008 12:39 AM
'imself. [ PHParagon.com ] ...bug free, my programs do occasionally include undisclosed FREE random features.
|
|
|
|
03-06-2008 05:37 AM
|
|
|
|
|
|
Re: Getting form variables
|
|
E-junkie
Ace Developer
Posts: 792
Registered: 08-17-2006

Message 3 of 8

Viewed 11,193 times
|

|
|
If you prefer to capture it after, then it's simply a matter of creating a form yourself or using a free form builder site like wufoo.com and then specifying the URL of that page as the return_url in your PayPal buy now button code form. You should also enable auto return in your paypal account so that buyers are redirected to that page automatically. Buyers who don't have a paypal account and pay with a credit card directly will be shown a button which they'll have to click to be sent to your form.
|
|
|
|
03-06-2008 07:59 AM
|
|
|
|
|
|
Re: Getting form variables
[ Edited ]
|
|
Wombat
Ace Developer
Posts: 1571
Registered: 02-14-2008

Message 4 of 8

Viewed 11,184 times
|

|
A static page form would not be of any use.
Yes it would appear if the buyer returned immediately to the site one way or the other BUT the buyer still has to be tied to the transaction and the post pay form will have to be tied in with that buyer too.
Static pages are more prone to spoofing simply because once the URL is known anyone can be told of it's existence, plus static pages are more susceptible to browser and ISP caching. However both these considerations are nothing really - because the page form MUST BE generated to ID the buyer and transaction.
So whether by a more logical pre pay process or the gathering of post pay data, programming logic within scripts will be needed.
Note both ways IPN must be used to avoid problems caused by browser or ISP crash after payment or even buyer inattentiveness and wandering off to other sites; as advised in the PayPal Order Management and other documents.
PS the last thing I would do is use an external form processor who's duty of care towards your client AFTER payment is zilch (no responsibility what so ever) and therefore you must take on that responsibility without control - and how does same tie in with auto record keeping.
Message Edited by Wombat on 03-07-2008 04:26 AM
'imself. [ PHParagon.com ] ...bug free, my programs do occasionally include undisclosed FREE random features.
|
|
|
|
03-06-2008 09:11 AM
|
|
|
|
|
|
|
|
Re: Getting form variables
[ Edited ]
|
|
Wombat
Ace Developer
Posts: 1571
Registered: 02-14-2008

Message 6 of 8

Viewed 11,121 times
|

|
Calicat
Do not be too concerned about the html coding. You may not understand much of that at the moment but it is a simple learning curve. A form is a simple means by which the BROWSER i.e. IExplorer or Firefox can gather info from the computer user and send it on to your web site's server in a way that is easily parsed in to component items.
Where all the power lies is in the programming of a server side program (script) which will be permanently waiting on the server for submissions from your form. The most common these days, and perhaps easiest to learn, is PHP (that's not to say php is the only one - just easiest now to learn to use).
Because you might capture such data before even bothering to show a pay now button form, some initial form processing functionality should be a little less daunting in that the customer will not be anxious about their payment yet. So how you do it is a little more flexible and dare I say it relaxed.
I realize today you probably know zero to nothing about programming too so an "i.e." for when you do get started (or deal with someone who does) might be something like...
The form submits values for... "sex" = 'Female' "Age" = '39' "Foot_Size" = '9.5' "Name" = 'Billy Bob' "Email" = 'bilbobby@someisp.dom'
By parsing the data sent by the form your waiting script could do basic checking of each "name=value" pair from the $_POST array (in php that's just an internal array of the data sent by the form, "ready made" so to speak in to what are referred to as NVPs or Name Value Pairs).
You know and therefore the script knows (is programmed to) what "names" to expect from your form so any superfluous nasties can be simply ignored; you program only for what is needed. That is what a "deicated" form processor does and is hugely easier to design than a general forms processor.
Don't be disheartened yet; there's more!
By checking the values, the script can redisplay your form if errors occur asking the customer to fix and resubmit the form.
When a customer visits your form page and being a script generated dynamic form (not just a static web page) your script can generate some unique values and place them in to any form's hidden tags value if / when needed.
So when / if the script decides the buyer has filled in the necessary information correctly and you remembering here the buyer hasn't yet forwarded any money, the script rather than redisplay the form instead generates and displays the required Pay Now Button form INSERTING the acquired data also...
1) the special data string might end up as the value of a hidden "custom" form tag... <input type="hidden" name="custom" value="sex=F&age=39&size=9.5&myname=Billy+Bob&address=ETC">
2) the special hidden tag named "invoice" would have a UNIQUE script generated value... <input type="hidden" name="invoice" value="<—PHP echo $str; –>"> ...where a bit of programming trickery produces, say... <input type="hidden" name="invoice" value="184725INV"> ...the latter (#2) also NOW BECOMING THE IDENTIFIER used to save ALL payment form data returned by PayPal after payment FOR JUST THAT CUSTOMER, and the "custom" value can be split up into it's various name=value pairs again for clear listing in that buyers record - probably in your database.
So we see how PayPal can be used to simply transport some previously obtained data to a post pay interface (yet if the payment fails that data is discarded in to cyberspace - nowhere)
A way out:
NOW the good news is IF you don't have the time to wait while you learn to do all this (which is actually not all that complex when looking at a final project) and you have a few bob put aside (Aus slang for money) then PayPal has a huge list of CERTIFIED developers who can be asked for quotes one of which may even be near you.
Long term I hope this brief outline shows there are quite straight forward logic steps that can be laid down to build a useful dedicated form processing script and an easy way to send this data to eventually arrive at another POST PAY script (via PayPal sent IPN) waiting to decide what to do if a payment is successful.
Also as previously mentioned this outline should make it easier to discuss your needs with an experienced developer.
Lucky I had a few bits to copy / change from an old emailed tutorial, aye?
PS "...I don't yet know about how to create a string and urlencode it..." I have deliberately left out describing the url encoding bit. Over simplified, what it does is transform the above "custom" tag value in to a weird looking character string to avoid errors when transported by browser to eventually via PayPal arrive at and be un-encoded by the IPN script.
Message Edited by Wombat on 03-07-2008 02:46 PM
'imself. [ PHParagon.com ] ...bug free, my programs do occasionally include undisclosed FREE random features.
|
|
|
|
03-06-2008 07:11 PM
|
|
|
|
|
|
Re: Getting form variables
|
|
Calicat
Visitor
Posts: 3
Registered: 03-06-2008


Message 7 of 8

Viewed 11,107 times
|

|
That helps a lot. Working out how to do the invoice number part sounds like I would need to study more, sleep less. But the other part about getting an array sounds easier to get going and figuring out how to unpack it afterward shouldn't be too hard. I don't expect too many hundreds of orders just yet, so I should be able to mix and match the payments with the variables I get back from PayPal Here is the HTML that I am working with to make the array etc.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>Untitled Document</title> <script language="JavaScript" type="text/JavaScript"> <!-- function MM_findObj(n, d) { //v4.01 var p,i,x; if(!d) d=document; if((p=n.indexOf("?" )>0&&parent.frames.length) { d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);} if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n]; for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); if(!x && d.getElementById) x=d.getElementById(n); return x; }
function MM_validateForm() { //v4.0 var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments; for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]); if (val) { nm=val.name; if ((val=val.value)!="" { if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@'); if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n'; } else if (test!='R') { num = parseFloat(val); if (isNaN(val)) errors+='- '+nm+' must contain a number.\n'; if (test.indexOf('inRange') != -1) { p=test.indexOf(':'); min=test.substring(8,p); max=test.substring(p+1); if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n'; } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; } } if (errors) alert('The following error(s) occurred:\n'+errors); document.MM_returnValue = (errors == ''); } //--> </script> </head>
<body> <p> </p> <form name="form1" method="post" action=""> <p>This a sample form </p> <table width="662" height="166" border="2" cellpadding="2" cellspacing="1"> <tr> <td> </td> <td>Name : <input name="name" type="text" id="name" onBlur="MM_validateForm('name','','R');MM_validateForm('name','','R');return document.MM_returnValue" maxlength="30"></td> <td><label>Gender: <input type="radio" name="Gender" value="sex"> Female</label> <label> <input type="radio" name="Gender" value="radio"> Male</label> <br></td> </tr> <tr> <td> </td> <td>Address: <input name="street" type="text" id="street" onBlur="MM_validateForm('street','','R');MM_validateForm('street','','R');return document.MM_returnValue" maxlength="20"></td> <td>State : <select name="state" id="state" onchange="setUS()"> <option value="x">Select a State</option> <option value="Alabama">Alabama</option> <option value="Alaska">Alaska</option> <option value="Arizona">Arizona</option> <option value="Arkansas">Arkansas</option> <option value="California">California</option> <option value="Colorado">Colorado</option> <option value="Connecticut">Connecticut</option> <option value="Delaware">Delaware</option> <option value="District of Columbia">District of Columbia</option> <option value="Florida">Florida</option> <option value="Georgia">Georgia</option> <option value="Hawaii">Hawaii</option> <option value="Idaho">Idaho</option> <option value="Illinois">Illinois</option> <option value="Indiana">Indiana</option> <option value="Iowa">Iowa</option> <option value="Kansas">Kansas</option> <option value="Kentucky">Kentucky</option> <option value="Louisiana">Louisiana</option> <option value="Maine">Maine</option> <option value="Maryland">Maryland</option> <option value="Massachusetts">Massachusetts</option> <option value="Michigan">Michigan</option> <option value="Minnesota">Minnesota</option> <option value="Mississippi">Mississippi</option> <option value="Missouri">Missouri</option> <option value="Montana">Montana</option> <option value="Nebraska">Nebraska</option> <option value="Nevada">Nevada</option> <option value="New Hampshire">New Hampshire</option> <option value="New Jersey">New Jersey</option> <option value="New Mexico">New Mexico</option> <option value="New York">New York</option> <option value="North Carolina">North Carolina</option> <option value="North Dakota">North Dakota</option> <option value="Ohio">Ohio</option> <option value="Oklahoma">Oklahoma</option> <option value="Oregon">Oregon</option> <option value="Pennsylvania">Pennsylvania</option> <option value="Puerto Rico">Puerto Rico</option> <option value="Rhode Island">Rhode Island</option> <option value="South Carolina">South Carolina</option> <option value="South Dakota">South Dakota</option> <option value="Tennessee">Tennessee</option> <option value="Texas">Texas</option> <option value="Utah">Utah</option> <option value="Vermont">Vermont</option> <option value="Virginia">Virginia</option> <option value="Washington">Washington</option> <option value="West Virginia">West Virginia</option> <option value="Wisconsin">Wisconsin</option> <option value="Wyoming">Wyoming</option> </select></td> </tr> <tr> <td> </td> <td>City: <input name="city" type="text" id="city" onBlur="MM_validateForm('city','','R');return document.MM_returnValue" maxlength="15"></td> <td> </td> </tr> <tr> <td> </td> <td>Zipcode : <input name="zip" type="text" id="zip" onBlur="MM_validateForm('zip','','RisNum');return document.MM_returnValue" maxlength="5"></td> <td>Foot Size: <input name="size" type="text" id="size" onBlur="MM_validateForm('name','','R','size','','RisNum');return document.MM_returnValue" maxlength="3"></td> </tr> <tr> <td> </td> <td>Email: <input name="email1" type="text" id="email1" onBlur="MM_validateForm('email1','','RisEmail');return document.MM_returnValue" maxlength="20"></td> <td> </td> </tr> <tr> <td> </td> <td>Confirm Email: <input name="email2" type="text" id="email2" onBlur="MM_validateForm('email2','','RisEmail');return document.MM_returnValue" maxlength="30"></td> <td> </td> </tr> </table> <p> <input type="submit" name="Submit" value="To Put my Pay Now Button here"> </p> </form> <p> </p> </body> </html>
|
|
|
|
03-06-2008 09:19 PM
|
|
|
|
|
|
Re: Getting form variables
|
|
Wombat
Ace Developer
Posts: 1571
Registered: 02-14-2008

Message 8 of 8

Viewed 11,076 times
|

|
Calicat
I have returned your PM.
'imself. [ PHParagon.com ] ...bug free, my programs do occasionally include undisclosed FREE random features.
|
|
|
|
03-07-2008 01:49 PM
|
|
|
|
|
|
|