?????????????
/**
*?????????????
*@paramunknown_type$order
*/
privatefunctionpayWithAlipay($order){
//????????????????
require_once(VENDOR_PATH."Alipay/alipay.config.php");
require_once(VENDOR_PATH."Alipay/lib/alipay_submit.class.php");
//???????
$payment_type="1";
//???????????
//?????????????·??
$notify_url=C("HOST")."index.php/Alipay/notifyOnAlipay";
//??????????????·??
$return_url=C("HOST")."index.php/Pay/ok";
//???????????
$seller_email=$alipay_config['seller_email'];
//????
//????????????????????л??
$out_trade_no=$order['OrderNum'];
//?????????????ж??????????
//????????
$subject="????????";
//????
//??????
#???????
$price=$order['Price'];
#??????
#$price=0.1;
//????
$body=$subject;
//????????
$show_url=C('HOST');
//????????????????飬??????
$parameter=array(
"service"=>"create_direct_pay_by_user"??
"partner"=>trim($alipay_config['partner'])??
"payment_type"=>$payment_type??
"notify_url"=>$notify_url??
"return_url"=>$return_url??
"seller_email"=>$seller_email??
"out_trade_no"=>$out_trade_no??
"subject"=>$subject??
"total_fee"=>$price??
"body"=>$body??
"show_url"=>$show_url??
"_input_charset"=>trim(strtolower($alipay_config['input_charset']))
);
Log::write('???????????????'.var_export($parameter??true)??Log::DEBUG);
//????????
$alipaySubmit=newAlipaySubmit($alipay_config);
$html_text=$alipaySubmit->buildRequestForm($parameter??"get"??"????");
echo$html_text;
}
???????????
<?php
/**
*???????????
*/
classAlipayActionextendsAction{
/**
*?????????
*/
publicfunctionnotifyOnAlipay(){
Log::write("notify:".print_r($_REQUEST??true)??Log::DEBUG);
require_once(VENDOR_PATH."Alipay/alipay.config.php");
require_once(VENDOR_PATH."Alipay/lib/alipay_notify.class.php");
$orderLogDao=M('orderlog');
//????ó?????????
$alipayNotify=newAlipayNotify($alipay_config);
$verify_result=$alipayNotify->verifyNotify();
Log::write('verify_result??'.var_export($verify_result??true)??Log::DEBUG);
if($verify_result){//??????
//?????????
$out_trade_no=$_POST['out_trade_no'];
//??????????
$trade_no=$_POST['trade_no'];
//???????????????
$DAO=M('order');
$order=$DAO->where("OrderNum='".$out_trade_no."'")->find();
//???????????????????0
if(!isset($order)){
$orderId=0;
}
else{
$orderId=$order['id'];
}
//??????
$trade_status=$_POST['trade_status'];
$log="notifyfromAlipay??trade_status=".$trade_status."alipaysign=".$_POST['sign'].'price='.$_POST['total_fee'];
$orderLog['o_id']=$orderId;
if($_POST['trade_status']=='TRADE_FINISHED'||$_POST['trade_status']=='TRADE_SUCCESS'){
#????????
if((float)$order['Price']!=(float)$_POST['total_fee']){
$data['PaymentStatus']='2';
}else{
$data['PaymentStatus']='1';
}
$DAO->where('id='.$orderId)->save($data);
}
$orderLog['pay_id']=$trade_no;
$orderLog['pay_log']=$log;
$orderLog['pay_type']='alipay';
$orderLog['pay_result']='success';
$orderLogDao->add($orderLog);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
echo"success";//???????????????
}
else{
//???????????????????
$orderLog['pay_log']="notifyfromAlipay????????????????sign=".$_POST['sign'];
$orderLog['o_id']=-1;
$orderLog['pay_type']='alipay';
$orderLog['pay_result']='fail';
$orderLogDao->add($orderLog);
//??????
echo"fail";
}
}
}
?>
??????tp????м????????????????????????????????????
????????趨header("Content-Type:text/html;charset=utf-8");
????????????????????????????
????NOTIC:[2]Cannotmodifyheaderinformation-headersalreadysentby(outputstartedat
????????????????????????????
????<emid="__mceDel"></em>