<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="notify_url" value="notify_url.php" />
<input type="hidden" name="return" value="return.php" />
<input type="hidden" name="cancel_return" value="cancel_return.php" />
<input type="hidden" name="cmd" value="_xclick">
<input name="business" value="business_acc_from_sandbox@domain.com" type="hidden">
<input type="hidden" name="item_name" value="item or shopping cart name">
<input type="hidden" name="item_number" value="123456">
<input type="hidden" name="currency_code" value="USD">
<input name="lc" value="US" type="hidden">
<input name="no_shipping" value="1" type="hidden">
<input type="hidden" name="amount" value="3.00">
<input type="submit" value="pay"/>
</form>
<input type="hidden" name="notify_url" value="notify_url.php" />
<input type="hidden" name="return" value="return.php" />
<input type="hidden" name="cancel_return" value="cancel_return.php" />
<input type="hidden" name="cmd" value="_xclick">
<input name="business" value="business_acc_from_sandbox@domain.com" type="hidden">
<input type="hidden" name="item_name" value="item or shopping cart name">
<input type="hidden" name="item_number" value="123456">
<input type="hidden" name="currency_code" value="USD">
<input name="lc" value="US" type="hidden">
<input name="no_shipping" value="1" type="hidden">
<input type="hidden" name="amount" value="3.00">
<input type="submit" value="pay"/>
</form>
notify url
$req='cmd=_notify-validate';
foreach($_POST as $key => $value)
{
$value=urlencode(stripslashes($value));
$req.="&$key=$value";
}
$header = "POST /cgi-bin/webscr HTTP/1.0\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Content-Length: " . strlen($req) . "\r\n\r\n";
$fp = fsockopen('ssl://www.sandbox.paypal.com',443,$errno,$errstr,15);
if(!$fp)
{
$mylog = $errno.$errstr."\r\n";
$dd=fopen('test/test.txt','a+');
fwrite($dd,$mylog,4096);
fclose($dd);
}else{
fputs($fp,$header.$req);
while (!feof($fp))
{
$res=fgets($fp,1024);
if (strcmp ($res, "VERIFIED") == 0)
{
$mylog = "VERIFIED\r\n";
$dd = fopen('test/test.txt','a+');
fwrite($dd,$mylog,4096);
fclose($dd);
}else if (strcmp ($res, "INVALID") == 0){
$mylog = "INVALID\r\n";
$dd = fopen('test/test.txt','a+');
fwrite($dd,$mylog,4096);
fclose($dd);
}
}
}
fclose ($fp);
參考:foreach($_POST as $key => $value)
{
$value=urlencode(stripslashes($value));
$req.="&$key=$value";
}
$header = "POST /cgi-bin/webscr HTTP/1.0\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Content-Length: " . strlen($req) . "\r\n\r\n";
$fp = fsockopen('ssl://www.sandbox.paypal.com',443,$errno,$errstr,15);
if(!$fp)
{
$mylog = $errno.$errstr."\r\n";
$dd=fopen('test/test.txt','a+');
fwrite($dd,$mylog,4096);
fclose($dd);
}else{
fputs($fp,$header.$req);
while (!feof($fp))
{
$res=fgets($fp,1024);
if (strcmp ($res, "VERIFIED") == 0)
{
$mylog = "VERIFIED\r\n";
$dd = fopen('test/test.txt','a+');
fwrite($dd,$mylog,4096);
fclose($dd);
}else if (strcmp ($res, "INVALID") == 0){
$mylog = "INVALID\r\n";
$dd = fopen('test/test.txt','a+');
fwrite($dd,$mylog,4096);
fclose($dd);
}
}
}
fclose ($fp);
https://www.paypal.com/cgi-bin/webscr?cmd=p/pdn/howto_checkout-outside
http://www.phpkerala.com/viewtopic.php?id=23
http://leepeng.blogspot.com/2006/04/standard-paypal-php-integration.html
http://www.k0513.com/qidong/show.asp?id=527
沒有留言:
張貼留言