我可以向 paypal 发送一个变量,并在付款完成后将其发回给我吗?

发布于 2024-09-01 10:32:56 字数 347 浏览 3 评论 0原文

我一直在使用快速结帐 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 技术交流群。

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

发布评论

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

评论(8

浮光之海 2024-09-08 10:32:57

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.

雅心素梦 2024-09-08 10:32:56

Iten_number 隐藏变量在我的应用程序中不起作用。但我发现 custom 隐藏字段工作正常。只需将此字段添加到由 paypal 生成的表单中:。之后,您可以读取此值来识别例如购买了什么产品。 (Java 代码):String custom = request.getParameter("custom");

Iten_number hidden variable don't work in my application. But i found that custom 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");

童话里做英雄 2024-09-08 10:32:56

是的,如果您发送 item_numberIPN 通知 将在发布时包含该信息回到你身边。当用户开始付款流程时,我会在数据库中记录一个唯一的 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 as payment_status — kind of important! &mdash and the item_number you fed in when posting to them).

停顿的约定 2024-09-08 10:32:56

只是为了补充这个老问题......

有一些选项参数通常用于通过 paypal 发送自定义数据。

这些选项标签为自定义字段名称的 on0on1on2 以及 os0os1 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

又爬满兰若 2024-09-08 10:32:56

根据 PayPal 付款标准的 HTML 变量您可以发送所有“传递”变量:

item_number 传递变量,供您跟踪产品或服务
购买或做出的贡献。您指定的值被传递
付款完成后返还给您。如果您需要此变量
希望 PayPal 跟踪库存或跟踪商品的损益
按钮卖出。

自定义传递变量,用于您自己的跟踪目的,买家看不到。默认 – 没有变量传递回给您。

发票传递变量,可用于识别本次购买的发票号码。默认值 – 没有变量传递回
你。

所有这些传递变量均由 IPN 在支付响应信息中发回。

您只需在服务器端渲染 HTML 模板并将字段写回到 HTML 代码中,例如

<input type="hidden" name="item_number" value="{{ productID }}">
<input type="hidden" name="invoice_id" value="{{ invoiceID }}">
<input type="hidden" name="custom" value="{{ jsonInfo }}">

从技术上讲,如果您想处理更多数据,“自定义”字段可以是 JSON 编码的字符串,例如

myItemObject = {
   "customerEmail" : "[email protected]
   "customerID: "AAFF324"
}
jsonInfo = json.dumps( myItemObject )
return render_template(tmpl_name, jsonInfo=jsonInfo, productID=productID, invoiceID=invoiceID)

According to HTML Variables for PayPal Payments Standard you can send all the "Pass-through" variables:

item_number 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.

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

and

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

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

<input type="hidden" name="item_number" value="{{ productID }}">
<input type="hidden" name="invoice_id" value="{{ invoiceID }}">
<input type="hidden" name="custom" value="{{ jsonInfo }}">

Technically the field "custom" can be a JSON encoded string if you want to handle more data like

myItemObject = {
   "customerEmail" : "[email protected]
   "customerID: "AAFF324"
}
jsonInfo = json.dumps( myItemObject )
return render_template(tmpl_name, jsonInfo=jsonInfo, productID=productID, invoiceID=invoiceID)
迷荒 2024-09-08 10:32:56

我终于得到了这个答案,我想与大家分享一下:

在您的 HTML 表单上放置此代码(这是 Paypal 沙箱):

form action="https://www.sandbox.paypal.com/cgi-bin/webscr?custom=YOUR_VAR" method="post"

在 Paypal 重定向到您的页面成功后,在您的 PHP 上:使用 cm 获取变量:

$example = $_GET["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):

form action="https://www.sandbox.paypal.com/cgi-bin/webscr?custom=YOUR_VAR" method="post"

On your PHP after the Paypal redirect to your page success: use the cm GET variable:

$example = $_GET["cm"];
往昔成烟 2024-09-08 10:32:56

我希望此网址能够解决您的问题。因为它也解决了我的问题。将自定义变量添加到您的表单中,然后在成功付款页面上检索它。
例子 :

然后将其检索为:

 $_POST['custom']

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 :

 $_POST['custom']
无戏配角 2024-09-08 10:32:56
<input type="hidden" name="on0" value="Ajay Gadhavana">
<input type="hidden" name="on1" value="my_phone_number">
<input type="hidden" name="on2" value="my_third_extra_field">

paypal 的响应将是

[option_name1] =>阿杰·加达瓦纳
[选项名称1] =>我的电话号码
[选项名称1] => my_third_extra_field

<input type="hidden" name="on0" value="Ajay Gadhavana">
<input type="hidden" name="on1" value="my_phone_number">
<input type="hidden" name="on2" value="my_third_extra_field">

Response from paypal would be

[option_name1] => Ajay Gadhavana
[option_name1] => my_phone_number
[option_name1] => my_third_extra_field

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