简体   繁体   中英

Paypal Adaptive Payments PPConnectionException in PPHttpConnection.php

I currently try to implement chained payments using the adaptive payments sdk. I receive this error

PPConnectionException in PPHttpConnection.php line 91:
error:14094410:SSL routines:SSL3_READ_BYTES:sslv3 alert handshake failure

My example code looks like this

$payRequest = new \PayPal\Types\AP\PayRequest();

    $receiver = array();
    $receiver[0] = new \PayPal\Types\AP\Receiver();
    $receiver[0]->amount = '7.50';
    $receiver[0]->email = "admin@example.de";

    $receiver[1] = new \PayPal\Types\AP\Receiver();
    $receiver[1]->amount = '2.50';
    $receiver[1]->email = "seller@example.de";
    $receiver[1]->primary = "true";
    $receiverList = new \PayPal\Types\AP\ReceiverList($receiver);
    $payRequest->receiverList = $receiverList;

    $requestEnvelope = new \PayPal\Types\Common\RequestEnvelope("de_DE");
    $payRequest->requestEnvelope = $requestEnvelope;
    $payRequest->actionType = "PAY";
    $payRequest->cancelUrl = "http://example.de:8080/payment/cancel";
    $payRequest->returnUrl = "http://example.de:8080?returned";
    $payRequest->currencyCode = "EUR";
    $payRequest->ipnNotificationUrl = "http://example.de:8080";

    $sdkConfig = array(
        'mode' => 'sandbox',
        "acct1.UserName" => "jb-us-seller_api1.paypal.com",
        "acct1.Password" => "WX4WTU3S8MY44S7F",
        "acct1.Signature" => "AFcWxV21C7fd0v3bYYYRCpSSRl31A7yDhhsPUU2XhtMoZXsWHFxu-RWy",
        "acct1.AppId" => "APP-80W284485P519543T"
    );

    $adaptivePaymentsService = new \PayPal\Service\AdaptivePaymentsService($sdkConfig);
    $payResponse = $adaptivePaymentsService->Pay($payRequest);

    if ($payResponse->responseEnvelope->ack == "Success")
    {
        redirect('Location: ' . 'https://sandbox.paypal.com/webscr?cmd=_ap-payment&paykey=' . $payResponse->payKey);
    }
    else{
        die('error');
    }

The solutions I found do not seem to work ... any ideas? Currently testing from localhost.

I'm not aware of the actual solution or cause of the error.

What fixed it for me was testing it on an actual server instead of my localhost enviroment.

I also updated the packages to the latest version since there were many changes regarding tls. Older examples do not reference working libaries.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM