public function execute(
        AccessToken $accessToken,
        Payment $payment,
        $payerId
    ) {
        $request = $this->client->createRequest(
            'POST',
            $payment->getExecuteUrl(),
            array(
                'Accept' => 'application/json',
                'Accept-Language' => 'en_US',
                'Authorization' => $accessToken->getTokenType().' '.$accessToken->getAccessToken(),
                'Content-Type' => 'application/json'
            ),
            '{"payer_id":"'.$payerId.'"}',
            array(
                'debug' => $this->debug
            )
        );

        $response = $this->send($request, 200, "Payment error:");
        $data = json_decode($response->getBody(), true);

        if ('authorize' === $data['intent']) {

            $authorizationBuilder = new PaymentAuthorizationBuilder();
            $authorization = $authorizationBuilder->build($data);

            return $authorization;
        }

        $paymentBuilder = new PaymentBuilder();
        $payment = $paymentBuilder->build($data);

        return $payment;
    }
public function execute(
        AccessToken $accessToken,
        Payment $payment,
        $payerId
    ) {
        $request = $this->client->createRequest(
            'POST',
            $payment->getExecuteUrl(),
            array(
                'Accept' => 'application/json',
                'Accept-Language' => 'en_US',
                'Authorization' => $accessToken->getTokenType().' '.$accessToken->getAccessToken(),
                'Content-Type' => 'application/json'
            ),
            '{"payer_id":"'.$payerId.'"}',
            array(
                'debug' => $this->debug
            )
        );

        $response = $this->send($request, 200, "Payment error:");
        $data = json_decode($response->getBody(), true);

        if ('authorize' === $data['intent']) {

            $authorizationBuilder = new PaymentAuthorizationBuilder();
            $authorization = $authorizationBuilder->build($data);

            return $authorization;
        }

        $paymentBuilder = new PaymentBuilder();
        $payment = $paymentBuilder->build($data);

        return $payment;
    }
public function execute ( AccessToken $ accessToken , Payment $ payment , $ payerId ) { $ request = $ this -> client -> createRequest ( 'POST' , $ payment -> getExecuteUrl ( ) , array ( 'Accept' => 'application/json' , 'Accept-Language' => 'en_US' , 'Authorization' => $ accessToken -> getTokenType ( ) . ' ' . $ accessToken -> getAccessToken ( ) , 'Content-Type' => 'application/json' ) , '{"payer_id":"' . $ payerId . '"}' , array ( 'debug' => $ this -> debug ) ) ; $ response = $ this -> send ( $ request , 200 , "Payment error:" ) ; $ data = json_decode ( $ response -> getBody ( ) , true ) ; if ( 'authorize' === $ data [ 'intent' ] ) { $ authorizationBuilder = new PaymentAuthorizationBuilder ( ) ; $ authorization = $ authorizationBuilder -> build ( $ data ) ; return $ authorization ; } $ paymentBuilder = new PaymentBuilder ( ) ; $ payment = $ paymentBuilder -> build ( $ data ) ; return $ payment ; }
Execute a payment or an authorization that was previously approved by the client.

@param PayPalRestApiClient\Model\AccessToken $accessToken
@param PayPalRestApiClient\Model\Payment $payment payment previously created with the "PaymentService::create" method
@param string $payerId not null, parameter "payerId" that is passed in the success url when using paypal payment method

@return PayPalRestApiClient\Model\Payment
Execute a payment or an authorization that was previously approved by the client .