#marcus-event-java
1 messages ยท Page 1 of 1 (latest)
I could - use - help ๐
public RequestOptions requestOptions() {
return new RequestOptionsBuilder()
.setApiKey(stripeApiKey)
.build();
I am sending the api key using the RequestOptions object.. there was some reason for that.. But I forgot ๐
Gotcha. When are you getting this error exactly?
Is it when you send API key with requestOptions or some other code?
private List<InvoiceItem> toInvoiceItems(Invoice stripeInvoice) {
List<InvoiceItem> invoiceItems = new ArrayList<>();
InvoiceLineItemCollection lines = stripeInvoice.getLines();
Iterable<InvoiceLineItem> invoiceLineItems = lines.autoPagingIterable(Map.of(), requestOptions);
for (InvoiceLineItem invoiceLineItem : invoiceLineItems) {
String servicePeriod = toServicePeriod(stripeInvoice);
InvoiceItem invoiceItem = InvoiceItem.of(invoiceLineItem.getAmount(), invoiceLineItem.getDescription(), servicePeriod);
invoiceItems.add(invoiceItem);
}
return invoiceItems;
}
this line:
Iterable<InvoiceLineItem> invoiceLineItems = lines.autoPagingIterable(Map.of(), requestOptions);
throws:
java.lang.NullPointerException: Cannot invoke "com.stripe.net.StripeResponseGetter.validateRequestOptions(com.stripe.net.RequestOptions)" because "this.responseGetter" is null
can you print out the lines variable and share what its returning?
What version of the SDK are you running? It sounds pretty similar to this issue
https://github.com/stripe/stripe-java/issues/1454
As I wrote, I am trying to upgrade to the latest, 2023-08-16 or so, from the last one 2020-11-15
but I found now my test - it loads in a static test json
this one.. I just adjusted the api version number
possibly that it is not valid to the new api?
Not sure what I would need to adjust for it
Sorry, not sure I fully understand.
Are you seeing the error when you run a test or make the API request?
I understand you're trying to upgrade to a newer API version but I was asking what version of stripe-java SDK are you currently running?
I am running a test. Haven't seen this test for ages.. But I currently assume it is mocking a real call.. using the json I provided above.
Now it might be the json I use is outdated - I did this ofen - I just repllaced the api version number and it kept working ๐
๐
Stepping in as hanzo needs to step away
Let me know if there is anything else I can help with Marcus
Ah I misunderstood and thought you were saying by changing the API version above it fixed your test
I want to change to the new api version, from the one before (2022-11-15)
I have a test, where I inject a json, to simulate a call to stripe. Those json samples always have the version on top, and that will determine if the json is accepted by the new api version (jar) or not
in most cases, there are few (relevant) changes for me, so just replacing the old number to the new.. did the trick 2-3 times for me in the past
but not this time, it seems
so I assume my json is not compatible with the real api.. I just dont know how to fix it
no
I use Java 20, and I switch from the spring api 2022-11-15 to 2023-08-16
reason for the json.. I receive all webhooks as json and store those events in my events table.. then process them async.
So Simulating a stripe request is easy - I just need to insert a json with status NEW into this table (integration test)
but if the json is not compatible to 2023-08-16.. yes, that could explain why it breaks
๐ great intro to my shift. Boss achievement unlocked
if I remember correctly you are the boss ๐
Do you have a follow up question or are you mostly all set now that you understood API versioning with Events and how stripe-java expects a specific version?
marcus-event-java
I have repeated my question twice
I did not get a single reply yet ๐ฆ
I keep getting a new support-person / moderator. You are number 3.
MarcusStripe
โ
Today at 10:27 PM
I am waiting now for almost 45 minutes now for a single reply.. people come and go.. but no help ๐ฆ
I mean you clearly seem to have intuited what the issue is
stripe-java is pinned to a specific API version based on which major version of the library you're using. so if you have an Event on API version A and use stripe-java expecting API version B then it would never work
I - assume- it is related to an outdated invoice.paid event.. but to fix it, I would need to know what is broken or how the new one looks like
I googled.. couldnt find
and I can't update the test system to the new api.. it forces me to update the PROD version first
that means that my PROD system is broken
and to break it.. I should have a fix read within seconds
so I want my tests to pass green before deploying the change and making the switch on the prod system
You can create a Test webhook endpoint pinned to a specific API version: https://stripe.com/docs/api/webhook_endpoints/create#create_webhook_endpoint-api_version
No idea how this works / is there a way to just get an updated invoice paid event?
1/ Create a webhook endpoint with the right API version that listens to invoice.paid
2/ Create an Invoice and pay it
3/ Receive the Event as expected
And to be clear are you using Java 20 the language runtime version or stripe-java 20.0.0 the version of our library?
yeah but that is the API version which is separate from the version of the stripe-java library. Do you know which one you are using?
If you're not sure I can look at logs on your account if you give me an Event id evt_123 or a Customer id or anything like this
2022-11-15
as I said
or you want the java library??
well the latest
<dependency>
<groupId>com.stripe</groupId>
<artifactId>stripe-java</artifactId>
<version>23.4.0</version>
</dependency>
Okay so you are on 23.* for the major version. If you look at the changelog entry here you see that version of stripe-java is pinned to the API version 2023-08-16, which is the most recent one. Any attempt to deserialize an Event with a different API version would fail.
So now if I understand your ask properly you want to receive an Event with the newer API version to confirm your code works right?
I am using 22.* as, to my understanding, this one supports only the latest api, 2023-08-16.
"Any attempt to deseralize an Event with a different api version would fail" - exactly -
this is, simply because in the json in one of the first lines, the json states the api version, and the java library compares that.
Since I dont know the updated json, as a first attempt, I have just change the api version in my test mock json to the new api version
that allows to proceed.. but then fails with a NullPointer Excception
java.lang.NullPointerException: Cannot invoke "com.stripe.net.StripeResponseGetter.validateRequestOptions(com.stripe.net.RequestOptions)" because "this.responseGetter" is null
at com.stripe.model.StripeCollection.autoPagingIterable(StripeCollection.java:82)
Can you share your exact end to end code for this?
sure
I also did above, I will do again.
private List<InvoiceItem> toInvoiceItems(Invoice stripeInvoice) {
List<InvoiceItem> invoiceItems = new ArrayList<>();
InvoiceLineItemCollection lines = stripeInvoice.getLines();
Iterable<InvoiceLineItem> invoiceLineItems = lines.autoPagingIterable(Map.of(), requestOptions);
for (InvoiceLineItem invoiceLineItem : invoiceLineItems) {
Iterable<InvoiceLineItem> invoiceLineItems = lines.autoPagingIterable(Map.of(), requestOptions);
I mean I'm trying to help you
and that code works fine on the old API version with stripe-java 22.X?
Okay so can I ask you for a complete end to end reproduction as a standalone java file?
and the erorr mesage is super confusing and hard to debug
on it as we speak. Almost done.
done
Funny enough, the real api key is not even needed
it works as just this one class
Simply run "main" and it will throw exactly the exception that I see.
Thanks
Thanks! will have a look in a bit but it will take a while for me to repro and debug
It's time for me to sleep.. how can we meet again?
I mean I see you around here now and then.. but tomorrow morning e.g you will still be sleeping from the pattern that I know you arrive.. usually my evening / night time
Now that you have a clear reproduction, I'd recommend reaching out to our support team instead: https://support.stripe.com/contact
and then, sending them the same code, or telling them to forwar dit to "koopajah"?
No need to forward it to me. You explain the issue, share the exact repro with detailed information and then they can help you figure out the problem
ok
I'll look at your code though in case there is a real bug in the stripe-java library and if so we'd fix it + I'd flag to my team. But we have people around the world and someone else can help you when they get your email escalated!
Yeah they usually switch me to a German person, and I always ask them not to do that.. but they still do.
The English support, to my experience, is better, and my English is fluent
I sent the email out now. Let's see
maybe some feedback that trying to switch to the native language might not always be the best to do.
yeahhhhh
I have constantly tried to say that internally too
I have said many times "I am not a native but I speak English, if I write in English don't respond in my language"
thanks. Good night. "I'd flag to my team" - as I said - you are the BOSS ๐
but weirdly: most people are ecstatic that we reply in their language so it's a hard balance
gotcha ๐
that could be a setting on the dashboard - prefered support language
easy fix imho ๐
it's fun because then if you get to my team (engineers helping users) we mostly only speak English and switch back but by then we don't know of the person wants English
haha I'm sure it seems easy, it definitely isn't ๐
life is hard and then you die.. or something. no it was that it sucks.
anyway ๐
bye
have a good night!