这是客户流:
访问网站 -> 用他们的信息填写表格 -> 单击“立即购买”并使用 PayPal 结账 -> 返回网站 -> 使用从结账处传递的信息来运行 PHP
服务器上的脚本通过 ajax
(假设结帐成功)。好吧,这就是计划。我遇到的问题是弄清楚如何实际传递变量(总共有 8 个...数组???)。我目前在网站上有一个快速结帐按钮,它将用户重定向到 PayPal 以完成交易。我一直在 YouTube 上或 S.O. 上寻找一个好的教程,但没有成功。我有什么想法可以完成这个吗?
谢谢
最佳答案
在您的 PayPal 表单中,只需为您的自定义字段使用类似以下的内容..
例子:
<input type="hidden" name="custom" value="<?php echo $custom1.','.$custom2.','.$custom3; ?>">
或;
<input type="hidden" name="custom" value="custom1,custom2,custom3">
简而言之,PayPal 接受自定义名称,您可以使用逗号分隔变量。
PayPal 将在 IPN 中将自定义字段传回给您。
编辑:
这是您可以使用自定义功能执行的示例:
$custom = $_POST['custom'];
$pattern = ",";
$pieces = explode($pattern,$custom, 3);
// 3 is how many custom fields there are
$custom1 = $pieces[0];
$custom2 = $pieces[1];
if (isset($pieces[2])) {
//an example checking to see if there is a third custom variable
$custom3 = $pieces[2];
}
关于php - 如何通过 PayPal IPN 发送多个变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44275586/