#marcus-event-java

1 messages ยท Page 1 of 1 (latest)

shut hollowBOT
urban lantern
#

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 ๐Ÿ™‚

glass vapor
#

Gotcha. When are you getting this error exactly?
Is it when you send API key with requestOptions or some other code?

urban lantern
#

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

glass vapor
#

can you print out the lines variable and share what its returning?

urban lantern
glass vapor
urban lantern
#

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

glass vapor
#

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?

urban lantern
#

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 ๐Ÿ™‚

shut hollowBOT
rare raven
#

๐Ÿ‘‹

#

Stepping in as hanzo needs to step away

#

Let me know if there is anything else I can help with Marcus

urban lantern
#

well, like everythin?

#

Hanzo did not help yet with any of my question ๐Ÿ˜ฆ

rare raven
#

Ah I misunderstood and thought you were saying by changing the API version above it fixed your test

urban lantern
#

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

rare raven
#

Okay let me take a look

#

You said you are using 20.0.0 of the Java SDK?

urban lantern
#

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

shut hollowBOT
urban lantern
#

now the boss comes ๐Ÿ™‚

#

Hello Koopajah ๐Ÿ™‚

static thorn
#

๐Ÿ‘‹ great intro to my shift. Boss achievement unlocked

urban lantern
#

if I remember correctly you are the boss ๐Ÿ™‚

static thorn
#

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

urban lantern
#

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 ๐Ÿ˜ฆ

static thorn
#

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

urban lantern
#

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

static thorn
urban lantern
#

No idea how this works / is there a way to just get an updated invoice paid event?

static thorn
#

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?

urban lantern
#

java 20

#

so far, stripe 2022-11-15, and I want to switch to 2023-08-16

static thorn
#

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

urban lantern
#

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>

static thorn
#

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?

urban lantern
#

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)

static thorn
#

Can you share your exact end to end code for this?

urban lantern
#

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);

static thorn
#

I mean I'm trying to help you

urban lantern
#

this one fais

#

fails

#

request Options, I use it to forward the api key

static thorn
#

and that code works fine on the old API version with stripe-java 22.X?

urban lantern
#

yes

#

works perfectly fine on prod

static thorn
#

Okay so can I ask you for a complete end to end reproduction as a standalone java file?

urban lantern
#

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

static thorn
#

Thanks! will have a look in a bit but it will take a while for me to repro and debug

urban lantern
#

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

static thorn
urban lantern
#

and then, sending them the same code, or telling them to forwar dit to "koopajah"?

static thorn
#

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

urban lantern
#

ok

static thorn
#

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!

urban lantern
#

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.

static thorn
#

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"

urban lantern
#

thanks. Good night. "I'd flag to my team" - as I said - you are the BOSS ๐Ÿ˜„

static thorn
#

but weirdly: most people are ecstatic that we reply in their language so it's a hard balance

urban lantern
#

gotcha ๐Ÿ™‚

#

that could be a setting on the dashboard - prefered support language

#

easy fix imho ๐Ÿ™‚

static thorn
#

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 ๐Ÿ˜…

urban lantern
#

life is hard and then you die.. or something. no it was that it sucks.

#

anyway ๐Ÿ˜‰

#

bye

static thorn
#

have a good night!

shut hollowBOT