Our Sponsors



Custom jobs at low cost, free lancers and service buyers.
PHP Nuke themes, stock photos, icons, drupal themes and more.



Western Studios :: View topic - Cry for help!!
Need Jobs done? Use our brand new Jobs Board to get your projects done at affordable prices.
 Forum FAQForum FAQ   SearchSearch   UsergroupsUsergroups     ProfileProfile   Log inLog in 


Cry for help!!


Goto page Previous  1, 2, 3  Next
 
Post new topic   Reply to topicprinter friendly version    Western Studios Forum Index -> Web Design
Western Studios

Site Admin
Site Admin
~PHP Nuke User~

Platinum Subscriber

Posts: 3366
Staff
Next Group: 1634 posts
admin(Mark) wrote:

hi, yes you need a button to pass the hidden fields to paypal.
Paypal has two ways to return the data to your website. You can turn the ipn feature on in your paypal account and put the link to your ipn script(not recommended) or you can pass the link as hidden fields in your form(recommended).

add these three fields to form.

Code:
return
cancel_return
notify_url


Each must have their own values.
return -> The value for this is a url to a success page on your site after a user subscribes.
cancel_return ->The value for this would be a url to the page a user sees when they cancel
notify_url -> The value for this is the url to your IPN script.

Posted: Tue Jun 20, 2006 1:19 pm

Western Studios

WS Newbie
WS Newbie
~PHP Nuke User~


Posts: 41
Next Group: 9 posts
JRowe wrote:

Ok then, Customer registers, then is taken to a page with the paypal button, which they press and then are sent to paypal. Is there any way to incorporate the initial write to the database with the paypal button, so theres not the extra step of clicking on submit information and then on the paypal button?

Anyway, the button script is like so:

Code:

(form action="https://www.paypal.com/cgi-bin/webscr" method="post")
(table)(tr)(td)(input type="hidden" name="on0" value="ID")ID(/td)(td)(input type="text" name="os0" maxlength="200")(/td)(/tr)(/table)(input type="image" src="http://mywebsite.com/Images/goButton.gif" border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!")
(img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1")
(input type="hidden" name="cmd" value="_xclick-subscriptions")
(input type="hidden" name="business" value="mypaypalEmail@somewhere.com")
(input type="hidden" name="item_name" value="Name of Subscription")
(input type="hidden" name="item_number" value="1")
(input type="hidden" name="no_shipping" value="1")
(input type="hidden" name="return" value="www.website.com/mySuccess.php")
(input type="hidden" name="cancel_return" value="www.website.com/myCancel.php")
(input type="hidden" name="no_note" value="1")
(input type="hidden" name="currency_code" value="USD")
(input type="hidden" name="bn" value="PP-SubscriptionsBF")
(input type="hidden" name="a1" value="3.95")
(input type="hidden" name="p1" value="1")
(input type="hidden" name="t1" value="M")
(input type="hidden" name="a3" value="9.95")
(input type="hidden" name="p3" value="1")
(input type="hidden" name="t3" value="M")
(input type="hidden" name="src" value="1")
(input type="hidden" name="sra" value="1")
(input type="hidden" name="notify_url" value="www.myWebsite.com/IPN.php")
(/form)



I think I get it now. I'll set up the IPN script and insert this button in place of what was there before, and hopefully (!) I can get this to work.

BTW, my boss had decided against using a CMS and wanted me to learn about automating the systems, rather than implementing existing scripts. I suppose this way it will be much easier for me to change things down the line, since I've had to work to understand every aspect of the process. A full fledged merchant gateway account is next on the list, for credit card processing *shudder*. At least I'm getting good with database work Smile

Thanks!

Posted: Tue Jun 20, 2006 2:34 pm

Western Studios

WS Newbie
WS Newbie
~PHP Nuke User~


Posts: 41
Next Group: 9 posts
JRowe wrote:

ok, here it is! the dreaded ipn script. All I want to do is update the game databases if payment is verified. Other service issues are irrelevant at this point in time, so here goes:

Code:
<?
// read the post from PayPal system and add 'cmd'
$req = 'cmd=_notify-validate';

foreach ($_POST as $key => $value) {
$value = urlencode(stripslashes($value));
$req .= "&$key=$value";
}
//paswords inited
//passwords were here, not here now since this is public, and well, you dont post passwords on public forums. that r bad. :P

// post back to PayPal system to validate
$header .= "POST /cgi-bin/webscr HTTP/1.0\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Content-Length: " . strlen($req) . "\r\n\r\n";
$fp = fsockopen ('www.paypal.com', 80, $errno, $errstr, 30);

// assign posted variables to local variables
$item_name = $_POST['item_name'];
$item_number = $_POST['item_number'];
$payment_status = $_POST['payment_status'];
$payment_amount = $_POST['mc_gross'];
$payment_currency = $_POST['mc_currency'];
$txn_id = $_POST['txn_id'];
$receiver_email = $_POST['receiver_email'];
$payer_email = $_POST['payer_email'];
// custom varible
$ID = $_POST['ID'];
//retrieve payment status
$payment_status = $_POST['payment_status'];

if (!$fp) {
// HTTP ERROR
}
else{
fputs ($fp, $header . $req);
while (!feof($fp)) {
$res = fgets ($fp, 1024);
if (strcmp ($res, "VERIFIED") == 0) {

//Grab $username from billing DB
mysql_connect(localhost,$BDBUsername,$BDBPassword);
@mysql_select_db($BDBDatabase) or die( "Unable to select database");
$Query = "SELECT 'Username' FROM Customer WHERE '$ID' == 'Id'";
$Result=mysql_query($Query);
$username = $Result;
mysql_close();

if ($payment_status == "Completed")
{
//UPDATE Gameserver 1
mysql_connect('server IP',$GameDBUsername1,$GameDBPassword1);   
@mysql_select_db($GameDB1) or die( "Unable to select database");   
$query1 = "Update t_users SET a_enable ='1' WHERE a_idname = '$username'";
mysql_query($query1);   
mysql_close();   

//UPDATE Gameserver 2
mysql_connect('server IP',$GameDBUsername2,$GameDBPassword2);   
@mysql_select_db($GameDB2) or die( "Unable to select database");   
$query2 = "Update t_users SET a_enable ='1' WHERE a_idname = '$username'";
mysql_query($query2);
mysql_close();   
}
}
}
}
?>


What do I need to change, if anything? I set this script to be IPN.php, configured the paypal profile to IPN-> On.

Will this work? It appears to do so now. Please give it a gander Smile

Posted: Tue Jun 20, 2006 5:05 pm

Western Studios

WS Newbie
WS Newbie
~PHP Nuke User~


Posts: 41
Next Group: 9 posts
JRowe wrote:

Ok, I can process the payment now, getting Verified or w/e from Paypal. The only problem I have is passing the Index number (ID for each individual) through paypal. How do I pass a custom variable?

Posted: Tue Jun 20, 2006 7:23 pm

Western Studios

WS Newbie
WS Newbie
~PHP Nuke User~


Posts: 41
Next Group: 9 posts
JRowe wrote:

ok, cool. I'm down to one last problem, and thats making the button pass a custom variable. I can grab the unique ID for each customer, but I don't know how to set it in the button or the IPN. The closest I've gotten thus far is passing all the normal payment variables and making a legitimate payment.

It doesnt do me much good when the game account isn't activated, tho Razz

@admin:
Could I send you my code directly, the registration, button, and IPN processing, and have you tell me where to put the custom variable?

Posted: Tue Jun 20, 2006 8:19 pm

Post new topic   Reply to topic    Western Studios Forum Index -> Web Design All times are GMT - 5 Hours
Goto page Previous  1, 2, 3  Next
Page 2 of 3

 
Jump to:  
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


Related topics
 Topics   Replies   Author   Views   Last Post 
No new posts I'm back 1 xtrax 763 Sat Mar 04, 2006 7:18 pm
admin View latest post
No new posts Ajax - The past is back 0 admin 759 Wed Nov 16, 2005 2:53 pm
admin View latest post
No new posts We're back 0 admin 679 Thu May 05, 2005 8:04 am
admin View latest post
No new posts Site back online 2 admin 873 Tue Apr 05, 2005 10:36 am
admin View latest post
No new posts Downloads will be back soon 1 admin 808 Wed Feb 23, 2005 2:36 pm
admin View latest post
 
Forums ©