Search code examples
phpcurlpaypalexpress-checkout

Paypal express payout error SetExpressCheckout failed: Could not resolve host: api-3t(6)


I am trying to test paypal express checkout with a tutorial I found.

I am working with php on my local pc.

I am using Firefox to test.

When calling paypal, I get this error back: SetExpressCheckout failed: Could not resolve host: api-3t(6)

I tried a solution from a post here that says: switching nameservers to Google Public DNS at 8.8.8.8 and 8.8.4.4

That didn't help

My code:

$API_Endpoint = "https://api-3t/".$GLOBALS['paypal_mode'].".paypal.com/nvp";
    $version = urlencode('124.0');

    // Set the curl parameters.
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $API_Endpoint);
    curl_setopt($ch, CURLOPT_VERBOSE, 1);

    // Turn off the server and peer verification (TrustManager Concept).
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);

    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_POST, 1);

    // Set the API operation, version, and API signature in the request.
    $nvpreq = "METHOD=$methodName_&VERSION=$version&PWD=$API_Password&USER=$API_UserName&SIGNATURE=$API_Signature$nvpStr_";


    // Set the request as a POST FIELD for curl.
    curl_setopt($ch, CURLOPT_POSTFIELDS, $nvpreq);

    // Get response from the server.
    $httpResponse = curl_exec($ch);

Can someone please help?

Thank you


Solution

  • Your current host is api-3t/sandbox.paypal.com/nvp which is in correct. Correct host is https://api-3t.sandbox.paypal.com/nvp

    Change from

    $API_Endpoint = "https://api-3t/".$GLOBALS['paypal_mode'].".paypal.com/nvp";
    

    To

    $API_Endpoint = "https://api-3t.".$GLOBALS['paypal_mode'].".paypal.com/nvp";