我创建了一个基于Pay Pal的网上商店,我需要一些像电子邮件这样的用户数据。我用了一个教程 http://www.geekality.net/2010/10/19/php-tutorial-paypal-payment-data-transfers-pdt/
当我试图返回$ response时,我得到一个FAIL而不是用户数据,http响应返回完成。
可以帮助我获取电子邮件或其他数据。谢谢
更新:
在我获得新代码之后:
http://letsbeyounger.com/nakup.php?tx=1LK05094L8779771A&st=Completed&amt=10%2e00&cc=USD&cm=&item_number=horsey
:
200 : FAIL
:
新代码:
<?php
if(isset($_GET['tx']))
{
$tx=$_GET['txt'];
echo $tx;
echo ":";
}
$request = curl_init();
curl_setopt_array($request,array
(
CURLOPT_URL => 'https://www.sandbox.paypal.com/cqi-bin/webscr',
CURLOPT_POST => TRUE,
CURLOPT_POSTFIELDS => http_build_query(array
(
'cmd' => '_notify-synch',
'txt' => $tx,
'at' =>'HjLLVwhVK2cV_1S0gt-NlZCsN_xLA5NlV3rgQheeJeDmiuGcrN_mO0TgEwW',
)),
CURLOPT_RETURNTRANSFER => TRUE,
CURLOPT_HEADER => FALSE,
CURLOPT_SSL_VERIFYPEER => FALSE,
// CURLOPT_CAINFO => 'cacert.pem',
));
$response = curl_exec($request);
$status = curl_getinfo($request,CURLINFO_HTTP_CODE);
echo '<pre>';
echo $status;
echo " : ";
echo $response;
echo " : ";
curl_close($request);
?>
从按钮中删除了重定向,而不是仅使用apis重定向页面。我应该删除/添加按钮代码的任何其他东西吗?
<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post" target="_top">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="WPJR8GHYG4LA6">
<table>
<tr><td><input type="hidden" name="on0" value="Book">Book</td></tr><tr><td><select name="os0">
<option value="Shiny Horsey">Shiny Horsey $10.00 USD</option>
</select> </td></tr>
</table>
<!-- <input type="hidden" name="notify_url" value="http://www.letsbeyounger.com/nakup.php" />-->
<input type="hidden" name="currency_code" value="USD">
<input type="image" src="https://www.sandbox.paypal.com/en_US/i/btn/btn_buynowCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
<img alt="" border="0" src="https://www.sandbox.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>