将自定义变量传递给 paypal IPN

2021-12-29 00:00:00 php paypal

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

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.

我的流程是这样的

  1. 用户填写表单
  2. 他们点击按钮,然后转到贝宝
  3. 他们付了钱,IPN 将信息发回给我,ipn.php 添加了传递给数据库的变量.

我的自定义变量是

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

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

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']. "');";

推荐答案

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

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:

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

相关文章