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
- IPN works in sandbox but not live in Sandbox Environment
- User is asked for shipping address when creating a credit card order in REST APIs
- When I do PayPal capture Order, I keep on getting Invalid Request Connection in REST APIs
- PAYER_ACTION_REQUIRED returned for Capture intent when calling v2 checkout orders in Sandbox Environment
- API TRANSACTION_REFUSED in Sandbox when Capturing Payment in REST APIs