I am trying to capture a payment through PayPal API but I keep receiving error 500. I followed the guide (translated to PHP for my needs) so I can not see where is my mistake.
My back is in PHP/Symfony so I use HTTPClient to send the request:
$response = $this->client->request('POST', sprintf('%s/%s/checkout/orders/%s/capture', $this->url, 'v2', $orderID), [
'auth_bearer' => $this->accessToken,
'headers' => [
'Content-Type' => 'application/json',
'PayPal-Request-Id' => $payment->getClientToken()
],
'json' => null
]);
I added 'json' => null to force the request as application/json.
Also I noticed some little problems, I could not authenticate on v2 URLs I have to use v1 and process payment to v2.
I am using sandbox account. If I run all the requests in postman I get 201 CREATED but if I do only this one with the ID from the checkout I get 404 Not Found.
On the three ways to use the request I do not have a single one with the same return.
Do someone had this problem and solved it?
EDIT: Add curl example from PayPal API doc:
curl -v -X POST https://api-m.sandbox.paypal.com/v2/checkout/orders/XXX/authorize \
-H "Content-Type: application/json" \
-H "Authorization: Bearer Access-Token" \
-H "PayPal-Request-Id: XXX"