Charge Token.

@param $body

@return \Exception|mixed
323843
public function chargeToken($body)
    {
        $request = $this->paystackHttpClient->post(
            Resource::CHARGE_TOKEN,
            [
                'body'  => is_array($body) ? $this->toJson($body) : $body,
            ]
        );

        return $this->processResourceRequestResponse($request);
    }
624415
public static function NotAcceptable($body = NULL, \Exception $previous = NULL) {
    return self::code(406, $body, $previous);
  }
254331
protected function parseLockRequest($body)
    {
        $result = $this->server->xml->expect(
            '{DAV:}lockinfo',
            $body
        );

        $lockInfo = new LockInfo();

        $lockInfo->owner = $result->owner;
        $lockInfo->token = DAV\UUIDUtil::getUUID();
        $lockInfo->scope = $result->scope;

        return $lockInfo;
    }
1246633
public function exchange(NostoOAuthToken $token)
    {
        $request = new HttpRequest();
        $request->setContentType(self::CONTENT_TYPE_URL_FORM_ENCODED);
        $request->setPath(HttpRequest::PATH_OAUTH_SYNC);
        $request->setQueryParams(array('access_token' => $token->getAccessToken()));
        $response = $request->get();
        if ($response->getCode() !== 200) {
            throw ExceptionBuilder::fromHttpRequestAndResponse($request, $response);
        }

        $tokens = Token::parseTokens($response->getJsonResult(true), 'api_');
        $account = new Account($token->getMerchantName());
        $account->setTokens($tokens);
        return $account;
    }
578606
private function parse($body)
    {
        $body = $this->substringBetween($body, '<CreditTransactionResult>', '</CreditTransactionResult>');

        $body = html_entity_decode($body);
        $xml = new \SimpleXMLElement($body);

        $resonse = array();

        $cmd= $xml->xpath('//CmdResponse');
        foreach ($cmd[0] as $name => $value) {
            $response[$name] = (string) $value;
        }

        if ($tran = $xml->xpath('//TranResponse')) {
            foreach ($tran[0] as $name => $value) {
                if ($name == 'Amount') {
                    foreach ($value as $key => $amount) {
                        $response[$key] = (string) $amount;
                    }
                } else {
                    $response[$name] = (string) $value;
                }
            }
        }

        return new Options($response);

    }
1278289
public function getToken($request = null)
    {
        $request = $request ?: $this->makeRequest();

        list($token) = sscanf($request->header($this->getAuthHeaderKey()), 'Bearer %s');
        if( ! $token) {
            $name = $this->getInputName();
            $token = $request->input($name);
        }

        return $token;
    }
1046429
public function chargeWithCardToken(RequestModels\CardTokenChargeCreate
	                                    $requestModel)
	{

		$chargeMapper = new ChargesMapper($requestModel);

		$requestPayload = array (
			'authorization' => $this->_apiSetting->getSecretKey(),
			'mode'          => $this->_apiSetting->getMode(),
			'postedParam'   => $chargeMapper->requestPayloadConverter(),

		);

		$processCharge = \com\checkout\helpers\ApiHttpClient::postRequest($this->_apiUrl->getCardTokensApiUri(),
			$this->_apiSetting->getSecretKey(),$requestPayload);

		$responseModel = new ResponseModels\Charge($processCharge);


		return $responseModel;
	}
695371
protected function parseAccessTokenResponse($responseBody)
    {
        $body = json_decode($responseBody, true);

        if (isset($body['error'])) {
            throw new TokenResponseException($body['hint']);
        }

        $token = new StdOAuth2Token();
        $token->setAccessToken($body['access_token']);
        $token->setRefreshToken($body['refresh_token']);
        $token->setLifetime($body['expires_in']);

        // Store the id_token as an "extra param"
        $token->setExtraParams(['id_token' => $body['id_token']]);

        return $token;
    }
1137777
public function charge(ChargeRequest $request)
    {
        $result = $this->request('POST', '/charges', [
            'card'     => (string) $request->getToken(),
            'amount'   => $request->getAmount() ? $request->getAmount()->getAmount() : null,
            'currency' => $request->getAmount() ? $request->getAmount()->getCurrency() : null,
            'capture'  => $request->isCapture() ? 'true' : 'false',
            'products' => json_encode($request->getProducts()),
        ]);

        return $this->objectConverter->convert($result);
    }
1211046
public static function create($body)
    {
        if (0 !== strpos($body, static::START_TOKEN)) {
            throw new InvalidArgumentException("Unexpected response body.");
        }
        if (static::END_TOKEN !== substr($body, -strlen(static::END_TOKEN))) {
            throw new InvalidArgumentException("Unexpected response body.");
        }

        $body = substr($body, strlen(static::START_TOKEN), -strlen(static::END_TOKEN));

        $parts = explode('|', trim($body, '|'));
        if (empty($parts)) {
            throw new InvalidArgumentException("Unexpected response body.");
        }

        $response = new static();

        for ($i = 0; $i < count($parts); $i++) {
            list($key, $value) = explode(':', $parts[$i], 2);

            if ($key === Config::RESULT) {
                if (0 < strpos($value, ':')) {
                    list($code, $field) = explode(':', $value, 2);
                } else {
                    $code = $value;
                    $field = 'unknown';
                }
                $response->set(Config::RESULT, $code);
                $response->set(Config::FIELD, $field);
            } else {
                $response->set($key, $value);
            }
        }

        return $response;
    }
922752
public function setAccessToken($token)
    {
        if ($token instanceof Token\TokenInterface) {
            $this->rawToken = $token;
        } else {
            $this->rawToken = is_array($token) ?
                $this->tokenFactory($token) :
                $this->tokenFactory(['access_token' => $token]);
        }

        if ($this->rawToken === null) {
            throw new Exception\OAuth2Exception("setAccessToken() takes a string, array or TokenInterface object");
        }

        return $this;
    }
66826
public function setBody($body)
    {
        $this->body = $body;
        $this->setHeader('Content-Length', strlen($body));

        return $this;
    }
1361504
public function checkWebPayment($token, $transactionId)
    {
        $requestPayment = new Structure\RequestPaymentDetails($token, $transactionId);

        $this->response = parent::checkWebPayment($this->entity, $requestPayment);

        /**
         * Checks the state of the platform integration.
         */
        if (Exception\IntegrationState::check($this->response->requestState)) {
            throw new Exception\IntegrationState($this->response->requestState);
        }

        if ($this->response->requestState->state == 0) {
            throw new Exception\IntegrationResponse(
                $this->response->requestState->message,
                $this->response->requestState->code
            );
        }

        return $this->response;
    }
153341
function getToken()
    {
        if (! $this->token )
            $this->token = $this->exchangeToken();
        elseif (\Poirot\OAuth2Client\checkExpiry( $this->token->getDateTimeExpiration() ))
            $this->token = $this->exchangeToken();


        return $this->token;
    }
254645
public function body($body = null)
    {
        if ($body !== null) {
            $this->_body = $body;

            return $this;
        }

        return $this->_body;
    }
1318072
public function body($body)
    {
        if ($body instanceof ReadableStreamInterface) {
            return new ReadableBodyStream($body);
        }

        return \RingCentral\Psr7\stream_for($body);
    }
73283
protected function parseAccessTokenResponse($responseBody)
    {
        $request = \Request::getInstance();
        if ($request->get('error')) {
            $reason = $request->get('error_description');
            throw new TokenResponseException($reason);
        }

        $data = json_decode($responseBody, true);

        if (null === $data || !is_array($data)) {
            throw new TokenResponseException('Unable to parse response.');
        } elseif (isset($data['error'])) {
            throw new TokenResponseException('Error in retrieving token: "' . $data['error'] . '"');
        }

        $token = new StdOAuth2Token();
        $token->setAccessToken($data['access_token']);
        $token->setLifetime($data['expires_in']);

        if (isset($data['refresh_token'])) {
            $token->setRefreshToken($data['refresh_token']);
            unset($data['refresh_token']);
        }

        unset($data['access_token']);
        unset($data['expires_in']);

        $data['state'] = $request->get('state');

        $token->setExtraParams($data);

        return $token;
    }