-
Notifications
You must be signed in to change notification settings - Fork 441
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Better Access to Response Headers #370
Comments
(feel free to assign this to me as I'm happy to do a PR here) |
@sedouard To be honest, a lot of the improvements come about when someone is interested enough to tackle them. If you are here, then I think you should take a shot at it — we can always use a few more people able to actively contribute to these libraries. (And it sounds like you already are, but maybe just coordinate with Olivier and co. first to make sure none of them are working on it.) |
Use case: I am creating a database entry in my app upon a particular event which results in a stripe API request. I want this entry to be as auditable as possible and want to include the request_id. What I'm doing: customer = Customer.retrieve(...)
customer.account_balance = 5
customer.save(idempotency_key) What I'd like to do here is, as a result of the save() call, I would like to get access to the response headers. @sedouard Have you worked on a PR for this? If you haven't and it's not on your plate I'll be happy to tackle it. |
@jleclanche Yes, there is an open PR for this: #371. Once it's merged, all customer.save(idempotency_key=idempotency_key)
request_id = customer.last_response.request_id |
Oh, cool, I missed the PR yeah. Just read the backlog and changes, looks great. You guys sure saved me a bunch of work :) |
Fixed in #371 and released as 1.77.0. |
It seems I cannot get either status_code, or response_code by following the same? Code snippet: Using the latest stripe version and Python 3.7. Not sure what I'm missing here? |
@danielhao5 The status code is accessible via the
|
I am using python sdk for stripe. I am unable to find the |
@inai-suraj can you share a code snippet that's not working for you? I just tried the following code and it works as expected. resp = stripe.PaymentIntent.create(
amount=1099,
currency="eur",
automatic_payment_methods={"enabled": True},
)
print(resp.last_response.headers) |
@pakrym-stripe My bad. It works. Thanks. |
On a successful API request the Stripe Java SDK doesn't provide a way of accessing response headers. (At least not that I can tell).
This can be useful in the case you're interested in response metadata (such as Idempotency-Key and Request-ID).
For example in a GET /charges/:id request:
It would be great if there was an optional way to grab the HTTP response metadata through some kind of bound method on the deserialized response:
Or simply as a property:
Because api_requestor returns only the deserialized version of the response body it isn't possible to get HTTP request-specific things at the moment. Does it make sense to add a
response
property here so that we mirror the approach discussed in the node sdk?The text was updated successfully, but these errors were encountered: