如何使用“立即购买”按钮将会话变量传递给 PayPal

发布于 2024-09-30 12:09:59 字数 1104 浏览 0 评论 0原文

当我的用户使用保存在会话变量中的用户名和用户 ID 登录时,他们可以使用 paypal 进行捐赠。使用简单的“立即购买”按钮,您可以在 PayPal 上轻松生成。

<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="XXX">
<input type="image" src="https://www.paypal.com/en_US/i/btn/btn_buynowCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
<img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>

当他们付款成功后,他们将连同所有 _POST 数据一起发送到我的confirm_ payment.php。我可以使用他们支付时使用的邮件,并将其与我的用户数据库进行比较,以找到正确的用户,但我无法确定他们对 PayPal 和我的网站使用相同的电子邮件。

我需要将 $_SESSION['username'] 传递给 paypal,以便我可以使用此信息自动为我的用户提供捐赠者状态。 添加类似以下内容吗

<input type="hidden" name="custom" value="custom variable">

我可以在我的按钮代码中 ?以下是有关可用变量的更多信息 paypal 信息

When my users are logged in with their username and userid saved in the session variable they can donate using paypal. With the simple buy now button that you can simply generate at paypal.

<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="XXX">
<input type="image" src="https://www.paypal.com/en_US/i/btn/btn_buynowCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
<img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>

When they payment is successful they are sent to my confirm_payment.php with all the _POST data. I can use the mail they paid with and compare this with my user database to find the correct user, but I can't be sure that they use the same email for paypal and my site.

I need to pass the $_SESSION['username'] to paypal so I can use this information to give my users donator status automatically. Can I add something like:

<input type="hidden" name="custom" value="custom variable">

to my button code? Here is more info on the variables avaliable paypal info

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

稚气少女 2024-10-07 12:09:59

我发现文档令人困惑,但经过大量网页浏览后,我发现自定义变量不允许您创建自己的隐藏字段,但有 3 个变量可能有用:

“自定义”可选传递变量用于您自己的跟踪买家看不到的目的。
默认值 – 没有变量传递回给您。 256 个字符

“item_number” 请参阅说明。传递变量,供您跟踪购买的产品或服务或所做的贡献。您指定的值将在付款完成后传回给您。如果您希望 PayPal 跟踪库存或跟踪按钮销售的商品的损益,则需要此变量。

“invoice”可选传递变量,您可以使用它来识别本次购买的发票号码。
默认值 – 没有变量传递回给您。 127个字符。

因此,如果您在允许“立即购买”按钮触发之前保存数据(我通过显示所做选择并将其保存到数据库的摘要屏幕来做到这一点),那么您可以输入一个值(例如保存数据的主键) ) 作为自定义值。

请注意,数据将发布到您指定的即时付款通知页面。

来自

https://www. x.com/developers/paypal/documentation-tools/paypal- payment-standard/integration-guide/Appx_websitestandard_htmlvariables#id08A6HF00TZS

I found the documentation confusing but after a lot of web browsing I discovered that the custom variables do not allow you to create your own hidden fields but there are 3 variables that may be useful:

"custom" Optional Pass-through variable for your own tracking purposes, which buyers do not see.
Default – No variable is passed back to you. 256 characters

"item_number" See description. Pass-through variable for you to track product or service purchased or the contribution made. The value you specify is passed back to you upon payment completion. This variable is required if you want PayPal to track inventory or track profit and loss for the item the button sells.

"invoice" Optional Pass-through variable you can use to identify your invoice number for this purchase.
Default – No variable is passed back to you. 127characters.

So if you save your data prior to allowing the buy now button to fire (I do this by having a summary screen which shows the choices made and saves them to a database) you can then put a value (e.g. primary key of the saved data) as the custom value.

Note that the data will be posted to the instant payment notification page that you designate.

From

https://www.x.com/developers/paypal/documentation-tools/paypal-payments-standard/integration-guide/Appx_websitestandard_htmlvariables#id08A6HF00TZS

ˇ宁静的妩媚 2024-10-07 12:09:59

是的,您可以这样添加,这是正确的方法,当 paypal 向您返回 IPNHandler 时,您将获得此 custom 的值code> 查询字符串中同名的隐藏字段。

yes you can add like this, this is the correct way, and when paypal pings you back on IPNHandler then you'll get the value of this custom hidden field in querystring with the same name.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文