通过PayPal重定向时无法传递开机自检数据



我已经设置了一个网站,客户输入其信息(名称,地址等),并希望他们能够通过PayPal使用信用卡付款。效果很好。我已经设置了PayPal即时付款通知,并通过PayPal设置了该通知,以便将客户重定向到我的页面。除了没有传递并保存到我的SQL数据库外,这一切都可以正常工作。我知道将数据插入数据库的代码正常工作。问题在于,由于PayPal页面介于两者之间,因此数据没有传递到该页面。

这是我有php

if (isset($_POST['child_name'])
    && isset($_POST['age'])
    && isset($_POST['hometown'])
    && isset($_POST['boy_girl'])
    && isset($_POST['email'])
    && isset($_POST['first_name'])
    && isset($_POST['last_name'])
    && isset($_POST['address1'])
    && isset($_POST['address2'])
    && isset($_POST['city'])
    && isset($_POST['state'])
    && isset($_POST['zip'])
    && isset($_POST['country']))  {
        $child_name = $_POST['child_name'];
        $age = $_POST['age'];
        $hometown = $_POST['hometown'];
        $boy_girl = $_POST['boy_girl'];
        $email = $_POST['email'];
        $first_name = $_POST['first_name'];
        $last_name = $_POST['last_name'];
        $address1 = $_POST['address1'];
        $address2 = $_POST['address2'];
        $city = $_POST['city'];
        $state = $_POST['state'];
        $zip = $_POST['zip'];
        $country = $_POST['country'];
}

这是HTML

<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="NT2YC6LP7SWBE">
<input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_paynowCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
<input type="hidden" name="child_name" id="child_name" value ="<? echo $child_name; ?>" maxlength="20"/>
<input type="hidden" name="age" id="age" value ="<? echo $age; ?>" maxlength="4"/>
<input type="hidden" name="hometown" id="hometown" value ="<? echo $hometown; ?>" maxlength="32"/>
<input type="hidden" name="boy_girl" id="boy_girl" value ="<? echo $boy_girl; ?>" maxlength="4"/>
<input type="hidden" name="first_name" id="first_name" value ="<? echo $first_name; ?>" maxlength="32"/>
<input type="hidden" name="last_name" id="last_name" value ="<? echo $last_name; ?>" maxlength="32"/>
<input type="hidden" name="email" id="email" value ="<? echo $email; ?>" maxlength="64"/>
<input type="hidden" name="address1" id="address1" value ="<? echo $address1; ?>" maxlength="64"/>
<input type="hidden" name="address2" id="address2" value ="<? echo $address2; ?>" maxlength="32"/>
<input type="hidden" name="city" id="city" value ="<? echo $city; ?>" maxlength="32"/>
<input type="hidden" name="state" id="state" value ="<? echo $state; ?>" maxlength="20"/>
<input type="hidden" name="zip" id="zip" value ="<? echo $zip; ?>" maxlength="10"/>
<input type="hidden" name="country" id="country" value ="<? echo $country; ?>" maxlength="32"/>
<input type="hidden" name="payment_type" id="payment_type" value ="paypal" maxlength="6"/>
<input type="hidden" name="paid" id="paid" value ="yes" maxlength="3"/>
<input type="hidden" name="mailed" id="mailed" value ="no" maxlength="3"/>
<img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>

我刚刚采用了PayPal给我的表格并添加了隐藏的输入。这在另一个页面上完美工作,但这是因为操作属性直接导致将插入数据的页面。在这里,操作将他们发送到PayPal的网站,数据从未启动。我该如何调整?

由于流动而无法执行此操作。两个解决方案:

  • 尝试使用分隔符字符

  • 将所有信息存储在PayPal的custom字段(255个字符)中
  • 使用唯一键将自定义信息存储在DB中,并将唯一键存储在custom字段中,因此您可以稍后使用IPN响应

  • 将其检索

在获得IPN响应之前,您不应该做任何与DB相关的事情,这就是IPN的重点。您在这里描述的是PDT,它依靠客户在付款过程后返回您的页面。

按照Kalpaitch的建议,您应该将数据保存到会话中,并在访客从PayPal页面返回时将其撤回。

最新更新