PayPal Donate Button Redirect After Payment

我是研究僧i 提交于 2020-01-02 16:15:48

问题


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)


回答1:


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.



来源:https://stackoverflow.com/questions/9382985/paypal-donate-button-redirect-after-payment

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!