我可以向 paypal 发送一个变量,并在付款完成后将其发回给我吗?
我一直在使用快速结帐 API 在付款后将我网站上的人们帐户转换为高级帐户。唯一的问题是,在用户单击返回按钮之前,它不会将用户送回站点,并且在发生这种情况时更新他们的权限。大约 40% 的用户似乎没有这样做......所以他们的帐户在付款后永远不会被记入贷方。
尽管 paypal 在成功付款后立即回发,但我始终无法使其真正立即更新用户的帐户,因为我无法让它发回某种可以识别刚刚完成付款的用户的信息。只有当您被发送回发送我通过回发记录的事务 ID 的站点时,我才能执行此操作。它会搜索它,如果在数据库中找到它则授予权限。
有没有办法向贝宝提交某种变量,然后它会发回给我?像&user_id=123这样的东西,这将使更新用户的权限变得非常方便。
Ive been using express checkout API to convert people's accounts on my site to premium accounts after paying. The only problem with it is that it doesn't send the user back to the site until they click the button to return, and it updates their permission when that happens. About 40% of the users don't seem to do that.... so their accounts never get credited after payment.
Although paypal does an instant post-back upon the successful payment, I was never able to make it actually update the user's account right away, since I cant get it to send back some sort of informational that would identify the user that just completed the payment. I could only do that when you are sent back to the site, which sends the transaction ID, that I logged with a post-back. It searches for it, and grants permission if it was found int he DB.
Is there a way to submit some sort of a variable to paypal, that it will then post back to me? Something like &user_id=123, which would make it very handly to update the user's permission.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(8)
2021 年对我有用的是在我的客户端应用程序中将“custom_id”(在“purchase_units”数组内)传递给 PayPal,并在后端检查“custom”。
是的,PayPal 似乎出于某种原因重命名了该参数。
What worked for me in 2021 is passing "custom_id" (inside the "purchase_units" array) to PayPal in my client app and checking "custom" on my backend.
Yes, it looks like PayPal renames the parameter for some reason.
Iten_number
隐藏变量在我的应用程序中不起作用。但我发现custom
隐藏字段工作正常。只需将此字段添加到由 paypal 生成的表单中:。之后,您可以读取此值来识别例如购买了什么产品。 (Java 代码):
String custom = request.getParameter("custom");
Iten_number
hidden variable don't work in my application. But i found thatcustom
hidden field works fine. Just add this field to the form, generated by paypal:<input type="hidden" name="custom" value="YOUR VALUE FROM DB"/>
. After, you can read this value to identify, for example, what product have been purchased. (Java code):String custom = request.getParameter("custom");
是的,如果您发送
item_number
,IPN 通知 将在发布时包含该信息回到你身边。当用户开始付款流程时,我会在数据库中记录一个唯一的 ID,并将其发送到 PayPal 时包含该 ID。当 IPN 出现时,该唯一 ID 会与数据库中的记录相匹配,从而为我提供所需的所有信息。编辑回复您的评论:
我希望上面链接的网站上有一个代码示例,但基本上就我而言,我使用的是发布到 https://www.paypal.com/cgi-bin/webscr。该表单中记录了 IPN 内容中的各种隐藏字段(
cmd
表示要执行的命令,business
指定您的企业 ID,item_name
表示PayPal UI 中的一个很好的描述,item_number
代表我上面提到的商品编号,等等)。当 IPN 发回您的 IPN 地址时,它包含各种字段(例如payment_status - 有点重要! &mdash 以及您在发布给他们)。
Yes, if you send
item_number
, the IPN notification will include that when it posts back to you. I record a unique ID in the database when the user starts the payment process, and include that when sending them to PayPal. When the IPN comes in, that unique ID matches up with the record in the database, giving me all the info I need.Edit Re your comment:
I expect there's a code example somewhere on the site linked above, but basically in my case I'm using a form that I POST to https://www.paypal.com/cgi-bin/webscr. Within that form are various hidden fields documented in the IPN stuff (
cmd
for what command to perform,business
to specify your business ID,item_name
for a nice description in the PayPal UI,item_number
for the item number I mentioned above, etc., etc.). When IPN posts back to your IPN address, it includes various fields (such aspayment_status
— kind of important! &mdash and theitem_number
you fed in when posting to them).只是为了补充这个老问题......
有一些选项参数通常用于通过 paypal 发送自定义数据。
这些选项标签为自定义字段名称的 on0、on1 或 on2 以及 os0、os1 和 os2 用于自定义字段值。
我将发送值为“UserID”的 on0 和实际 ID 的 os0 。
这些值将在 IPN 中表示如下:
os0 表示为 option_selection1
os1 表示为 option_selection2
< strong>os2 表示为 option_selection3
on0 表示为 option_name1
on1 表示为 >option_name2
on2 表示为 option_name3
这是有关 PayPal HTML 参数的信息
Just to add to this old question...
There are option parameters that are commonly used for custom data sending through paypal.
These option tags are on0, on1, or on2 for the custom field names and os0, os1, and os2 for the custom field values.
I would send on0 with a value of "UserID" and os0 the actual ID.
These values will be represented in the IPN as follows:
os0 is represented as option_selection1
os1 is represented as option_selection2
os2 is represented as option_selection3
on0 is represented as option_name1
on1 is represented as option_name2
on2 is represented as option_name3
Here's the info on PayPal's HTML parameters
根据 PayPal 付款标准的 HTML 变量您可以发送所有“传递”变量:
和
所有这些传递变量均由 IPN 在支付响应信息中发回。
您只需在服务器端渲染 HTML 模板并将字段写回到 HTML 代码中,例如
从技术上讲,如果您想处理更多数据,“自定义”字段可以是 JSON 编码的字符串,例如
According to HTML Variables for PayPal Payments Standard you can send all the "Pass-through" variables:
and
All these pass-through variables are sent back by the IPN in the payment response info.
You just have to render your HTML template server-side and write the fields back in the HTML code like
Technically the field "custom" can be a JSON encoded string if you want to handle more data like
我终于得到了这个答案,我想与大家分享一下:
在您的 HTML 表单上放置此代码(这是 Paypal 沙箱):
在 Paypal 重定向到您的页面成功后,在您的 PHP 上:使用
cm 获取变量:
I finally get this answer, I want to share with all of you look:
on your HTML form put this code (this is Paypal sandbox):
On your PHP after the Paypal redirect to your page success: use the
cm
GET variable:我希望此网址能够解决您的问题。因为它也解决了我的问题。将自定义变量添加到您的表单中,然后在成功付款页面上检索它。
例子 :
然后将其检索为:
I hope this URL solves your issue. As it solved mine as well. Add a custom variable to your form and then retrieve it on your success payment page.
Example :
<input type='hidden' name='custom' value='<?php echo $email; ?>'/>
and then retrieve it as :
paypal 的响应将是
[option_name1] =>阿杰·加达瓦纳
[选项名称1] =>我的电话号码
[选项名称1] => my_third_extra_field
Response from paypal would be
[option_name1] => Ajay Gadhavana
[option_name1] => my_phone_number
[option_name1] => my_third_extra_field