发起支付

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

        $formContent = $this->executeFormRequest($createOrderRequest);

        echo $formContent;
    }
305396
protected function prepareParams(array $params)
	{
		$prepared = [];
		
		foreach($params as $k => $v)
		{
			if(is_array($v))
			{
				foreach(array_values($v) as $i => $val)
				{
					$prepared[sprintf('%s%u', $k, $i)] = $val;
				}
			}
			else
			{
				$prepared[(string)$k] = $v;
			}
		}
		
		return $prepared;
	}
268903
protected function _request(array $params)
    {
        $client = new Client();

        if ( $params['type'] == 'get' ) {
            $url = $this->url . '/api/' . $this->apiKey . '/' . $params['uri'] . '?' . http_build_query($params['data']);
            $options = [];
            if ( $this->httpAuthUsername && $this->httpAuthPassword ) {
                $options['auth'] = [
                    $this->httpAuthUsername,
                    $this->httpAuthPassword
                ];
            }

            return $client->get($url, $options);
        }
    }
867948
public function create(array $params = [])
    {
        $defaults = [
            'issue_id' => null,
            'project_id' => null,
            'spent_on' => null,
            'hours' => null,
            'activity_id' => null,
            'comments' => null,
        ];
        $params = $this->sanitizeParams($defaults, $params);

        if (
            (!isset($params['issue_id']) && !isset($params['project_id']))
         || !isset($params['hours'])
        ) {
            throw new \Exception('Missing mandatory parameters');
        }

        $xml = new \SimpleXMLElement('<?xml version="1.0"?><time_entry></time_entry>');
        foreach ($params as $k => $v) {
            if ('custom_fields' === $k && is_array($v)) {
                $this->attachCustomFieldXML($xml, $v);
            } else {
                $xml->addChild($k, $v);
            }
        }

        return $this->post('/time_entries.xml', $xml->asXML());
    }
318595
public function setParams($params)
		{
			$this->params = [];
			foreach ($params as $param)
			{
				// variables
				$name = $param['name'];
				$type = $param['type'];
				$value = $param['value'];

				// properties
				$this->params[$name] = $this->convert($type, $value);
			}

			// return
			return $this;
		}
1289536
public function UnifiedOrder($params)
    {
        $this->input = new UnifiedOrder();
        $params = array_merge($this->configs, $params);
        $this->setParams($params);
        return Api::unifiedOrder($this->input);
    }
838347
public function get($params = null)
    {
        $curlHandle = $this->prepareGet($params);
        return $this->curlGetResponse($curlHandle);
    }
315986
public function setParams($params = null)
    {
        if (isset($params)) {
            $this->params = (array) $params;
        } else {
            $this->params = $this->cli->parseParams($this->server->cliArgs());
        }

        return $this;
    }
153025
public static function get($params = array())
	{
		$object = new static;
		$data   = $object->request('GET', $object->getUrl(), $params);
		$data   = $object->stripResponseData($data);

		// Initialise a collection
		$collection = self::newCollection();

		if (isset($data[0]) && is_array($data[0])) {
			// This should be a collection
			$collection->setItems($data);
		}

		return $collection;
	}
775376
private function createAssignsFromParams(array $params): array
    {
        $assigns = [];

        /** @var Param $param */
        foreach ($params as $param) {
            $propertyFetch = new PropertyFetch(new Variable('this'), $param->var->name);
            $assigns[] = new Assign($propertyFetch, new Variable($param->var->name));
        }

        return $assigns;
    }
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;
    }
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;
    }
340016
protected function getHeader(array $params)
	{
		// Prepare the function's header
		$header = "/**\n";
		foreach ($params as $paramName => $paramType)
		{
			$header .= '* @param {' . $paramType . '} ' . $paramName . "\n";
		}
		$header .= "*/\n";

		return $header;
	}
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);
        }
    }
599666
public function getCallable($params = [])
    {
        $className = $this->className;
        $methodName = $this->methodName;
        foreach($params as $name => $value)
        {
            $className = str_replace('{$' . $name . '}', $value, $className);
            $methodName = str_replace('{$' . $name . '}', $value, $methodName);
        }
        return [RequestContext::getServer()->getBean($className), $methodName];
    }
256015
public function createPrintTradeTransaction(array $params)
    {
        // 參數初始化
        $this->sdk->Send = array_merge($this->sdk->Send, [
            'AllPayLogisticsID' => '',
            'PlatformID' => '',
        ]);

        $this->sdk->Send = array_replace(
            $this->sdk->Send,
            array_intersect_key($params, $this->sdk->Send)
        );

        return $this->sdk->formToArray(
            $this->sdk->PrintTradeDoc()
        );
    }
928055
public function refund(Array $params)
    {
        $refundRequest = $this->getRequestParam('RefundRequestParam', $params, $this->config, $this->sign);

        //发起请求
        $result = $this->executeRequestWithPem($refundRequest, $this->config['cert_pem_path'], $this->config['key_pem_path']);

        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->success('退款成功');
    }