Comments (6)
has there been any activity on this?
from stripe-java.
Could you elaborate on why our dashboard logs are not sufficient for your use case?
In terms of stripe-java:
For all StripeObjects
, toString
includes the a JSON representation of the object. It is true that this this is effectively re-serializing the deserialized data; it is not a true readback of the raw response.
The API parameters that you pass are also what go over the wire.
I'm a bit nervous to include the full request object in the StripeObject
. Among other things, it'd include the api key that you made the request with. I may be overly paranoid, but I'm potentially not excited about objects that didn't used to have API keys in them now having API keys, depending on what kind of automatic serialization formats people might be using (I don't want to accidentally lead you to start injecting your Stripe secret key into your database just because you bumped your stripe-java
dependency).
Anyway, I'm happy to entertain this. Would I be able to convince you to submit a pull request? I'll also note that short of rolling your own SDK, you'd in general always be welcome to fork stripe-java to add the request / response logging that you need. You wouldn't need to roll your own SDK.
Let me know your thoughts. If you're not up for taking a stab at adding what you need, could you describe the desired interface in a bit more detail? Would you expect that any fetched APIResource
would be able to tell you about the request that created it?
from stripe-java.
Don't get me wrong - the Stripe dashboard log is outstanding and we've used it several times. The reason we need the logging "in-house" is 1. what if the call doesn't make it to stripe (network issue) - then your log can't show it, 2. we use multiple external APIs and track all calls to all APIs (including some internal stuff), 3. with all logging "internal" we're able to attach all sorts of reference information to each log entry - I can look up a user and see precisely what the sequence of API calls were, which helps a lot when trying to answer "why doesn't it work?"
The information can't really be put in the StripeObject returned by e.g. Charge.create() - there are several cases that require logging where such an object is not returned (e.g. the failure cases).
The strategy I've seen used by other SDKs is to not use a static method, but instead have a Client object created which handles the request and then returns the StripeObject if succesful, but regardless it holds on to the most recent request information (since separate Client objects can be created by separate threads, this can easily be used in a thread safe manner by the calling code).
So instead of Charge.create(params, apiKey)
, you'd have something along the lines of:
StripeClient client = new StripeClient(apiKey);
try {
client.charge(params);
} finally {
doLogging(client); // client now has e.g. lastRequest, lastResponse, lastStatus, etc
}
(specific implementations may do things slightly differently, but you get the general gist)
Under the hood, Charge.create(params, apiKey)
can of course "just" do new StripeClient(apiKey).charge(params)
for backwards compatibility.
I realize that this would be a significant departure from the current structure, at least under the hood.
Perhaps it would be an easier change to not to a StripeClient, but instead do a StripeCall, encapsulating a single call to Stripe. The usage would then be something like:
StripeCall call = Charge.createCall(params, apiKey);
try {
call.execute();
} finally {
doLogging(call); // call now has e.g. lastRequest, lastResponse, lastStatus, etc
}
That would unfortunately duplicate the entire static method set, which is not super-exciting.
It's not easy to retrofit in a both clean and backwards compatible manner on the current SDK. Thoughts?
from stripe-java.
I think the correct approach here would be to abstract all connection logic into pluggable backends. You could then write a custom backend that extends the provided backend to write all requests / responses to your logging backend.
from stripe-java.
I'm going to close this issue for now, but tag it with version-two
. We'll probably go with the backends approach, which means you'll be able to create a custom backend that would log all requests / responses.
from stripe-java.
This issue has been added to the Version 2 Roadmap https://github.com/stripe/stripe-java/wiki/Roadmap
from stripe-java.
Related Issues (20)
- StripeClient#subscriptions().list() causes class com.google.gson.internal.LinkedTreeMap cannot be cast to class com.stripe.model.HasId HOT 5
- The StripeResponseGetter has not been set on this resource HOT 9
- Allow Webhook class instance to be configured with java.time.Clock HOT 2
- Official support for Spring Boot HOT 3
- getResponseGetter() not set on account.capabilities() HOT 2
- Cannot Unset Invoice Settings Custom Field of a Given Customer HOT 1
- Unable to use Webhook.constructEvent when using StripeClient HOT 1
- Customer.getCashBalanceTransactions does not exist HOT 2
- PaymentIntent error when gson version is < 2.9.1 HOT 2
- Stripe-java in am quarkus application is returning null for all Stripe resource requests HOT 2
- Add feature to add Discount in SubscriptionCreateParams HOT 3
- Change due date attribute of Stripe invoice to a past date HOT 2
- Price object tiers field is null even though the price has tiers setup HOT 1
- retrieve raw JSON, instead of immediately parsing into Stripe Models HOT 3
- `toJson` fails to create exactly the same json as the Stripe HTTP API HOT 2
- API error shadowed by ClassCastException message if error is not a json object HOT 1
- Missing Function in Meter Class HOT 7
- Add network_details to dispute HOT 3
- Null value from PaymentMethod.retrieve associated to a Link Payment HOT 2
- The getFeatures function in stripe.com.model.Product provided in the documentation don't exists HOT 2
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 stripe-java.