简体   繁体   中英

Give PayPal buy now button special ID?

I have a service I am starting where it's paid. I want to give a PayPal payment a special id. The ID would be passed through IPN and I could read it so I can modify my mysql database with that special ID. If that all makes sense...

I am basically want to upgrade their account without having to do some complicated process which I have already tried where it would send the user the transaction ID and they would have to go to a special URL to change their account information.

See what I mean? How would I go about doing this?

Thanks, Coulton

If anyone else has a question on how to do it, I've found a way to fix it. When making your button, include this:

<input type='hidden' name='notify_url' value='http://yourdomain.com/paypal/ipn.php?user_id=$user_id'>

So you can pass who has made the payment to the IPN via get. Simply use $_GET['user_id'] to get the data (in my case a user_id). You can pass any variables you wish!

I played around with this for ages before I have realized that you can only send the pre defined paypal variables and not make your own up.

These are listed here https://www.paypal.com/cgi-bin/webscr?cmd=p/pdn/howto_checkout-outside

One you can use for a custom variable is called 'custom'

<input type="hidden" name="custom" value="<?=$twitId;?>">

You also need to ensure you use this button

<input type="hidden" name="cmd" value="_s-xclick">

You also need to turn on and set a URL for the Instant Payment Notification on PayPal

They call this as a listener but it really just sends the payment data to the paypal page. Note this is not the URL the customer is returned to after payment completion as set in button preferences.

Retrieve the custom variable in PHP thus

$userID = $_POST[custom];

Full instructions here http://www.brianmoreau.com/articles/paypal_buy_now_button_sending_custom_variables.php

Hope this saves you the many hours I spent on it.

This method also allows you to obtain the buyer details such as email and address and the transaction reference.

To view the full data paypal sends after payment by clicking on history, IPN history

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM