将自定义数据发送到 PayPal 并在交易完成后取回

send custom data to PayPal and get it back once the transaction is completed

我的网站上有一个带有 PayPal 按钮的表格,买家可以在其中输入我需要处理 her/his 愿望的数据。我想将这些数据保存到我的数据库中,但只能在用户进行交易之后。

本质上,我需要将此自定义数据转发给 PayPal,一旦用户完成交易,PayPal 应将其发回给我,如果用户未完成交易,则将其丢弃。

是否可以将自定义数据发送到 PayPal 并将相同的数据发送到我服务器上的 listenerPage.php? listenerPage.php 会将数据存储到数据库中。我是 PayPal 的新手,这正是我想象中的流程。我也对其他解决方案持开放态度。

<input class="import-input-i-need-to-get-from-paypal" type="text" placeholder="Data">   
<a id="a-submit" href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=someID">Pay with PayPal</a>

使用 a 元素作为按钮时的附加问题。

href 属性应该是:https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&custom=customdata&hosted_button_id=someID"?这可以接受吗?

是的,您可以,而且非常简单。 在您的 paypal 按钮的表单中添加一个带有 'name' 属性 "custom" 和自定义数据作为值的隐藏字段。它将 return 返回为 "custom"

<input type="hidden" name="custom" value="custom data here" />