Question

When my users are logged in with their username and userid saved in the session variable they can donate using paypal. With the simple buy now button that you can simply generate at paypal.

<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="XXX">
<input type="image" src="https://www.paypal.com/en_US/i/btn/btn_buynowCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
<img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>

When they payment is successful they are sent to my confirm_payment.php with all the _POST data. I can use the mail they paid with and compare this with my user database to find the correct user, but I can't be sure that they use the same email for paypal and my site.

I need to pass the $_SESSION['username'] to paypal so I can use this information to give my users donator status automatically. Can I add something like:

<input type="hidden" name="custom" value="custom variable">

to my button code? Here is more info on the variables avaliable paypal info

Was it helpful?

Solution

yes you can add like this, this is the correct way, and when paypal pings you back on IPNHandler then you'll get the value of this custom hidden field in querystring with the same name.

OTHER TIPS

I found the documentation confusing but after a lot of web browsing I discovered that the custom variables do not allow you to create your own hidden fields but there are 3 variables that may be useful:

"custom" Optional Pass-through variable for your own tracking purposes, which buyers do not see. Default – No variable is passed back to you. 256 characters

"item_number" See description. Pass-through variable for you to track product or service purchased or the contribution made. The value you specify is passed back to you upon payment completion. This variable is required if you want PayPal to track inventory or track profit and loss for the item the button sells.

"invoice" Optional Pass-through variable you can use to identify your invoice number for this purchase. Default – No variable is passed back to you. 127characters.

So if you save your data prior to allowing the buy now button to fire (I do this by having a summary screen which shows the choices made and saves them to a database) you can then put a value (e.g. primary key of the saved data) as the custom value.

Note that the data will be posted to the instant payment notification page that you designate.

From

https://www.x.com/developers/paypal/documentation-tools/paypal-payments-standard/integration-guide/Appx_websitestandard_htmlvariables#id08A6HF00TZS

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top