#Att89

1 messages ยท Page 1 of 1 (latest)

languid jettyBOT
main flame
#

Hi! Let me help you with this.

pastel dune
#

Hi! Thanks, the ID of our account is acct_1M1mEbDXxFAIpgi2

#

The last event triggered locally, which failed has the ID evt_3MCJjEDXxFAIpgi20Hn2gAhm

#

In Test-mode but not locally:
evt_3MCJjEDXxFAIpgi20phB6RMs

#

And in Live-Mode:
evt_1MC5nzDXxFAIpgi2TZxYkCJg

#

Hopefully it is the same problem though

main flame
#

Looking at it

#

It seems like the error is happening inside your server. Are you getting any errors on your side?

pastel dune
#

Locally nothing, in our test-server sometimes this error:
com.stripe.exception.PermissionException: Only Stripe Connect platforms can work with other accounts. If you specified a client_id parameter, make sure it's correct. If you need to setup a Stripe Connect platform, you can do so at https://dashboard.stripe.com/account/applications/settings.; code: platform_account_required

#

But I don't now what this even mean

main flame
#

It doesn't seem to be related to webhooks.

pastel dune
#

You mean the error above? I think it is probably because of the move of the data from the old account.

main flame
#

Your server is responding with status 400 to Stripe attempts to send a webhook request. You need to check if the webhook endpoint address is correct, and check why does your server respond with 400 error.

pastel dune
#

For example on a login of a user, I will check what the server does with the stripe account, but it has nothing to do with the webhook-problem

#

I think at least

#

I check first the webhook-addresses one more time

#

Hmm, the webhook entpoint address and secret key for stripe is set properly

#

If I open the address from the console, where Stripe CLI is running, the server is triggered

main flame
#

Can you confirm that the server is receiving and handling any webhook request? For example, by logging a message?

pastel dune
#

The endpoint secret for local testing should be the one displayed in the console, after running the command
stripe listen --forward-to *address*
am I right?

main flame
#

Yes

pastel dune
#

I'm going to log the two cases, where the server gives 400 back

#

OK, the error happens on the deserialization of the stripe object

#

Therefore I use the standard stripe code-snippet before the switch-case statement for handling the event, to deserialize the stripeobject

#

For some reason the dataObjectDeserializer.getObject().isPresent() is false, and dataObjectDeserializer.getObject() has the value Optional.empty

#

So basically the data coming in is empty

plain stone
#

๐Ÿ‘‹ taking over for my colleague. Let me catch up.

pastel dune
#

Hello

plain stone
#

would you mind sharing your code please?

pastel dune
#

The code of the webhook

#

?

plain stone
#

yes please

pastel dune
#

I use the stripe standard code snippet from setting up the webhook:

        Event event = null;

        // Verify webhook signature and extract the event.
        // See https://stripe.com/docs/webhooks/signatures for more information.
        try {
            event = Webhook.constructEvent(payload, header, ENDPOINT_SECRET);
        } catch (JSONException | SignatureVerificationException e) {
            // Invalid payload or signature
            response.setStatus(400);
            return "";
        }

        EventDataObjectDeserializer dataObjectDeserializer = event.getDataObjectDeserializer();
        StripeObject stripeObject;
        if (dataObjectDeserializer.getObject().isPresent()) {
            stripeObject = dataObjectDeserializer.getObject().get();
        } else {
            // Deserialization failed, probably due to an API version mismatch.
            // Refer to the Javadoc documentation on `EventDataObjectDeserializer` for
            // instructions on how to handle this case, or return an error here.
            response.setStatus(400);
            return "";
        }```
#

The error happening below, beacuseif (dataObjectDeserializer.getObject().isPresent()) is false

#

If I print out dataObjectDeserializer.getObject(), it has the value Optional.empty

plain stone
#

ok could you please log the event after this line:
event = Webhook.constructEvent(payload, header, ENDPOINT_SECRET);

pastel dune
#

One second please, I also check the API version

plain stone
#

could you also log the payload?

pastel dune
#

It must be because of a wrong API version, I think

plain stone
#

what version of the Java SDK are you using?

pastel dune
#

In the dashboard 2022-08-01 is set

#

The Java SDK Version is 20.120.0

#

This is the one I used on our old account

plain stone
#

you need to update to v.21.x

#

each Java SDK major version is bound to a Stripe API version

#

meaning that the 20.x is pinned to API version 2020-08-27

pastel dune
#

OK, changed the version to 21.15.0

plain stone
#

could you rerun your tests?

pastel dune
#

Yes, now it is working

#

Thank you very much.

plain stone
#

no worries ๐Ÿ™‚

#

let me know if you need any more help

pastel dune
#

A newer version has some major changes, as i saw

plain stone
#

yes exactly

pastel dune
#

If I would use it, i must make also some major changes on our server

#

How long is 21.15.0 supported?

#

As I saw some functions, which I need and use now, doesn't even exists any more

plain stone
#

v21.x is still a supported and very widely used version since API version 2022-08-01 hasn't been around for a long while

pastel dune
#

OK, so I don't have to worry for a while?

plain stone
#

there will be updates on v21 for sure (e.g. there's a v21.16.0-beta.1) so keep an eye on the changelog to know when you might be interested in updating minor versions

#

and you wouldn't need to change the major version unless you are planning on upgrading the API version from your dashboard

#

you might be interested in upgrading your Stripe API version if you see features in the changelog(https://stripe.com/docs/changelog) that you would benefit from

Keep track of every change to the Stripe API.

pastel dune
#

A major problem for us in the new version is for example: I can't get the charges from a payment intent anymore with paymentIntent.getCharges()

#

OK, good to know, thank you very much!