Cartalyst\Stripe\Api\Api::createHandler PHP Method

createHandler() protected method

Create the client handler.
protected createHandler ( ) : GuzzleHttp\HandlerStack
return GuzzleHttp\HandlerStack
    protected function createHandler()
    {
        $stack = HandlerStack::create();
        $stack->push(Middleware::mapRequest(function (RequestInterface $request) {
            $config = $this->config;
            return $request->withHeader('Stripe-Version', $config->getApiVersion())->withHeader('Idempotency-Key', $config->getIdempotencyKey())->withHeader('User-Agent', 'Cartalyst-Stripe/' . $config->getVersion())->withHeader('Authorization', 'Basic ' . base64_encode($config->getApiKey()));
        }));
        $stack->push(Middleware::retry(function ($retries, RequestInterface $request, ResponseInterface $response = null, TransferException $exception = null) {
            return $retries < 3 && ($exception instanceof ConnectException || $response && $response->getStatusCode() >= 500);
        }, function ($retries) {
            return (int) pow(2, $retries) * 1000;
        }));
        return $stack;
    }