fiskaly / fiskaly-sdk-php Goto Github PK
View Code? Open in Web Editor NEWfiskaly Cloud-TSE SDK for PHP
License: MIT License
fiskaly Cloud-TSE SDK for PHP
License: MIT License
We have seen the following issue recently:
[ERROR] 2021/08/13 08:50:03 auth.go:132: failed to parse organization_id and env from token: failed to fetch remote JWK (status = 503)
[ERROR] 2021/08/13 08:50:03 request.go:227: authentication error: failed to fetch remote JWK (status = 503)
[ERROR] 2021/08/13 08:50:03 request.go:338: building http request error: failed to fetch remote JWK (status = 503)
[ERROR] 2021/08/13 08:50:03 request.go:272: failed to do http request, error failed to fetch remote JWK (status = 503)
[ERROR] 2021/08/13 08:50:03 request.go:159: request error: failed to fetch remote JWK (status = 503)
It seemed, like the issue let the fiskaly-client crash.
At least, it was unreachable for some moments after the occurence.
fiskaly-sdk-php/src/FiskalyClient.php
Line 77 in f2598d3
Small change for PHP8.
Optional parameter at the end, or set it to =''
We have got the following Error on a few of our devices, two days ago:
[ERROR] 2021/08/11 17:11:36 request.go:159: request error: HTTP error: {{"body":"{"status_code":500,"error":"Internal Server Error","code":"SlowDown","message":"Internal Server Error"}","headers":{"access-control-allow-origin":[""],"access-control-expose-headers":["X-Request-ID"],"content-length":["103"],"content-type":["application/json; charset=utf-8"],"date":["Wed, 11 Aug 2021 17:11:36 GMT"],"response-time":["10.136"],"strict-transport-security":["max-age=15724800; includeSubDomains"],"vary":["Origin"],"x-request-id":["***"],"x-response-time":["10.136"]},"status":500}}
Somehow it worked after a few retries.
We regularely recive errors of our devices, with the following message:
[ERROR] 2021/08/13 08:44:08 auth.go:105: incorrect status code 401
[ERROR] 2021/08/13 08:44:08 auth.go:106: response body: {"status_code":401,"error":"Method Not Allowed","message":"Invalid credentials"}
[ERROR] 2021/08/13 08:44:08 request.go:227: authentication error: HTTP error: {{"body":"{"status_code":401,"error":"Method Not Allowed","message":"Invalid credentials"}","headers":{"access-control-allow-origin":[""],"access-control-expose-headers":["X-Request-ID"],"content-length":["80"],"content-type":["application/json; charset=utf-8"],"date":["Fri, 13 Aug 2021 08:44:08 GMT"],"response-time":["0.013"],"strict-transport-security":["max-age=15724800; includeSubDomains"],"vary":["Origin"],"x-request-id":["***"],"x-response-time":["0.013"]},"status":401}}
[ERROR] 2021/08/13 08:44:08 request.go:338: building http request error: HTTP error: {{"body":"{"status_code":401,"error":"Method Not Allowed","message":"Invalid credentials"}","headers":{"access-control-allow-origin":[""],"access-control-expose-headers":["X-Request-ID"],"content-length":["80"],"content-type":["application/json; charset=utf-8"],"date":["Fri, 13 Aug 2021 08:44:08 GMT"],"response-time":["0.013"],"strict-transport-security":["max-age=15724800; includeSubDomains"],"vary":["Origin"],"x-request-id":["***"],"x-response-time":["0.013"]},"status":401}}
[ERROR] 2021/08/13 08:44:08 auth.go:105: incorrect status code 401
[ERROR] 2021/08/13 08:44:08 auth.go:106: response body: {"status_code":401,"error":"Method Not Allowed","message":"Invalid credentials"}
[ERROR] 2021/08/13 08:44:08 request.go:227: authentication error: HTTP error: {{"body":"{"status_code":401,"error":"Method Not Allowed","message":"Invalid credentials"}","headers":{"access-control-allow-origin":[""],"access-control-expose-headers":["X-Request-ID"],"content-length":["80"],"content-type":["application/json; charset=utf-8"],"date":["Fri, 13 Aug 2021 08:44:08 GMT"],"response-time":["0.017"],"strict-transport-security":["max-age=15724800; includeSubDomains"],"vary":["Origin"],"x-request-id":["***"],"x-response-time":["0.017"]},"status":401}}
[ERROR] 2021/08/13 08:44:08 request.go:338: building http request error: HTTP error: {{"body":"{"status_code":401,"error":"Method Not Allowed","message":"Invalid credentials"}","headers":{"access-control-allow-origin":[""],"access-control-expose-headers":["X-Request-ID"],"content-length":["80"],"content-type":["application/json; charset=utf-8"],"date":["Fri, 13 Aug 2021 08:44:08 GMT"],"response-time":["0.017"],"strict-transport-security":["max-age=15724800; includeSubDomains"],"vary":["Origin"],"x-request-id":["***"],"x-response-time":["0.017"]},"status":401}}
[ERROR] 2021/08/13 08:44:08 request.go:272: failed to do http request, error HTTP error: {{"body":"{"status_code":401,"error":"Method Not Allowed","message":"Invalid credentials"}","headers":{"access-control-allow-origin":[""],"access-control-expose-headers":["X-Request-ID"],"content-length":["80"],"content-type":["application/json; charset=utf-8"],"date":["Fri, 13 Aug 2021 08:44:08 GMT"],"response-time":["0.017"],"strict-transport-security":["max-age=15724800; includeSubDomains"],"vary":["Origin"],"x-request-id":["***"],"x-response-time":["0.017"]},"status":401}}
[ERROR] 2021/08/13 08:44:08 request.go:159: request error: HTTP error: {{"body":"{"status_code":401,"error":"Method Not Allowed","message":"Invalid credentials"}","headers":{"access-control-allow-origin":[""],"access-control-expose-headers":["X-Request-ID"],"content-length":["80"],"content-type":["application/json; charset=utf-8"],"date":["Fri, 13 Aug 2021 08:44:08 GMT"],"response-time":["0.017"],"strict-transport-security":["max-age=15724800; includeSubDomains"],"vary":["Origin"],"x-request-id":["***"],"x-response-time":["0.017"]},"status":401}}
Even though, after a few retries, the data will be transmittet, without any intervention. It just spams our logging.
[PHPUnit\Framework\Exception] Undefined index: code
#1 vendor/fiskaly/fiskaly-sdk-php/src/errors/FiskalyErrorHandler.php:30
#2 vendor/fiskaly/fiskaly-sdk-php/src/FiskalyClient.php:307
public static function throwOnError($response)
{
if ($response instanceof ErrorResponse) {
if ($response->getCode() == self::$HTTP_ERROR) {
$responseData = $response->getData();
$errorBody = json_decode(base64_decode($responseData['response']['body']), true);
$requestId = $responseData['response']['headers']['x-request-id'][0];
throw new FiskalyHttpException($errorBody['message'], $errorBody['code'], $errorBody['error'], $errorBody['status_code'], $requestId);
} elseif ($response->getCode() == self::$HTTP_TIMEOUT_ERROR) {
throw new FiskalyHttpTimeoutException($response->getMessage());
} else {
throw new FiskalyClientException($response->getMessage(), $response->getCode(), $response->getData());
}
}
}
Some errors don't contain the key ['code']
I'm trying to make responses, but if the state has to be array I can't make it work. My Code is the following:
$query = new stdClass();
$query->states = array("FINISHED")
If I now pass it to the response()
method then I get the exception state should be an array.
Im passing $query
in the $query
parameter of the method (not converted to JSON or something like that).
When I try to finalize a transaction this exception is throwned: "Invalid params". This is caused due to this error: "path must not contain "?"".
This is the PUT url: /tss/301fcd8f-7304-4f64-b684-63f8ccbca6a8/tx/bf411dc7-caac-40b2-bdd2-606316f09f52?latest_revision=1
.
I don't remember this happened last time I checked (31 december 2020). Is this a Google Cloud issue maybe and can I solve it on my side?
0 => array:6 [
"file" => "/var/www/html/test/vendor/fiskaly/fiskaly-sdk-php/src/FiskalyClient.php"
"line" => 320
"function" => "throwOnError"
"class" => "FiskalyClient\errors\FiskalyErrorHandler"
"type" => "::"
"args" => array:1 [
0 => Datto\JsonRpc\Responses\ErrorResponse {#598
-message: "Invalid params"
-code: -32602
-data: "path must not contain "?""
-id: 0
}
]
]
1 => array:6 [
"file" => "/var/www/html/test/Fiskaly/Client.php"
"line" => 134
"function" => "request"
"class" => "FiskalyClient\FiskalyClient"
"type" => "->"
"args" => array:5 [
0 => "PUT"
1 => "/tss/301fcd8f-7304-4f64-b684-63f8ccbca6a8/tx/bf411dc7-caac-40b2-bdd2-606316f09f52?latest_revision=1"
2 => null
3 => null
4 => "eyJzdGF0ZSI6IkZJTklTSEVEIiwiY2xpZW50X2lkIjoiNzUyYzkyZWItYzE5NS00OWI3LWE0MTAtNmQ5YzlkOTAzZDdhIiwic3RhbmRhcmRfdjEiOnsicmVjZWlwdCI6eyJyZWNlaXB0X3R5cGUiOiJSRUNFSVBUIiwiYW1vdW50c19wZXJfdmF0X3JhdGUiOnsidmF0X3JhdGUiOiJOT1JNQUwiLCJhbW91bnQiOiIxMi41In0sImFtb3VudHNfcGVyX3BheW1lbnRfdHlwZSI6eyJwYXltZW50X3R5cGUiOiJOT05fQ0FTSCIsImFtb3VudCI6IjEyLjUifX19fQ=="
]
]
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.