-
Notifications
You must be signed in to change notification settings - Fork 850
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ApiResponse psr-7 compliant #699
Comments
Hi @decima, thanks for the suggestion. I think this is a desirable change, but it would require making some significant changes to the HTTP client and interface to be compliant (there are a few things required by the spec that we're not storing right now, like the protocol version or the "reason phrase"). I'll tag this as |
Hello, any thoughts on this feature? |
Hello in the same context, during a discussion on the Symfony Devs Slack some devs ask about the ability to use a PSR-18 HTTP Client when using Here is what I was able to create: (requires PHP8) https://gist.github.com/Prometee/3bc6ca1a8b16d593ceb24da66fa6142f use App\Stripe\HttpClient\PsrHttpClient;
use GuzzleHttp\Psr7\HttpFactory;
use Http\Adapter\Guzzle7\Client;
use Stripe\ApiRequestor;
$httpFactory = new HttpFactory();
$psrHttpClient = new PsrHttpClient(
new Client(),
$httpFactory,
$httpFactory
);
ApiRequestor::setHttpClient($psrHttpClient);
ApiRequestor::setStreamingHttpClient($psrHttpClient); |
This would be an awesome feature to easily be able to drop in a Guzzle client with some middleware for logging/debugging. Extremely useful if you are trying to monitor all outbound calls from your app to identify performance issues, n+1 issues, or badly written requests/unexpected responses. Yes Stripe give us developers a portal to view this information in but it is much better to have it all in one place. And thank you @Prometee, this is exactly what I was looking for! |
I'm here because this morning I got a |
Yeah, I'd like to do it so I can inject some middleware to record requests and report on errors a bit better. You can specify retries with the native |
You're right @ZacharyDuBois There is a Sorry for my off-topic. |
I'd love to see this happen. A PSR-7 based client would make it so easy to log outgoing requests and find errors. Any update from Stripe? |
I think the
Stripe\ApiResponse
should be psr7-compliant for easier integration in frameworks that handle psr7 responses, like Laravel, Symfony and others.What do you think?
The text was updated successfully, but these errors were encountered: