微信:
我用的即時到賬模式二:掃碼支付
流程:網上很多
回調問題:
public functionwxpayNotifyUrl()
{
// 獲取微信支付的結果
$xml=$GLOBALS['HTTP_RAW_POST_DATA'];
$this->load->config('wxpay_config');
$wxconfig['appid']=$this->config->item('appid');
$wxconfig['mch_id']=$this->config->item('mch_id');
$wxconfig['apikey']=$this->config->item('apikey');
$wxconfig['appsecret']=$this->config->item('appsecret');
$wxconfig['sslcertPath']=$this->config->item('sslcertPath');
$wxconfig['sslkeyPath']=$this->config->item('sslkeyPath');
$this->logtool->log(array('libxml'=>"libxml"));
// 解析xml 調用的庫
libxml_disable_entity_loader(true);
$this->logtool->log(array('libxml'=>"scuess"));
$array= json_decode(json_encode(simplexml_load_string($xml,'SimpleXMLElement',LIBXML_NOCDATA)),true)
if($array!=null){
// 調用微信掃碼支付接口配置信息
$this->load->config('wxpay_config');
$wxconfig['appid'] =$this->config->item('appid');
$wxconfig['mch_id'] =$this->config->item('mch_id');
$wxconfig['apikey'] =$this->config->item('apikey');
$wxconfig['appsecret'] =$this->config->item('appsecret');
$wxconfig['sslcertPath'] =$this->config->item('sslcertPath');
$wxconfig['sslkeyPath'] =$this->config->item('sslkeyPath');
//由于此類庫構造函數需要傳參胸完,我們初始化類庫就傳參數給他吧
$this->load->library('CI_Wechatpay',$wxconfig);
$out_trade_no=$array['out_trade_no'];
$trade_no=$array['transaction_id'];
// 查詢自己平臺的訂單數據
$result=$this->User_model->GetUserOrderInfo($out_trade_no);
$orderItem=$result->orderinfo;
// 訂單完成
if($orderItem->o_state==3) {
//告知微信我成功了
$this->ci_wechatpay->response_back();
}else{
// 訂單未完成书释,更新訂單
$result=$this->User_model->UpdateOrderInfo($out_trade_no,"3",$trade_no,"2");
if($result->code==200) {
//告知微信我成功了
$this->ci_wechatpay->response_back();
}else{
//告知微信我失敗了繼續(xù)發(fā)
$this->ci_wechatpay->response_back("FAIL");
}
}
}else{
//告知微信我失敗了繼續(xù)發(fā)
$this->wechatpay->response_back("FAIL");
}
}
支付寶支付的吭
注意:我用的是UTF-8 ?MD5版本的
回調后簽名簽證不正確:這是支付寶的一個bug.
修改:
functionparaFilter($para) {
reset($para);// 添加這一句
$para_filter=array();
while(list($key,$val) = each ($para)) {
if($key=="sign"||$key=="sign_type"||$val=="")continue;
else$para_filter[$key] =$para[$key];
}
return$para_filter;
}