百度空间 | 百度首页 
               
 
查看文章
 
使用socket,在线支付
2008-08-29 11:20
$fp = fsockopen ($host, 80, $errno, $errstr, 30);
if (!$fp)
{
echo "$errstr ($errno)<br>\n";
}
else
{
$request="POST http://www.westpay.com.cn/pay/ISPN.asp HTTP/1.0
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */ *
Referer: http://www.westpay.com.cn
Accept-Language: gb2312
Content-Type: application/x-www-form-urlencoded
User-Agent: Mozilla/4.0 (compatible; MSIE 5.0; Windows 98; DigExt)
Host: www.westpay.com.cn
Content-Length: $len
Proxy-Connection: Keep-Alive
Pragma: no-cache

$req";

fputs ($fp, "$request");
while (!feof($fp))
{
$res = fgets ($fp, 1024);
if (strcmp ($res, "VERIFIED") == 0)
{
$msg = "支付通知验证成功";
$state= 1;
}
else if (strcmp ($res, "INVALID") == 0)
{
$msg = "支付通知验证失败";
$state = 2;
}
else
{
$msg = "支付通知验证过程中出现错误";
$state = 3;
}
}
fclose ($fp);
}echo($msg);

类别:php网摘 | 添加到搜藏 | 浏览() | 评论 (0)
 
最近读者:
 
网友评论:
发表评论:
姓 名:
网址或邮箱: (选填)
内 容:
验证码: 请点击后输入四位验证码,字母不区分大小写
      

     

©2009 Baidu