 WS Newbie ~PHP Nuke User~Posts: 41
Next Group: 9 posts
JRowe wrote:Ok, here's my problem: I'm totally confusticated by the paypal IPN script. I work for a game company and my boss wants me to finish the paypal integration for the game registration process. I need to take variables from my registration form, pass them to paypal, and if the payment is succesful, activate the account. If the payment is unsuccessful, then send the user to a page explaining whatever the problem was. I'd be willing to pay $10 to someone's paypal if they could fix this up for me.
I collect the information from a registration page, and this validates it and then writes it to the databases. There is a billing database and 2 game databases. Those work fine... I just need to verify payment status with paypal.
Code: |
<?php
//HERE THERE BE GAMES
$_POST[gametitle] = 'Game Name Here';
//HERE THERE BE GAMES
//SET USER INFO
$firstname=$_POST[firstname];
$lastname=$_POST[lastname];
$address=$_POST[address];
$city=$_POST[city];
$state=$_POST[state];
$country=$_POST[country];
$zipcode=$_POST[zipcode];
$email=$_POST[email];
$username=$_POST[username];
$password=$_POST[password];
$gametitle=$_POST[gametitle];
//GET DATE
$date=date("y-m-d H:i:s");
//GET DATE
//PARSE USER INFO FOR BLANK FORMS
if(!$firstname || !$lastname || !$address || !$city || !$state || !$country || !$zipcode || !$email || !$username || !$password || !$gametitle)
{
echo 'Please fill out all the required information. Press the back button on the browser, or hit Alt+Left, and fill out all the required information.';
exit;
}
//PARSE USER INFO FOR BLANK FORMS
$BDBDatabase="Billing Database Address";
$GameDBAddress1="Game DB 1 Address";
$GameDBAddress1="Game DB 2 Address";
$BDBUsername="Username";
$BDBPassword="Password";
$BDBDatabase="DB";
$GameDBUsername1 ="Username";
$GameDBPassword1="Password";
$GameDB1="DB";
$GameDBUsername2 ="Username";
$GameDBPassword2="Password";
$GameDB2="DB";
//open connection to gameserv for username authentication
mysql_connect('$DBAddress',$GameDBUsername1,$GameDBPassword1);
mysql_select_db($GameDB1);
$query0="SELECT * FROM users WHERE idname='$username'";
$result=mysql_query($query0);
$num=mysql_numrows($result);
mysql_close();
if ($num>0) {
echo 'The User name you chose has been taken. Please select another name.';
exit;
}
//Open connection to BILLING database, select database, Define Information to be passed, run query, close connection.
mysql_connect(localhost,$BDBUsername,$BDBPassword);
@mysql_select_db($BDBDatabase) or die( "Unable to select database");
$query = "insert into Customer(FirstName, LastName, Address, City, State, country, ZipCode, Email, Username, Password, Game) values('$firstname','$lastname','$address','$city','$state','$country','$zipcode','$email','$username','$password','$gametitle')";
mysql_query($query);
mysql_close();
//Open connection to GAMESERVER 1 database, select database, Define Information to be passed, run query, close connection.
mysql_connect('$GameDBAddress1',$GameDBUsername1,$GameDBPassword1);
@mysql_select_db($GameDB1) or die( "Unable to select database");
$query1 = "insert into users(pay,idname, passwd,regi_date,enable,name,lastname,email,city,region,countryeic) values('d','$username','$password','$date','0','$firstname','$lastname','$email','$city','$state','$country')";
mysql_query($query1);
mysql_close();
//Open connection to GAMESERVER 2, select database, Define Information to be passed, run query, close connection.
mysql_connect('$GameDBAddress2',$GameDBUsername2,$GameDBPassword2);
@mysql_select_db($GameDB2) or die( "Unable to select database");
$query2 = "insert into users(pay,idname, passwd,regi_date,enable,name,lastname,email,city,region,countryeic) values('d','$username','$password','$date','0','$firstname','$lastname','$email','$city','$state','$country')";
mysql_query($query2);
mysql_close();
?> |
Is that enough information? I can add fields and grab information easily enough, I just can't figure out how to send information to paypal. It's a subscription, and the payment is 3.95 first month, 9.95 every month thereafter. I really got in over my head on this.
Any help I can get will be much appreciated.
I've gone through the IPN tutorial a dozen times and am no closer to figuring out how to implement this than I was at the start.
Posted: Thu Jun 15, 2006 6:58 pm
 Site Admin ~PHP Nuke User~ Posts: 3358
StaffNext Group: 1642 posts
admin(Mark) wrote:Would you like to send the information to paypal then update all three databases with the user data?
I get busy alot but I will try to help you. Will you use the address from the paypal account or from the form? If you are not going to use the paypal address then I suggest you create a temp table in the database to keep the user information pending the success of the payment. Make sure to use a unique auto increment field.
Once the user post the form, have the data stored in that table. Next run a query to get the unique id for the stored user's informations. You can simply do a query to find the id where the username is what that user's name is.
Once that is done, let me know so I can help you setup the script to send the data to paypal.
Posted: Fri Jun 16, 2006 2:59 am
 WS Newbie ~PHP Nuke User~Posts: 41
Next Group: 9 posts
JRowe wrote:
Quote: |
| Would you like to send the information to paypal then update all three databases with the user data? |
Yes, definitely what I'm working towards Although I'm writing account info to the databases before validation so that the customer can return and pay later if needed.
Quote: |
| I get busy alot but I will try to help you. Will you use the address from the paypal account or from the form? If you are not going to use the paypal address then I suggest you create a temp table in the database to keep the user information pending the success of the payment. Make sure to use a unique auto increment field. |
The Customer table is what I'm currently using for purchase information.
Quote: |
| Once the user post the form, have the data stored in that table. Next run a query to get the unique id for the stored user's informations. You can simply do a query to find the id where the username is what that user's name is. Once that is done, let me know so I can help you setup the script to send the data to paypal. |
The values are all assigned to variables within this script, and inserted into the database with
Code: |
$query = "insert into Customer(FirstName, LastName, Address, City, State, country, ZipCode, Email, Username, Password, Game) values('$firstname','$lastname','$address','$city','$state','$country' ,'$zipcode','$email','$username','$password','$gametitle')"; |
If I need more information to post to Paypal, I can easily update the registration form.
I'll get the query to grab the index ID set up and post it as soon as i get it figured out.
Posted: Fri Jun 16, 2006 4:21 am
 WS Newbie ~PHP Nuke User~Posts: 41
Next Group: 9 posts
JRowe wrote:
Code: |
mysql_connect(localhost,$BDBUsername,$BDBPassword);
@mysql_select_db($BDBDatabase) or die( "Unable to select database");
$PaypalQuery = "SELECT 'Id' FROM Customer WHERE '$username' == 'Username'";
$PaypalResult=mysql_query($PaypalQuery);
mysql_close(); |
Ok, I think that's correct. $PaypalResult returns the Id of the user.
Posted: Fri Jun 16, 2006 4:40 am
 WS Newbie ~PHP Nuke User~Posts: 41
Next Group: 9 posts
JRowe wrote:ok, so now instead of having the submit button enter the data into the database, I want to combine it with the paypal button, which submits all the data to paypal. From there, I want the paypal process to go through it's hoops, then return to my ipn page, which updates the account information previously written based on success or failure of the payment. So...
Here's the button:
Code: |
FORM NAME="form1" METHOD="post" ACTION="https://www.paypal.com/cgi-bin/webscr/"
INPUT TYPE="hidden" NAME="bn" VALUE="name of business"
INPUT TYPE="hidden" NAME="cmd" VALUE="_xclick-subscriptions"
INPUT TYPE="hidden" NAME="rm" VALUE="1"
INPUT TYPE=hidden NAME=business VALUE="business paypal email"
INPUT TYPE=hidden NAME=item_name VALUE="Item Name"
INPUT TYPE=hidden NAME=item_number VALUE="1"
INPUT TYPE=hidden NAME=currency_code VALUE="USD"
INPUT TYPE=hidden NAME=image_url VALUE="custom button image"
INPUT TYPE=hidden NAME=return VALUE="http://www.myReturnPage.com"
INPUT TYPE=hidden NAME=cancel_return VALUE="http://www.myCancelPage.com"
INPUT TYPE="hidden" NAME="a1" VALUE="3.95" //trial cost
INPUT TYPE="hidden" NAME="p1" VALUE="1" //trial period
INPUT TYPE="hidden" NAME="t1" VALUE="M" //trial period
INPUT TYPE="hidden" NAME="a3" VALUE="9.95" //normal cost
INPUT TYPE="hidden" NAME="p3" VALUE="1" //normal period
INPUT TYPE="hidden" NAME="t3" VALUE="M" //normal period
INPUT TYPE="hidden" NAME="no_shipping" VALUE="1" //indicate no shipping
input type="hidden" name="src" value="1" -- INPUT TYPE="hidden" NAME="notify_url" VALUE="www.myIPNProcessingScriptPage.com"
INPUT TYPE="submit" NAME="Submit" VALUE="Subscribe"
|
So the process would be:
User signs up, presses submit button
-user information is written to database
--user is redirected to paypal
---paypal recieves necessary information
User makes payment
-paypal sends me information
--the IPN script processes it
---On successful payment, Game account is enabled, User is redirected to main game site
----On failed payment, user is informed of the error and redirected to login page to reattempt payment with another method
-----At login page, User is authenticated using UN/PW
------User given the option to change their paypal email account, all other data scraped from database based on username.
-------User Presses submit button, database updated, paypal process reinitiated.
In the IPN script itself I can check the Billing Database (where IPN information will ultimately be stored) and enable or disable game accounts.
The only thing i need help with is the button and the IPN script.
What do I need to pass through with the button in order to send paypal user information?
How do I recieve the information from paypal?
I apologize in advance for my lack of understanding. I have a very linear thought process and the IPN inner workings have eluded me. Thanks for the help, admin
Posted: Mon Jun 19, 2006 3:55 pm
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
 |