getInitCore($orderNo, $money); $body['trade_type'] = 'APP'; $body['spbill_create_ip'] = $spbill_create_ip; $client = new Client('api.mch.weixin.qq.com', 443, true); $client->withHeader(['Content-Type' => 'application/json']); $client->withBody($this->sign($body)); $client->post($this->uniformed); $client->close(); if (!in_array($client->getStatusCode(), [101, 200, 201])) { return new Result(code: 505, message: $client->getBody()); } $data = Help::toArray($client->getBody()); if (isset($data['return_code']) && $data['return_code'] != 'SUCCESS') { return new Result(code: 503, message: $data['return_msg']); } if ($data['result_code'] != 'SUCCESS') { return new Result(code: 504, message: $data['err_code_des']); } return new Result(code: 0, data: $this->reception($data['prepayid'])); } /** * @param string $prepay_id * @return string */ public function reception(string $prepay_id): string { return $this->sign([ 'appId' => $this->config->getAppid(), 'partnerid' => $this->config->getMchId(), 'prepayid' => $prepay_id, 'package' => 'Sign=WXPay', 'noncestr' => Help::random(32), 'timestamp' => time() ]); } }