Pay an order.

@author yansongda <me@yansongda.cn>

@param string $endpoint
@param array  $payload

@return Collection
197429
public function pay($endpoint, array $payload): Collection
    {
        $payload['trade_type'] = $this->getTradeType();

        $payRequest = [
            'appId'     => $payload['appid'],
            'timeStamp' => strval(time()),
            'nonceStr'  => Str::random(),
            'package'   => 'prepay_id='.$this->preOrder('pay/unifiedorder', $payload)->prepay_id,
            'signType'  => 'MD5',
        ];
        $payRequest['paySign'] = Support::generateSign($payRequest, $this->config->get('key'));

        Log::debug('Paying A JSAPI Order:', [$endpoint, $payRequest]);

        return new Collection($payRequest);
    }
1105268
protected function executeQuery($endpoint)
    {
        $ch = curl_init($endpoint);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

        $responseContent = curl_exec($ch);
        $httpStatus = curl_getinfo($ch, CURLINFO_HTTP_CODE);

        if ($responseContent === false || $httpStatus != 200) {
            throw new MoneyException('Could not execute YahooFinanceRatioProvider query to endpoint '.$endpoint);
        }

        curl_close($ch);

        return $responseContent;
    }
338355
public function pay($endpoint, array $payload): Response
    {
        $payload['appid'] = Support::getInstance()->appid;
        $payload['trade_type'] = $this->getTradeType();

        if ($this->mode === Wechat::MODE_SERVICE) {
            $payload['sub_appid'] = Support::getInstance()->sub_appid;
        }

        $pay_request = [
            'appid'     => $this->mode === Wechat::MODE_SERVICE ? $payload['sub_appid'] : $payload['appid'],
            'partnerid' => $this->mode === Wechat::MODE_SERVICE ? $payload['sub_mch_id'] : $payload['mch_id'],
            'prepayid'  => $this->preOrder($payload)->get('prepay_id'),
            'timestamp' => strval(time()),
            'noncestr'  => Str::random(),
            'package'   => 'Sign=WXPay',
        ];
        $pay_request['sign'] = Support::generateSign($pay_request);

        Events::dispatch(Events::PAY_STARTED, new Events\PayStarted('Wechat', 'App', $endpoint, $pay_request));

        return JsonResponse::create($pay_request);
    }
211065
public function performContentApiRequest($endpoint, $payload)
    {
        $this->setupRequest($payload);
        $this->apiEndpoint = $endpoint;

        return $this->doDropboxApiContentRequest();
    }
1333170
public function updatePushSubscription($endpoint, $key = null, $token = null)
    {
        $subscription = PushSubscription::findByEndpoint($endpoint);

        if ($subscription && $this->pushSubscriptionBelongsToUser($subscription)) {
            $subscription->public_key = $key;
            $subscription->auth_token = $token;
            $subscription->save();

            return $subscription;
        }

        if ($subscription && ! $this->pushSubscriptionBelongsToUser($subscription)) {
            $subscription->delete();
        }

        return $this->pushSubscriptions()->save(new PushSubscription([
            'endpoint' => $endpoint,
            'public_key' => $key,
            'auth_token' => $token,
        ]));
    }
411774
protected function request($endpoint, array $parameter = [], $method = 'GET')
    {
        $option = [
            CURLOPT_HTTPHEADER => [
                'key: ' . $this->api_key,
            ],
            CURLOPT_SSL_VERIFYPEER => true,
            CURLOPT_SSL_VERIFYHOST => 2,
            CURLOPT_CAINFO => __DIR__ . DIRECTORY_SEPARATOR . 'Certificate' . DIRECTORY_SEPARATOR . 'cacert.pem',
        ];

        if ('POST' === $method) {
            $this->request = Curl::post($this->api_url[$this->account_type] . '/' . $endpoint, $parameter, $option);
        } else {
            $this->request = Curl::get($this->api_url[$this->account_type] . '/' . $endpoint, $parameter, $option);
        }

        $this->response = [
            'code' => false,
            'data' => false,
            'error' => false,
        ];

        if (isset($this->request->body) && isset($this->request->body->rajaongkir)) {
            if (200 === $this->request->body->rajaongkir->status->code) {
                $this->response['code'] = $this->request->body->rajaongkir->status->code;

                if (isset($this->request->body->rajaongkir->results)) {
                    $this->response['data'] = $this->request->body->rajaongkir->results;
                } elseif (isset($this->request->body->rajaongkir->result)) {
                    $this->response['data'] = $this->request->body->rajaongkir->result;
                } else {
                    $this->response['code'] = 400;
                    $this->response['error'] = 'Invalid response. Response tidak ditemukan, harap baca dokumentasi dengan baik.';
                }

                if (isset($this->request->body->rajaongkir->origin_details) && isset($this->request->body->rajaongkir->destination_details)) {
                    $this->response['meta'] = [
                        'origin' => $this->request->body->rajaongkir->origin_details,
                        'destination' => $this->request->body->rajaongkir->destination_details,
                        'weight' => $this->request->body->rajaongkir->query->weight,
                        'courier' => $this->request->body->rajaongkir->query->courier,
                    ];
                }
            } else {
                $this->response['code'] = $this->request->body->rajaongkir->status->code;
                $this->response['error'] = $this->request->body->rajaongkir->status->description;
            }
        } else {
            $this->response['code'] = 400;
            $this->response['error'] = 'Invalid response. Response tidak ditemukan, harap baca dokumentasi dengan baik.';
        }

        return (object) $this->response;
    }
207742
public function node($endpoint)
    {
        $request = new Request($endpoint, $this->secret, 'node', []);

        return $this->sendBatchRequest([$request]);
    }
1301182
public function request($method, $endpoint, array $params = array(), $isVault = false)
    {
        return $this->doRequest($method, $endpoint, $params, $isVault);
    }
52157
protected function sendRequest($endpoint, array $queryParams)
    {
        return $this->flexClient->sendRequest(
            $this->getApiName(),
            $this->getApiVersion(),
            $endpoint,
            $queryParams
        );
    }
1139532
public function consume(EndpointInterface $endpoint)
    {
        $handler = new AmqpQueueHandler($endpoint, (int) $this->expirationCount, $this->format, $this->serializer);

        if ($this->smartesbHelper) {
            $handler->setSmartesbHelper($this->smartesbHelper);
        }
        if ($this->logger) {
            $handler->setLogger($this->logger);
        }

        try {
            $this->manager->getQueue($this->getQueueName($endpoint))->consume($handler);
        } finally {
            $this->manager->disconnect();
        }

        return true;
    }
1354490
public function sendRequest($endpoint, array $parameters, IncomingMessage $matchingMessage)
    {
        $headers = [
            'Content-Type:application/json',
            'Authorization:Bearer '.$this->getAccessToken(),
        ];

        $apiURL = Collection::make($matchingMessage->getPayload())->get('serviceUrl',
            Collection::make($parameters)->get('serviceUrl'));

        return $this->http->post($apiURL.'/v3/'.$endpoint, [], $parameters, $headers, true);
    }
1238982
protected function get($endpoint, $params = [])
    {
        if (array_key_exists('reply_markup', $params)) {
            $params['reply_markup'] = (string)$params['reply_markup'];
        }

        return $this->sendRequest(
            'GET',
            $endpoint,
            $params
        );
    }
966280
private function get(string $endpoint): array
    {
        return \GuzzleHttp\json_decode(
            $this->client
                ->get(
                    self::API_BASE_URI.$endpoint,
                    [
                        'query' => [
                            'client_id' => $this->apiKey,
                        ],
                    ]
                )
                ->getBody()
                ->getContents(),
            true
        );
    }
634827
public function api($endpoint, array $params = [], $method = Method::GET)
    {
        $headers = $this->getApiHeaders();
        $options = $this->prepareOptions($params, $method);
        Method::isMethodSupported($method);
        if ($this->isUsingTokenParam()) {
            $params['oauth2_access_token'] = $this->accessToken->getToken();
        } else {
            $headers['Authorization'] = 'Bearer ' . $this->accessToken->getToken();
        }
        $guzzle = new GuzzleClient([
            'base_uri' => $this->getApiRoot(),
            'headers' => $headers,
        ]);
        if (!empty($params) && Method::GET === $method) {
            $endpoint .= '?' . build_query($params);
        }
        try {
            $response = $guzzle->request($method, $endpoint, $options);
        } catch (RequestException $requestException) {
            throw Exception::fromRequestException($requestException);
        }
        return self::responseToArray($response);
    }
103090
public function addEndpoint(Endpoint $endpoint): Route
	{
		$this->endpoints[get_class($endpoint)] = $endpoint;
		return $this;
	}
1155852
private function sendRequest($endpoint, $headers = array())
    {
        $method = strtolower($this->config[$endpoint]['method']);

        if (! in_array($method, array('get', 'post', 'put', 'delete'))) {
            throw new \Exception(sprintf('%s method must be GET, POST, PUT, or DELETE', $endpoint));
        }

        if (isset($this->config['auth'])) {
            $response = $this->client->request(
                $method,
                $this->config[$endpoint]['path'],
                [
                    'auth' => [$this->config['auth']['user'], $this->config['auth']['password']],
                    'headers' => $headers,
                ]
            );
        } else {
            $response = $this->client->request(
                $method,
                $this->config[$endpoint]['path'],
                [
                    'headers' => $headers,
                ]
            );
        }

        return $response;
    }
653960
public function endpoint($point)
    {
        $endpoint = $this->container->make(Endpoint::class);

        $endpoint
            ->setPoint($point)
            ->add();

        return $this->hang($endpoint);
    }