Jack Wilsdon
Jack Wilsdon

Reputation: 7045

PayPal Donate Button Redirect After Payment

I know how to make a PayPal donate button redirect after payment, but what I need to know is, can you pass the payed amount through this redirection. So it would redirect to http://example.com/donate?amount=123, is this even possible? Thanks!

EDIT: It seems I can do it with IPN(?), I just don't know how to use paypal's IPN, can anyone help me? (yes I have read the docs, they are confusing)

Upvotes: 2

Views: 4046

Answers (1)

aletzo
aletzo

Reputation: 2456

yes it is possible, like so:

<!-- where you setup your paypal button : -->
<input type="hidden" name="return" value="http://example.com/donate?amount=<?php echo $amount ?>" />

But (concerning security)

It would be better to keep it in e.g. $_SESSION['amount'] along with a reference id $_SESSION['reference_id'] = md5('whatever you like' . 'plus salt');

And in the paypal button use that reference_id like so:

<input type="hidden" name="return" value="http://example.com/donate?ref=<?php echo $_SESSION['reference_id'] ?>" />

And then, if $_GET['ref'] == $_SESSION['reference_id'], then you can use the $_SESSION['amount'] variable.

Upvotes: 3

Related Questions