Orders get request error 500

Mortodox
Contributor
Contributor

Hello,

 

I've set up the PayPal checkout system, when I make a payment everything goes well but when I try to retrieve the transaction details on the server side as indicated on the documentation the following error is sent to me:

 

 

 

 

{"error": "invalid_token", "error_description": "Token signature verification failed"}

 

 

 

 

or:

 

 

 

 

{"error":"invalid_client","error_description":"Client credentials are missing"}

 

 

 

 

 

Could you tell me what I forgot to do ? I did follow the documentation....

https://developer.paypal.com/docs/checkout/integrate/#6-verify-the-transaction

 

My code (PHP) :

 

 

 

 

[...]    
      $orderId = $request->getContent();
      try {
         
        // paypal-checkout-sdk
        $client = PayPalClient::client();
        $getOrder = new OrdersGetRequest($orderId);
        $getOrder->headers["Authorization"] = "Bearer xxxx:xxxx";
        $response = $client->execute($head);
        
      } catch (\Exception $e) {
         throw $e;
      }

[...]

 

 

 

 

JS :

 

 

 

paypal.Buttons({
	    env: 'sandbox',
	    client: {
        sandbox:    'xxx'
     },
	    createOrder: function(data, actions) {
	        return actions.order.create({
	          purchase_units: [{
	            amount: {
	              value: '0.03'
	            }
	          }]
	        });
	      },
	      onApprove: function(data, actions) {
	        // Capture the funds from the transaction
	        return actions.order.capture().then(function(details) {
		        
	          // Show a success message to your buyer
	          //alert('Transaction completed by ' + details.payer.name.given_name);

	          console.log(data);
	          // Call your server to save the transaction
	          return fetch('https://xx.xx.xx/fr/purchase/paid/', {
		          
	            method: 'POST',
	            headers: {
	              'content-type': 'application/json'
	            },
	            body: JSON.stringify({
	              orderID: data.orderID
	            })
	            
	          });
	          
	        });
	        
	      },
	      onCancel: function(data) {
	    	    jQuery('#checkoutHolder').html('The checkout failed please refresh the page and try again.');

	    	    jQuery(".payPalButton").hide();

	    	}
	      
	    }).render('#paypal-button');

 

 

 

 

 

Thank you for your help.

Login to Me Too
1 REPLY 1

Mortodox
Contributor
Contributor

Hello,

 

little up 😞

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.