|
@@ -129,26 +129,16 @@ class WxpayV2{
|
|
|
"out_trade_no" =>$out_trade_no,
|
|
|
'nonce_str' => Formatter::nonce(),
|
|
|
]);
|
|
|
- return $result;
|
|
|
-
|
|
|
-
|
|
|
+ if(empty($result)){
|
|
|
+ if(empty($this->errorMsg)){
|
|
|
+ $this->errorMsg = "支付错误001";
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ return Transformer::toArray($result);
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- * 查询订单
|
|
|
- * @param type $out_trade_no 商户订单号
|
|
|
- */
|
|
|
- public function searchOrder($out_trade_no){
|
|
|
- $apiUrl = "v3/pay/transactions/out-trade-no/{out_trade_no}";
|
|
|
- $result = $this->clientHttp("GET", $apiUrl,[
|
|
|
- "out_trade_no"=>$out_trade_no,
|
|
|
- "query"=>["mchid"=>$this->config["MCHID"]],
|
|
|
- ]);
|
|
|
- return $result;
|
|
|
- }
|
|
|
|
|
|
* 关闭订单
|
|
|
* @param type $out_trade_no 商户订单号
|
|
@@ -162,53 +152,39 @@ class WxpayV2{
|
|
|
return $result;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- * 生成签名
|
|
|
- * @param type $info
|
|
|
- * @return string
|
|
|
- */
|
|
|
- private function makeSign($info){
|
|
|
- $params = [
|
|
|
- 'appId' => $info["appId"],
|
|
|
- 'timeStamp' => (string)Formatter::timestamp(),
|
|
|
- 'nonceStr' => Formatter::nonce(),
|
|
|
- 'package' => 'prepay_id='.$info["prepay_id"],
|
|
|
- ];
|
|
|
- $params["paySign"] = Rsa::sign(Formatter::joinedByLineFeed(...array_values($params)),$this->merchantPrivateKeyInstance);
|
|
|
- $params["signType"] = 'RSA';
|
|
|
- return $params;
|
|
|
- }
|
|
|
|
|
|
- * 解密回调参数
|
|
|
- * @param type $data
|
|
|
- * @return type
|
|
|
+ * 回调验签
|
|
|
+ * @param type $inBody
|
|
|
+ * @return bool
|
|
|
*/
|
|
|
- public function aesGcmDecrypt($data){
|
|
|
-
|
|
|
- $inBodyResource = AesGcm::decrypt($data["ciphertext"], $this->config["apiv3Key"], $data["nonce"], $data["associated_data"]);
|
|
|
-
|
|
|
- $inBodyResourceArray = (array)json_decode($inBodyResource, true);
|
|
|
- return $inBodyResourceArray;
|
|
|
+ public function notifyCheckSign($inBody){
|
|
|
+ $apiv2Key = $this->config["ApiV2Key"];
|
|
|
+ $inBodyArray = Transformer::toArray($inBody);
|
|
|
+ $signType = empty($inBodyArray["sign_type"]) ? Hash::ALGO_MD5 : $inBodyArray["sign_type"];
|
|
|
+ $sign = $inBodyArray["sign"];
|
|
|
+ $calculated = Hash::sign(
|
|
|
+ $signType,
|
|
|
+ Formatter::queryStringLike(Formatter::ksort($inBodyArray)),
|
|
|
+ $apiv2Key
|
|
|
+ );
|
|
|
+ $signatureStatus = Hash::equals($calculated, $sign);
|
|
|
+ if ($signatureStatus) {
|
|
|
+
|
|
|
+ $inBodyReqInfoArray = null;
|
|
|
+ if(!empty($inBodyArray['req_info'])){
|
|
|
+ $reqInfo = $inBodyArray['req_info'];
|
|
|
+ $inBodyReqInfoXml = AesEcb::decrypt($reqInfo, Hash::md5($apiv2Key));
|
|
|
+ $inBodyReqInfoArray = Transformer::toArray($inBodyReqInfoXml);
|
|
|
+ }
|
|
|
+ return [
|
|
|
+ "data"=>$inBodyArray,
|
|
|
+ "info"=>$inBodyReqInfoArray
|
|
|
+ ];
|
|
|
+ }
|
|
|
+ return $signatureStatus;
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
|
|
|
* http提交[同步请求]
|
|
|
* @param type $type
|
|
@@ -259,37 +235,6 @@ class WxpayV2{
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- * 回调验签
|
|
|
- * @param type $inBody
|
|
|
- * @return bool
|
|
|
- */
|
|
|
- public function notifyCheckSign($inBody){
|
|
|
- $apiv2Key = $this->config["ApiV2Key"];
|
|
|
- $inBodyArray = Transformer::toArray($inBody);
|
|
|
- $signType = empty($inBodyArray["sign_type"]) ? Hash::ALGO_MD5 : $inBodyArray["sign_type"];
|
|
|
- $sign = $inBodyArray["sign"];
|
|
|
- $calculated = Hash::sign(
|
|
|
- $signType,
|
|
|
- Formatter::queryStringLike(Formatter::ksort($inBodyArray)),
|
|
|
- $apiv2Key
|
|
|
- );
|
|
|
- $signatureStatus = Hash::equals($calculated, $sign);
|
|
|
- if ($signatureStatus) {
|
|
|
-
|
|
|
- $inBodyReqInfoArray = null;
|
|
|
- if(!empty($inBodyArray['req_info'])){
|
|
|
- $reqInfo = $inBodyArray['req_info'];
|
|
|
- $inBodyReqInfoXml = AesEcb::decrypt($reqInfo, Hash::md5($apiv2Key));
|
|
|
- $inBodyReqInfoArray = Transformer::toArray($inBodyReqInfoXml);
|
|
|
- }
|
|
|
- return [
|
|
|
- "data"=>$inBodyArray,
|
|
|
- "info"=>$inBodyReqInfoArray
|
|
|
- ];
|
|
|
- }
|
|
|
- return $signatureStatus;
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
|