/** * 将xml转为array * @param string $xml * @param string $mchKey 商户Api密钥 * @throws WxPayException */ public static function init($xml, $mchKey = '') { $obj = new self(); if ($mchKey) { $obj->setMchKey($mchKey); } $obj->fromXml($xml); //fix bug 2015-06-29 if ($obj->values['return_code'] != 'SUCCESS') { return $obj->getValues(); } $obj->checkSign(); return $obj->getValues(); }
/** * 将xml转为array * @param $xml 需要解析的xml内容 * @param bool|true $checkSign 是否需要验证签名 * @param $key 验证签名的key * @return array * @throws \Exception */ public static function init($xml, $checkSign = true, $key = "") { $obj = new self(); $obj->fromXml($xml); if ($obj->values['return_code'] != 'SUCCESS') { return $obj->getValues(); } if ($checkSign) { $obj->checkSign($key); } return $obj->getValues(); }