统一发起支付

@param array $params 参数字段名与微信接口字段名一样，具体请查看微信接口参数文档以及对应的CreateOrderRequestParam类的init方法
@return array
330921
public function createOrder(Array $params)
    {
        $createOrderRequest = $this->getRequestParam('CreateOrderRequestParam', $params, $this->config, $this->sign);

        $result = $this->executeRequest($createOrderRequest);

        if ($result['return_code'] != "SUCCESS") {
            return $this->error($result['return_msg'], $result);
        }
        if (!$this->sign->verifySign($result, $this->config['key'])) {
            return $this->error("验证微信的签名失败", $result);
        }
        if ($result['result_code'] != 'SUCCESS') {
            $message = "err_code＝{$result['err_code']}, err_code_des＝{$result['err_code_des']}";
            return $this->error($message, $result);
        }

        return $this->responseCreateOrder($result);
    }
628556
public function deleteByParams($params = [])
    {
        extract($params);

        $query = $this->newDeleteQuery();

        if (isset($where)) {
            if (is_array($where)) {
                foreach ($where as $condition) {
                    $condition = (array)$condition;
                    $query->where($condition[0], $condition[1]);
                }
            } else {
                call_user_func_array([$query, 'where'], $where);
            }
        }

        if (isset($order)) {
            call_user_func_array([$query, 'order'], $order);
        }

        if (isset($limit)) {
            call_user_func_array([$query, 'limit'], $limit);
        }

        $this->getDB()->execute($query);

        return $this;
    }
1323069
public function all(array $params = array())
    {
        $endpoint = '/admin/locations.json';
        $response = $this->request($endpoint, 'GET', $params);
        return $this->createCollection(Location::class, $response['locations']);
    }
923256
public static function createFromArray(array $params)
    {
        return new static(
            isset($params['method']) ? $params['method'] : 'GET',
            new Uri(isset($params['uri']) ? $params['uri'] : ''),
            isset($params['headers']) ? $params['headers'] : array(),
            isset($params['body']) ? (is_resource($params['body']) ? new Stream($params['body']) : Stream::createFromContents($params['body'])) : Stream::createFromContents(''),
            isset($params['server']) ? $params['server'] : array(),
            isset($params['cookies']) ? $params['cookies'] : array()
        );
    }
1174186
public function withServerParams(array $params)
    {
        $request = $this->copy();
        $request->serverParams = $params;
        
        $request->reset();
        
        return $request;
    }
197068
public function get_parameters($param=null)
    {
        $params = array(
            'SORT'    => $this->sorting,
            'ORDER'   => $this->order,
            'MAILBOX' => $this->folders,
        );

        if ($param !== null) {
            return $params[$param];
        }

        return $params;
    }
581404
private function extractSorting(array $params)
    {
        if (false === $this->issetNotEmpty(self::PARAM_SORTING, $params)) {
            return $this;
        }
        $sort = explode(',', $params[self::PARAM_SORTING]);
        $this->sorting = [];
        foreach ($sort as $field) {
            $direction = 1;
            if (0 === strpos($field, '-')) {
                $direction = -1;
                $field = str_replace('-', '', $field);
            }
            $this->sorting[$field] = $direction;
        }
        return $this;
    }
1163808
private function getDateParams($params)
    {
        /**
         * @var \DateTime
         */
        $to = $this->dateContext;
        /**
         * @var \DateTime
         */
        $from = clone $to;
        $from->sub(new \DateInterval('PT4M'));
        $from->sub(new \DateInterval('PT59S'));

        $params['dateFrom'] = $from->format('Y-m-d H:i:s');

        $params['dateTo'] = $to->format('Y-m-d H:i:s');

        return $params;
    }
627558
public function setParams(array $params)
    {
        foreach ($this->params as $param) {
            if (!array_key_exists($param, $params)) {
                $methodName = 'unset'.ucfirst($param);

                if (method_exists($this, $methodName)) {
                    call_user_func(
                        [$this, $methodName]
                    );
                    continue;
                }
            }

            if (property_exists($this, $param)) {
                $methodName = 'set'.ucfirst($param);

                if (method_exists($this, $methodName)) {
                    call_user_func(
                        [$this, $methodName],
                        $params[$param]
                    );
                }
            }
        }

        return $this;
    }
483908
public function findOneByParams(array $params = [])
    {
        $params['limit'] = 1;
        $records = $this->findByParams($params);
        if (count($records) > 0) {
            return $records->rewind();
        }

        return null;
    }
1314795
public function getParamTokens(array $params)
    {
        foreach ($params as $k => $p) {
            if (is_array($p)) {
                $params[$k] = isset($p[2]) ? $p[2] : 0;
            }
        }

        return $params;
    }
87992
public function fetchRequestToken(array $params = [])
    {
        $this->setAccessToken(null);
        $defaultParams = [
            'oauth_consumer_key' => $this->consumerKey,
            'oauth_callback' => $this->getReturnUrl(),
            //'xoauth_displayname' => Yii::$app->name,
        ];
        if (!empty($this->scope)) {
            $defaultParams['scope'] = $this->scope;
        }

        $request = $this->createRequest()
            ->setMethod($this->requestTokenMethod)
            ->setUrl($this->requestTokenUrl)
            ->setData(array_merge($defaultParams, $params));

        $this->signRequest($request);

        $response = $this->sendRequest($request);

        $token = $this->createToken([
            'params' => $response
        ]);
        $this->setState('requestToken', $token);

        return $token;
    }
1054435
public function getAllParams(array $params)
    {
        $all = $this->defaults;

        if (isset($params['p'])) {
            foreach (explode(',', $params['p']) as $preset) {
                if (isset($this->presets[$preset])) {
                    $all = array_merge($all, $this->presets[$preset]);
                }
            }
        }

        return array_merge($all, $params);
    }
809235
protected function extractQueryParameters(array $params)
    {
        $availableParams = ['extract-archive'];
        $query = [];

        foreach ($params as $key => $value) {
            if (in_array($key, $availableParams)) {
                $query[$key] = $value;
            }
        }

        return $query;
    }
1293222
public function execute(array $params = []) : array
    {
        foreach ($params as $paramName => $paramValue) {
            $type = is_int($paramValue) ? \PDO::PARAM_INT : \PDO::PARAM_STR;
            $this->getStatement()->bindValue($paramName, $paramValue, $type);
        }
        $this->getStatement()->execute();

        return $this->getStatement()->fetchAll(\PDO::FETCH_ASSOC);
    }
440650
private function getParams(array $params)
    {
        $result = [];
        foreach ($params as $name => $item) {
            $value = $item['value'];
            if ('collection' === $item['type']) {
                $value = $this->getParams($value);
            }

            $result[$name] = new PropertyParameter($name, $value, $item['type']);
        }

        return $result;
    }
875254
protected function _request(array $params)
    {
        $client = new Client();
        $options = [
            'headers' => [
                'X-Api-Key' => $this->apiKey
            ]
        ];

        if ( $this->httpAuthUsername && $this->httpAuthPassword ) {
            $options['auth'] = [
                $this->httpAuthUsername,
                $this->httpAuthPassword
            ];
        }

        if ( $params['type'] == 'get' ) {
            $url = $this->url . '/api/' . $params['uri'] . '?' . http_build_query($params['data']);

            return $client->get($url, $options);
        }

        if ( $params['type'] == 'put' ) {
            $url = $this->url . '/api/' . $params['uri'];
            $options['json'] = $params['data'];

            return $client->put($url, $options);
        }

        if ( $params['type'] == 'post' ) {
            $url = $this->url . '/api/' . $params['uri'];
            $options['json'] = $params['data'];

            return $client->post($url, $options);
        }

        if ( $params['type'] == 'delete' ) {
            $url = $this->url . '/api/' . $params['uri'] . '?' . http_build_query($params['data']);

            return $client->delete($url, $options);
        }
    }