?? westpay_process.php
字號:
<?php
/*----------------------------------------------------
[ShoopD] modules/payment/westpay_process.php
Version: 1.5
Author: soolan (soolan@qq.com)
Copyright: soolan (www.shoopd.com)
Last Modified: 2006/3/11 10:00
----------------------------------------------------*/
$req = 'cmd=_notify-validate';
foreach ($_POST as $key => $value)
{
$value = urlencode(stripslashes($value));
$req .= "&$key=$value";
}
$host = "www.westpay.com.cn";
$port = 80;
$path = "/pay/ISPN.asp";
$url = "http://".$host.$path;
$referer = "http://".$host;
$len = strlen($req);
$MerchantOrderNumber = $_POST['MerchantOrderNumber']; //和商戶支付命令中的訂單號相同
$WestPayOrderNumber = $_POST['WestPayOrderNumber'];
$PaidAmount = $_POST['PaidAmount']; //WestPay傳回的實際支付金額。
$MerchantID =$_POST['MerchantID'];
$fp = fsockopen ($host, 80, $errno, $errstr, 30);
if (!$fp)
{
echo "$errstr ($errno)<br>\n";
}
else
{
$request="POST $url HTTP/1.0
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*
Referer: $referer
Accept-Language: gb2312
Content-Type: application/x-www-form-urlencoded
User-Agent: Mozilla/4.0 (compatible; MSIE 5.0; Windows 98; DigExt)
Host: $host
Content-Length: $len
Proxy-Connection: Keep-Alive
Pragma: no-cache
$req";
?>
<?php
fputs ($fp, "$request");
while (!feof($fp)){
$res = fgets ($fp, 1024);
if (strcmp ($res, "VERIFIED") == 0){
if(!is_array($cache_payment_key)){
include(cacheexists("payment_key"));
}
if ($MerchantID == $cache_payment_key['westpay']['pa']['account']['value']) {
$message = "支付通知驗證成功。";
$state = 1;
}else{
$state = 2;
}
}else if (strcmp ($res, "INVALID") == 0){
$message = "支付通知驗證失敗,請聯系商城管理員查看是否支付成功。";
$state = 3;
}else{
$message = "支付通知驗證過程中出現錯誤,請聯系商城管理員查看是否支付成功。";
$state = 4;
}
}
fclose ($fp);
}
$message_all = array();
$message_all[] = $message;
$orders_id_array = explode('_',$MerchantOrderNumber);
$orders_id = $orders_id_array['1'];
if($orders_id){
$payment_type = "westpay_".$orders_id."_".$MerchantOrderNumber;
$orders_history_data = $db->get_one("select count(*) as count from $table_orders_history where orders_id='$orders_id' and payment_type='$payment_type'");
}
if ($orders_history_data['count'] > 0){
$result = true;
}elseif ($state == 1){
if($PaidAmount > 0){
$db->query("update $table_orders_total set value=value+'$PaidAmount' where orders_id='$orders_id' and classes='paid' ");
}
include DIR_SHOOPD.'includes/update_status.php';
$_array_ = array(
'orders_id' => $orders_id,
'insert_money' => $PaidAmount,
'payment_type' => "westpay_".$orders_id,
);
update_status($_array_);
$result = true;
}
if(!is_array($cache_payment_key)){
include(cacheexists("payment_key"));
}
$payment_title = payment_title($cache_payment_key['westpay'],$lang_payment);
$pay_info = array(
'money' => display_price($PaidAmount),
'platform' => $payment_title,
'result' => $result,
);
?>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -