Comments (4)
Hello. The check for errors is on the API request itself, not the contents of your actual $call
object. You could have a successful API call that returns a $call
object that contains errors. In that case you would check the success/fail status of the $call
in your calling code.
from chargify-sdk-php.
Apologies for not posting my entire code. I am instantiating a new Call object and calling ->readByChargifyId()
with the call id given from the Direct response, since the response from Chargify doesn't include error details in their response.
// $response = data returned from Chargify via the Direct form request
$chargify = new ChargifyV2(config('services.chargify.direct'));
$call = $chargify->call();
$responseCall = $call->readByChargifyId($response->get('call_id'));
$responseCall->isError()
and $responseCall->getErrors()
return false and empty, respectively, even though the call has an error.
Right now I have to do the following to extract the errors:
$chargify = new ChargifyV2(config('services.chargify.direct'));
$call = $chargify->call();
$service = $call->getService();
$response = $service->request('calls/' . $request->get('call_id'), 'GET');
$responseArray = $call->getResponseArray($response);
if (!empty($responseArray['call']['response']['result']['errors'])) {
foreach ($responseArray['call']['response']['result']['errors'] as $error) {
$errors->add($error['attribute'], $error['message']);
}
}
Not sure of any other way to extract the errors. Seems a little more roundabout than it's intended.
from chargify-sdk-php.
Your first code is accurate. As I mentioned, ->isError()
and ->getErrors()
only deal with problems with the http request to Chargify. As your example code is showing, the http response was successful so there should not be any errors from ->isError()
or ->getErrors()
. This is expected.
You can get the errors on the actual call with the following:
$chargify = new ChargifyV2(config('services.chargify.direct'));
$call = $chargify->call();
$responseCall = $call->readByChargifyId($response->get('call_id'));
var_dump($responseCall['response']['result']['errors']);
from chargify-sdk-php.
ah, gotcha. Thanks for clearing that up.
from chargify-sdk-php.
Related Issues (15)
- \GuzzleHttp\Message\Response getStatus HOT 4
- new Request in V2 is not including base_url, causes all requests to fail HOT 2
- How Can I use WebHooks? HOT 1
- Any reason why Guzzle version is hard coded? HOT 1
- Invoice payment HOT 2
- cancelImmediately results in error 500 HOT 2
- Network error HOT 4
- How to work with this in localhost without https? HOT 1
- Load _data HOT 2
- Subscription preview and coupons support HOT 1
- Announcement: new maintainer wanted HOT 6
- Guzzle Version HOT 5
- Suggestion to clarify docs on Subscription migrate() HOT 5
- Version variable needs updating HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from chargify-sdk-php.