HttpException: {"error":"invalid_client","error_description":"Client Authentication failed"}

mkgeneralaid
New Community Member

this posted and here

<Removed>

 

using Javascript SDK created sample live 0.01 sales SUCCESS

following the 

ID/secret here live

<Removed>

<Removed>

PHP SDK

https://developer.paypal.com/docs/checkout/reference/server-integration/setup-sdk/

Where put this:

$request = new OrdersCreateRequest();
$request->headers["prefer"] = "return=representation";

???

BUT here >>>

<Removed>

GETTING:  // WHERE is the error??? I used Live --- are headers the problem or is auth ???


Fatal error: Uncaught PayPalHttp\HttpException: {"error":"invalid_client","error_description":"Client Authentication failed"} in /home/polislatchiaptsv/public_html/main/vendor/paypal/paypalhttp/lib/PayPalHttp/HttpClient.php:215 Stack trace: #0 /home/polislatchiaptsv/public_html/main/vendor/paypal/paypalhttp/lib/PayPalHttp/HttpClient.php(100): PayPalHttp\HttpClient->parseResponse(Object(PayPalHttp\Curl)) #1 /home/polislatchiaptsv/public_html/main/vendor/paypal/paypal-checkout-sdk/lib/PayPalCheckoutSdk/Core/AuthorizationInjector.php(37): PayPalHttp\HttpClient->execute(Object(PayPalCheckoutSdk\Core\AccessTokenRequest)) #2 /home/polislatchiaptsv/public_html/main/vendor/paypal/paypal-checkout-sdk/lib/PayPalCheckoutSdk/Core/AuthorizationInjector.php(29): PayPalCheckoutSdk\Core\AuthorizationInjector->fetchAccessToken() #3 /home/polislatchiaptsv/public_html/main/vendor/paypal/paypalhttp/lib/PayPalHttp/HttpClient.php(64): PayPalCheckoutSdk\Core\AuthorizationInjector->inject(Object(PayPalCheckoutSdk\Orders\OrdersGetRequest)) #4 /ho in /home/polislatchiaptsv/public_html/main/vendor/paypal/paypalhttp/lib/PayPalHttp/HttpClient.php on line 215

 

<?php

namespace Sample;

require __DIR__ . '/vendor/autoload.php';
//1. Import the PayPal SDK client that was created in `Set up Server-Side SDK`.
use Sample\PayPalClient;
use PayPalCheckoutSdk\Orders\OrdersGetRequest;
use Sample\CaptureIntentExamples\CreateOrder;

class GetOrder
{

  // 2. Set up your server to receive a call from the client
  /**
   *You can use this function to retrieve an order by passing order ID as an argument.
   */
  public static function getOrder($orderId)
  {

    // 3. Call PayPal to get the transaction details
    $client = PayPalClient::client();
    $response = $client->execute(new OrdersGetRequest($orderId));
    /**
     *Enable the following line to print complete response as JSON.
     */
    //print json_encode($response->result);
    print "Status Code: {$response->statusCode}\n";
    print "Status: {$response->result->status}\n";
    print "Order ID: {$response->result->id}\n";
    print "Intent: {$response->result->intent}\n";
    print "Links:\n";
    foreach($response->result->links as $link)
    {
      print "\t{$link->rel}: {$link->href}\tCall Type: {$link->method}\n";
    }
    // 4. Save the transaction in your database. Implement logic to save transaction to your database for future reference.
    print "Gross Amount: {$response->result->purchase_units[0]->amount->currency_code} {$response->result->purchase_units[0]->amount->value}\n";

    // To print the whole response body, uncomment the following line
    // echo json_encode($response->result, JSON_PRETTY_PRINT);
  }
}

/**
 *This driver function invokes the getOrder function to retrieve
 *sample order details.
 *
 *To get the correct order ID, this sample uses createOrder to create a new order
 *and then uses the newly-created order ID with GetOrder.
 */
if (!count(debug_backtrace()))
{
  GetOrder::getOrder('9EC1989552495262M'true);  // SAMPLE SUCCESS 0.01 ID
}
?>

 

Login to Me Too
4 REPLIES 4

Toeiking
New Community Member

Hi there!

 

I'd love to know how you fixed this problem.

I've been experiencing the same problem for two days now, and I can't seem to go anywhere.

I'm still at development and testing phrase, and I'm trying to create an order. My client id

and client secret are correct for sure, but I keep getting exactly the same error message.

 

Thank you for sharing your solution.

 

Kind regards,

 

Alex

Login to Me Too

Alexander-Pop
New Community Member

Make sure you use API Keys from proper Environment.

If use SDK:

use PayPalCheckoutSdk\Core\ProductionEnvironment;
use PayPalCheckoutSdk\Core\SandboxEnvironment;

 

$clientId = 'YOUR_PAYPAL_CLIENT_ID'; //'YOUR_PAYPAL_SANDBOX_CLIENT_ID';
$clientSecret = 'YOUR_PAYPAL_CLIENT_SECRET'; //'YOUR_PAYPAL_CLIENT_SANDBOX_SECRET'

 

/* sandbox */
$environment = new SandboxEnvironment($clientId, $clientSecret);

/* production */
$environment = new ProductionEnvironment($clientId, $clientSecret);

Login to Me Too

James467
New Community Member

Is there anything else? I have  $clientId  $clientSecret supplied by PayPal and it still throws up this error. I know they work.

 

( ! ) Fatal error: Uncaught PayPalHttp\HttpException in D:\wamp64\www\scripts\PayPalCheckout-SDK\vendor\paypal\paypalhttp\lib\PayPalHttp\HttpClient.php on line 215( ! ) PayPalHttp\HttpException: in D:\wamp64\www\scripts\PayPalCheckout-SDK\vendor\paypal\paypalhttp\lib\PayPalHttp\HttpClient.php on line 215Call Stack# Time Memory Function Location

10.0007422432{main}( )...\index.php:0
20.02441762432Sample\CaptureIntentExamples\GetOrder::getOrder( )...\index.php:104
30.02991968440PayPalCheckoutSdk\Core\PayPalHttpClient->execute( )...\index.php:70
40.80492001832PayPalCheckoutSdk\Core\PayPalHttpClient->parseResponse( )...\HttpClient.php:100

 

checkout v2 has been beating me up for a month now. I almost miss the mess of IPN

Login to Me Too

untucked
Contributor
Contributor

This answer was close to my solution, 

The correct naming for ProductionEnvironment is LiveEnvironment

 

class PayPalClient:
def __init__(self):
self.client_id = client_id
self.client_secret = client_secret

self.environment = LiveEnvironment(client_id=self.client_id, client_secret=self.client_secret)
self.client = PayPalHttpClient(self.environment)

Login to Me Too

Haven't Found your Answer?

It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.