appId = $appId; $this->appSecret = $appSecret; } public function pay($params) { ksort($params); $str = http_build_query($params) . $this->appSecret; $params['sign'] = md5($str); $curl = new Curl(); $curl->post('http://api.paytaro.com/v1/gateway/fetch', http_build_query($params)); if ($curl->error) { abort(500, '接口请求失败'); } $result = $curl->response; $curl->close(); if (!isset($result->data->trade_no)) { abort(500, '接口请求失败'); } return $result->data->pay_url; } public function verify($params) { $sign = $params['sign']; unset($params['sign']); ksort($params); reset($params); $str = http_build_query($params) . $this->appSecret; if ($sign !== md5($str)) { return false; } return true; } }