微信企業支付到零錢

2021-08-21 14:13:40 字數 2204 閱讀 7087

public function weixinpay()

// 建立訂單

$code = $this->_get_pay_code();

$openid = $userinfo['openid'];

$user_id = $userinfo['id'];

$nickname = $userinfo['nickname'];

$this->answer_m->create_order($user_id,$openid,$code,$amount);

// 執行支付

$parameters = array(

'mchid' => self::mchid,//商戶號

'nonce_str' => $this->create_noncestr(32), //生成32位的隨機字串

'partner_trade_no' => $payment_id, //商戶訂單號,不能重複使用

'openid' => $openid,//使用者的open_id

'check_name' => 'no_check',//是否檢查姓名

// 're_user_name' => $transfer['real_name'], //真實姓名

'amount' => bcmul($amount,100,0), //企業付款金額,單位為分 最低1元

'desc' => '答題獎金',//備註

'spbill_create_ip' => strval($_server['server_addr']),//伺服器ip

);$parameters['sign'] = $this->getsign($parameters, self::pay_key);//getsign商戶支付金鑰

$xml = $this->arraytoxml($parameters);

$response = $this->postxmlcurl($xml, $url,true);

$result = $this->xmltoarray($response);

if($result['return_code']=='success')else

}else

}public function create_noncestr($length=16)

return $str;

}// 生成簽名

public function getsign($obj,$key)

ksort($parameters);

$string = $this->formtbizqueryparmap($parameters,false);

$string = $string."&key=".$key;

// var_dump($string);

$string = md5($string);

$result =strtoupper($string);

// var_dump($result);die;

return $result;

}public function arraytoxml($arr)else

}$xml .="";

return $xml;

}

public function postxmlcurl($xml,$url,$usercert= false,$second= 30)

// post 提交

curl_setopt($ch, curlopt_post, true);

curl_setopt($ch, curlopt_postfields, $xml);

// 執行curl

$data = curl_exec($ch);

// 返回結果

if($data)else

}// 將xml 轉array

public function xmltoarray($xml)

// 格式化引數,簽名使用

public function formtbizqueryparmap($paramap,$urlencode)

$buff .= $k ."=".$v."&";

}$reqpar = '';

if(strlen($buff) >0)

return $reqpar;

} // 建立訂單號

public function _get_pay_code()

微信企業支付到零錢

class wxcompanypay 商戶號 mchid 隨機字串 nonce str 簽名 sign 商戶訂單號 partner trade no 使用者openid openid 校驗使用者姓名選項 check name 收款使用者姓名 可選 re user name 金額 amount 企業付...

微信支付之企業付款到零錢

public function pay to change orderid,openid,amount 簽名步驟一 按字典序排序引數 ksort parameters string this formatbizqueryparamap parameters,false 簽名步驟二 在string後加...

微信支付之企業付款到零錢

1.專案搭建框架 php3.1 2.專案 class paymoneyaction extends action else return json encode isrr protected function getnoncestr length 32 return str protected fu...