Exemplo n.º 1
0
 /**
  *
  * 撤销订单API接口,Reverse中参数out_trade_no和transaction_id必须填写一个
  * appid、mchid、spbill_create_ip、nonce_str不需要填入
  * @param Reverse $input
  * @param int $time_out
  * @throws WxPayException
  */
 public function reverse($input, $time_out = 6)
 {
     $url = 'https://api.mch.weixin.qq.com/secapi/pay/reverse';
     //检测必填参数
     if (!$input->isOutTradeNoSet() && !$input->isTransactionIdSet()) {
         throw new WxPayException('撤销订单API接口中,参数out_trade_no和transaction_id必须填写一个!');
     }
     $input->setAppid(Wxpay::getConfig('appid'));
     //公众账号ID
     $input->setMchId(Wxpay::getConfig('mchid'));
     //商户号
     $input->setSubMchId(Wxpay::getConfig('sub_mch_id'));
     //子商户号
     $input->setNonceStr($this->getNonceStr());
     //随机字符串
     $input->setSign();
     //签名
     $xml = $input->toXml();
     $start_time_stamp = $this->getMillisecond();
     //请求开始时间
     $response = $this->postXmlCurl($xml, $url, true, $time_out);
     $result = Results::Init($response);
     $this->reportCostTime($url, $start_time_stamp, $result);
     //上报请求花费时间
     return $result;
 }