Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 852
iosfreak Avatar asked Jul 11 '11 22:07

iosfreak


People also ask

Can I customize PayPal button?

PayPal button The default value is gold , but you can also set it to: black , blue , silver , or white . Overrides the shape of the button. The default value is softEdges , but you can also set it to hardEdges or rounded . Adds a label next to the button logo.

What is PayPal capture ID?

After your buyer completes checkout, use the payment's transaction ID with authorization and capture in the PayPal website. From the website, you can: Capture a partial or full authorization amount. Authorize a higher amount, up to 115% of the originally authorized amount (not to exceed an increase of $75 USD).

How do I find my PayPal authorization ID?

Authorization ID - In the URI for the API call, replace the sample ID with your authorization ID. This is either the original authorization ID or the ID from reauthorizing the transaction. PayPal-RequestId - Replace the sample ID with a unique ID you generate.


2 Answers

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!

like image 57
iosfreak Avatar answered Oct 11 '22 13:10

iosfreak


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

like image 42
Brian Moreau Avatar answered Oct 11 '22 13:10

Brian Moreau