1
0
Files
PayPal-PHP-Server-SDK/doc/api-response.md
Patrick Powers 6da8b9b5b8 1.1.0 Release (#44)
* Automated commit message

* add changelog

---------

Co-authored-by: PayPalServerSDKs <server-sdks@paypal.com>
Co-authored-by: Patrick Powers <patickpowers@hey.com>
2025-05-27 13:31:17 -05:00

999 B

ApiResponse

Represents the result of an API call, including the request details, response metadata, and the returned data.

Methods

Name Type Description
getRequest() HttpRequest Returns the original request that resulted in this response.
getStatusCode() ?int Returns the response status code.
getHeaders() ?array Returns the response headers.
getResult() mixed Returns the response data.
getBody() mixed Returns the original body from the response.
isSuccess() bool Checks if the response is successful (HTTP 2xx).
isError() bool Checks if the response indicates an error. (not HTTP 2xx)

Usage Example

$response = $client->exampleController()->exampleEndpoint($input);

if ($response->isSuccess()) {
    echo "Success! Result: ";
    print_r($response->getResult());
} else {
    echo "Error: ";
    print_r($response->getBody());
}