Let PayPal buy the special identifier button now?

I have a service with which I start, where it is paid. I want to give PayPal payment a special identifier. The identifier will be transmitted via IPN and I could read it, so I can change my mysql database with this special identifier. If all this makes sense ...

Basically, I want to update my account without having to do the complicated process that I already tried when it would send the transaction ID to the user and they would have to go to a special URL to change the account information.

See what I mean? How can i do this?

Thanks Coulton

+6
source share
2 answers

If anyone else has a question on how to do this, I have found a way to fix this. When creating your button, specify this:

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

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

+6
source

I played with this for ages before I realized that you can send predefined PayPal variables and not create your own.

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

The one you can use for a custom variable is called "custom"

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

You also need to make sure that you use this button.

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

You also need to enable and set the URL for instant payment alerts in PayPal

They call it a listener, but it really just sends the payment details to the PayPal page. Please note that this is not the URL at which the customer returns after the payment is completed, as indicated in the button settings.

Get a user variable in PHP this way

 $userID = $_POST[custom]; 

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

I hope this saves you from the many hours I spent on it.

This method also allows you to get buyer's details, such as email address and transaction address and link.

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

+1
source

Source: https://habr.com/ru/post/892539/


All Articles