tags:

views:

294

answers:

2

I wanted to get the userid from paypal after the user have made his payment.

Pay.php

<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="<?php echo $merchant_email ?>">
<input type="hidden" name="item_name" value="IPN test">
<input type="hidden" name="item_number" value="1">
<input type="hidden" name="amount" value="0.01">
<input type="hidden" name="notify_url" value="<?php echo $ipn_url ?>">
<input type="hidden" name="return"     value="<?php echo $return_url ?>">
<input type="hidden" name="cancel_return" value="<?php echo $cancel_url ?>">
<input type="hidden" name="userid" value="888">
<input type="hidden" name="currency_code" value="USD">
<input type="image" src="https://www.paypal.com/en_US/i/btn/x-click-but23.gif"
       border="0" name="submit" alt="Buy Now">

So I would enable ipn in my paypal account and point to http://www.domain.com/ipn.php?

In ipn.php code

<?php
$userid = $_POST['userid'];


$qry = "INSERT into mypayments(userid) VALUES ('$userid') “;
$result = mysql_query($qry,$db);
?>

Is it correct? How do I get VERIFIED from paypal?

A: 

Its a two step process.

PayPal will post an IPN to the url you specified in $ipn_url.

You will then get a VERIFIED response when you post all of the IPN data with an additional cmd=_notify-validate param (details) back to PayPal.

PHP sample here.

Alex K.
A: 

I believe that userid is an incorrect name and will not be returned in your IPN message. I use the optional fields for passing IDs and stuff needed for processing the transaction on my end.

These optional tags are on0, on1, or on3 for the custom field names and os0, ls1, and os2 for the custom field values.

I would send on0 with a value of "UserID" and os0 the actual ID.

These values will be represented in the IPN as follows:

os0 is represented as option_selection1

os1 is represented as option_selection2

os2 is represented as option_selection3

on0 is represented as option_name1

on1 is represented as option_name2

on2 is represented as option_name3

Here's the info on PayPal's HTML parameters

jumpdart