Comments (12)
It look's pretty simple to implement it, would you try it?
from gopay-inline.
Working on it.
from gopay-inline.
Well, not as easy as it looks on the first sight. API call /accounts/account-statement returns application/octet-stream
When called, the Markette\GopayInline\Http\Response does not contain the content of the file, just headers. Any idea how to fix this and not break everything else?
from gopay-inline.
Mmm. Can you check return header/content-type?
https://github.com/Markette/GopayInline/blob/master/src/Http/Curl.php#L34-L44
from gopay-inline.
object(Markette\GopayInline\Http\Response)#94 (4) { ["data":protected]=> NULL ["headers":protected]=> array(26) { ["url"]=> string(52) "https://gate.gopay.cz/api/accounts/account-statement" ["content_type"]=> string(24) "application/octet-stream" ["http_code"]=> int(200) ["header_size"]=> int(598) ["request_size"]=> int(379) ["filetime"]=> int(-1) ["ssl_verify_result"]=> int(0) ["redirect_count"]=> int(0) ["total_time"]=> float(0.232824) ["namelookup_time"]=> float(3.1E-5) ["connect_time"]=> float(0.008602) ["pretransfer_time"]=> float(0.039469) ["size_upload"]=> float(101) ["size_download"]=> float(60416) ["speed_download"]=> float(259492) ["speed_upload"]=> float(433) ["download_content_length"]=> float(-1) ["upload_content_length"]=> float(101) ["starttransfer_time"]=> float(0.224169) ["redirect_time"]=> float(0) ["redirect_url"]=> string(0) "" ["primary_ip"]=> string(13) "35.156.106.68" ["certinfo"]=> array(0) { } ["primary_port"]=> int(443) ["local_ip"]=> string(13) "88.86.109.181" ["local_port"]=> int(40482) } ["code":protected]=> int(200) ["error":protected]=> NULL }
The problem is in line
https://github.com/Markette/GopayInline/blob/master/src/Http/Curl.php#L41
$result contains binary content of the file (xls/abo or csv).
json_decode($result) then makes it NULL.
from gopay-inline.
My idea is to rewrite https://github.com/Markette/GopayInline/blob/master/src/Http/Curl.php#L40-44 to:
} else {
$info = curl_getinfo($ch);
$response->setCode(curl_getinfo($ch, CURLINFO_HTTP_CODE));
$response->setHeaders($info);
if($info['content_type'] == 'application/json') {
$response->setData(json_decode($result));
} else {
$response->setData($result);
}
}
What do you say?
from gopay-inline.
Nice idea, that's what I was thinking about. Could we also check application/octet-stream
content type? Just for sure.
from gopay-inline.
So like this?
if($info['content_type'] == 'application/json') {
$response->setData(json_decode($result));
} elseif($info['content_type'] == 'application/octet-stream' {
$response->setData($result);
} else {
$response->setData($result);
}
from gopay-inline.
At this moment we had just application/json
. Your plan is to add a application/octet-stream
. And I would like to throw an exception if neight of these conditions is mached. Do you agree or do you think it's pointless?
from gopay-inline.
I wouldn't throw an Exception as it poses a risk of breaking things, that currently work (we would have to check that all the current calls do return application/json
correctly to be sure). Saying this, I would restate my suggestion to this:
if($info['content_type'] == 'application/octet-stream') {
$response->setData($result);
} else {
$response->setData(json_decode($result));
}
This way we make sure, that everything works exactly as now (and we don't break something by accident), with the exception of application/octet-stream
that has newly added behaviour.
from gopay-inline.
Ouk.
from gopay-inline.
Resolved via #25
from gopay-inline.
Related Issues (20)
- EET je NULL
- vatRate a type je NULL u items při použití PaymentFactory
- Refundace platby pro EET
- EET účtenky platby HOT 3
- Missing BITCOIN PaymentInstrument HOT 5
- Wrong type used for price amounts HOT 8
- PHP 7.2 - 8.0 HOT 2
- Nette 3 support HOT 5
- Contributte
- Contributte style HOT 1
- Argument $data in PaymentFactory::create() should be regular entity HOT 6
- RecurrentPayment configuration not compatible with Payment (callback parameter) HOT 6
- Contributte standardise HOT 2
- Payment price validation of an multi-item HOT 2
- How to create signature? HOT 2
- Auto update authorization token after expiration.
- Wrong installation instructions in README HOT 1
- Allow version 4 of moneyphp/money dependency HOT 6
- Added endpoint for cancel recurrence payment
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 gopay-inline.