php 将自定义变量传递给 paypal IPN
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1838585/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Passing custom variables to paypal IPN
提问by spotlightsnap
I am trying to pass custom variables to paypal IPN. I can manage to pass one variable. But i don't know how to pass multiple variables.
我正在尝试将自定义变量传递给 paypal IPN。我可以设法传递一个变量。但我不知道如何传递多个变量。
My Process is something like this
我的流程是这样的
- User fill up the form
- They click button and it goes to paypal
- They paid, IPN send me back the information and that ipn.php added variables that passed to the database.
- 用户填写表格
- 他们单击按钮,然后转到贝宝
- 他们付了钱,IPN 将信息发回给我,ipn.php 添加了传递给数据库的变量。
My custom variables are
我的自定义变量是
- total lines (whenever they write, i count the lines)
- message (their message that they wrote)
- advertisement id
- 总行数(每当他们写作时,我都会计算行数)
- 消息(他们写的消息)
- 广告编号
But for now, I can only pass one variable like this
但是现在,我只能像这样传递一个变量
form.php
表单.php
<input name="custom" type="hidden" id="custom" value="{$line_count}">
$_SESSION['line_count'] = $_POST['lines_txt'];
ipn.php
ipn.php
$sql="INSERT INTO `form`(`totalline`) VALUES ('" .$_POST['custom']. "');";
采纳答案by Residuum
I am not sure, if it is even possible with Paypal to send and receive multiple variables. If it is not possible due to Paypal's restrictions, you could use one of the following approaches:
我不确定,Paypal 是否可以发送和接收多个变量。如果由于 Paypal 的限制而无法实现,您可以使用以下方法之一:
- Send the data serialized, and deserialize on return.
- Write the data to the database in form.php (with status notpaid) and send the id. In ipn.php catch the id and set status = paid / error / whatever happened in the database.
- 发送序列化的数据,并在返回时反序列化。
- 将数据写入form.php中的数据库(状态为notpaid)并发送id。在 ipn.php 中捕获 id 并设置 status =paid / error / 无论在数据库中发生了什么。
回答by sw.
You can pass other information via the notify_url field, for example doing http://www.yoursite.com/notify?myvariable=value
您可以通过 notify_url 字段传递其他信息,例如执行http://www.yoursite.com/notify?myvariable=value
回答by Martin
If it is just to pas a variable that is not pertinent to paypal but more pertinent to you when it comes back, you can use the value ['custom'] to submit to paypal, paypal will simply pass it back to yuo once things are done on their side.
如果只是传递一个与 paypal 无关但在返回时与您更相关的变量,您可以使用值 ['custom'] 提交给 paypal,一旦事情发生,paypal 将简单地将其传回给 yuo在他们这边完成。
回答by Ben Fransen
A vague memory tells me there are two options for sending data to PayPal. The command x_click and i thought there was something like an upload parameter. When the upload parameter is set to 1 you can send multiple lines to paypal.
模糊的记忆告诉我有两个选项可以将数据发送到 PayPal。命令 x_click ,我认为有类似上传参数的东西。当上传参数设置为 1 时,您可以向贝宝发送多行。
回答by cdalxndr
Haven't tested, but according to documentation, you could use multiple hidden inputs with name item_number_X(X=number) inside paypal form to store variables:
尚未测试,但根据文档,您可以item_number_X在 paypal 表单中使用多个带有名称(X=number) 的隐藏输入来存储变量:
<INPUT TYPE="hidden" name="item_number_1" value="value1">
<INPUT TYPE="hidden" name="item_number_2" value="value2">
From paypal docs:
从贝宝文档:
Recordkeeping with passthrough variables
使用传递变量保持记录
Some variables are exclusively for your own use, such as order management. PayPal returns the values that you send through Instant Payment Notification exactly as you sent them. For this reason, they are called passthrough variables. Their values are not recorded or used by PayPal.
某些变量专供您自己使用,例如订单管理。PayPal 会完全按照您发送的方式返回您通过即时付款通知发送的值。因此,它们被称为直通变量。PayPal 不会记录或使用它们的值。
The following are passthrough variables:
以下是直通变量:
- custom
- item_number or item_number_x
- invoice
- 风俗
- item_number 或 item_number_x
- 发票
回答by Fox
Yes, you can! You can use 'custom' variable and add in your form
是的你可以!您可以使用“自定义”变量并添加到您的表单中
<INPUT TYPE="hidden" name="custom" value="user_id=1&uname=jj">
And in your IPN.php:
在你的 IPN.php 中:
$custom = $_POST['custom'];
And extract the variables from string
并从字符串中提取变量

