将自定义变量传递给 paypal IPN

发布于 2024-08-13 22:22:05 字数 621 浏览 3 评论 0原文

我正在尝试将自定义变量传递给 paypal IPN。我可以设法传递一个变量。但我不知道如何传递多个变量。

我的流程是这样的

  1. 用户填写表格
  2. 他们单击按钮,然后转到 paypal
  3. 他们付款,IPN 向我发回信息,并且 ipn.php 添加了传递到数据库的变量。

我的自定义变量是

  1. 总行数(每当他们写入时,我都会计算行数)
  2. 消息(他们写的消息)
  3. 广告id

但是现在,我只能传递一个像这样的变量

form.php

<input name="custom" type="hidden" id="custom" value="{$line_count}">

$_SESSION['line_count'] = $_POST['lines_txt'];

ipn.php

$sql="INSERT INTO `form`(`totalline`) VALUES ('" .$_POST['custom']. "');";

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.

My Process is something like this

  1. User fill up the form
  2. They click button and it goes to paypal
  3. They paid, IPN send me back the information and that ipn.php added variables that passed to the database.

My custom variables are

  1. total lines (whenever they write, i count the lines)
  2. message (their message that they wrote)
  3. advertisement id

But for now, I can only pass one variable like this

form.php

<input name="custom" type="hidden" id="custom" value="{$line_count}">

$_SESSION['line_count'] = $_POST['lines_txt'];

ipn.php

$sql="INSERT INTO `form`(`totalline`) VALUES ('" .$_POST['custom']. "');";

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

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

发布评论

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

评论(6

暮光沉寂 2024-08-20 22:22:06

是的,你可以!
您可以使用“自定义”变量并在表单中添加

<INPUT TYPE="hidden" name="custom" value="user_id=1&uname=jj">

并在 IPN.php 中添加:

$custom = $_POST['custom'];

并从字符串中提取变量

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:

$custom = $_POST['custom'];

And extract the variables from string

回首观望 2024-08-20 22:22:05

我不确定 Paypal 是否可以发送和接收多个变量。如果由于 Paypal 的限制而无法实现,您可以使用以下方法之一:

  • 发送序列化的数据,并在返回时反序列化。
  • 将数据写入form.php中的数据库(状态为notpaid)并发送id。在 ipn.php 中捕获 id 并设置 status =paid / error / 数据库中发生的任何情况。

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:

  • 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.
三五鸿雁 2024-08-20 22:22:05

您可以通过 notify_url 字段传递其他信息,例如执行 http://www.yoursite.com /notify?myvariable=值

You can pass other information via the notify_url field, for example doing http://www.yoursite.com/notify?myvariable=value

心不设防 2024-08-20 22:22:05

如果只是传递一个与paypal无关但返回时与你更相关的变量,你可以使用值['custom']提交给paypal,一旦事情完成,paypal就会简单地将其传回给yuo在他们这边完成。

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.

明天过后 2024-08-20 22:22:05

模糊的记忆告诉我,向 PayPal 发送数据有两种选择。命令 x_click 和我认为有类似上传参数的东西。当上传参数设置为 1 时,您可以发送多行到 paypal。

更新 有关此内容的 PayPal 信息

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.

Update PayPal information about this

温折酒 2024-08-20 22:22:05

尚未测试,但根据文档,您可以在 paypal 表单中使用名称为 item_number_X (X=number) 的多个隐藏输入来存储变量

<INPUT TYPE="hidden" name="item_number_1" value="value1">
<INPUT TYPE="hidden" name="item_number_2" value="value2">

: paypal.com/docs/paypal- payments-standard/integration-guide/formbasics/#recordkeeping-with-passthrough-variables" rel="nofollow noreferrer">paypal 文档:

使用传递变量进行记录保存

有些变量是专门供您自己使用的,例如订单管理。 PayPal 返回您通过即时付款通知发送的值,与您发送的值完全相同。因此,它们被称为传递变量。 PayPal 不会记录或使用它们的值。

以下是传递变量:

  • 自定义
  • item_number 或 item_number_x
  • 发票

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:

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

The following are passthrough variables:

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