/** * 提交被扫支付API * 收银员使用扫码设备读取微信用户刷卡授权码以后,二维码或条码信息传送至商户收银台, * 由商户收银台或者商户后台调用该接口发起支付。 * WxPayWxPayMicroPay中body、out_trade_no、total_fee、auth_code参数必填 * appid、mchid、spbill_create_ip、nonce_str不需要填入 * @param WxPayWxPayMicroPay $inputObj * @param int $timeOut */ public function micropay($inputObj, $timeOut = 10) { $url = "https://api.mch.weixin.qq.com/pay/micropay"; //检测必填参数 if (!$inputObj->isBodySet()) { throw new WxPayException("提交被扫支付API接口中,缺少必填参数body!"); } else { if (!$inputObj->isOutTradeNoSet()) { throw new WxPayException("提交被扫支付API接口中,缺少必填参数out_trade_no!"); } else { if (!$inputObj->isTotalFeeSet()) { throw new WxPayException("提交被扫支付API接口中,缺少必填参数total_fee!"); } else { if (!$inputObj->isAuthCodeSet()) { throw new WxPayException("提交被扫支付API接口中,缺少必填参数auth_code!"); } } } } $inputObj->setSpbillCreateIp($_SERVER['REMOTE_ADDR']); //终端ip $inputObj->setAppid($this->apiConfig->appid); //公众账号ID $inputObj->setMchId($this->apiConfig->mchid); //商户号 $inputObj->setMchKey($this->apiConfig->mchkey); //商户密钥 $inputObj->setNonceStr($this->getNonceStr()); //随机字符串 $inputObj->setSign(); //签名 $xml = $inputObj->toXml(); $startTimeStamp = $this->getMillisecond(); //请求开始时间 $response = $this->postXmlCurl($xml, $url, false, $timeOut); $result = WxPayResults::init($response, $this->apiConfig->mchkey); $this->reportCostTime($url, $startTimeStamp, $result); //上报请求花费时间 return $result; }