Paypal API invalid request on Orders capture
adgower
Contributor
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on
Oct-25-2020
05:51 PM
Using Laravel HTTP client
Http::withToken($response->json()['access_token'])->post('https://api.sandbox.paypal.com/v2/checkout/orders/'.$request->token.'/capture');
returns:
{"name":"INVALID_REQUEST","message":"Request is not well-formed, syntactically incorrect, or violates schema.","debug_id":"1ba98921ebb38","details":[{"field":"\/","location":"body","issue":"INVALID_SYNTAX","description":"MALFORMED_REQUEST_JSON"}],"links":[{"href":"https:\/\/developer.paypal.com\/docs\/api\/orders\/v2\/#error-INVALID_SYNTAX","rel":"information_link","encType":"application\/json"}]}
I have the required parameters not sure what else I am missing. Any tips?
Labels:
Login to Me Too
- Labels:
-
Payments REST APIs
1 REPLY 1
dreadkopp
Contributor
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
May-14-2023
05:14 AM
Since i ran into the same issue recently and stumbled upon this thread:
When using the HTTP Facade, the ::post() method will pass an empty array as payload. which is by definition invalid (since present but not according to specs).
As a workaround you can use the underlying ::send() method
something like this:
public function captureOrder(string $token): bool
{
return Http::withToken($this->getAuthToken())
->contentType('application/json')
->send('POST',$this->baseUrl.'/v2/checkout/orders/'.$token.'/capture')
->created();
}
i know to OP might not need this info anymore but it might help someone 🙂

Haven't Found your Answer?
It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.
Related Content
- where does paypal payments go to if there is no linked phone or email to the seller ? in PayPal Payments Standard
- CHECKOUT.ORDER.APPROVED webhook event not triggered if payment_source is passed in in REST APIs
- Inquiry About Documentation and Support for Tokenization and Future Payment in Payflow
- Are there any restrictions to charge using only html, vanilla javascript and php with rest api? in REST APIs
- I get always the error: "invalid client_id or redirect_uri" from signin authorize endpoint. in Braintree Server-side Integration (PHP, Java, .NET, Ruby, Python, NodeJS SDKs)