stripe/stripe-java

`latest_charge` field is NULL even though there is a charge

cmboult opened this issue · 3 comments

Describe the bug

We're seeing some weird behaviour with the latest_charge field
We receive a webhook for a payment_intent.succeeded event, put the event ID on a queue and then do a lookup using PaymentIntent.retrieve for the given ID but latest_charge is NULL. If I do the same call manually a few seconds later latest_charge is populated... is this expected behaviour? Viewing the webhook event in the dashboard, I can see the charge is populated there too.

the deprecated charges field (using an older version of the library) always had the latest charge populated when doing this same lookup.

To Reproduce

  1. create a payment intent
  2. confirm intent
  3. receive payment_intent.succeeded webhook event
  4. immediately lookup payment intent using PaymentIntent.retrieve
  5. observe latest_charge is NULL

Expected behavior

latest_charge is populated

Code snippets

No response

OS

macOS

Java version

Java 11

stripe-java version

v22.1.0

API version

2022-11-09

Additional context

No response

@cmboult this doesn't look like a bug with the stripe-java library itself in this case and more something to do with either your integration or the call you make to the API. Please work with our support team directly for help and they can investigate what is going on. Please make sure to give them clear examples of Event id evt_123 and Charge id ch_123 so that they can investigate for you.

You can contact them here: https://support.stripe.com/contact

this works fine in versions before v22. charges had the latest charge populated correctly

Please work directly with our support team. This is not a stripe-java issue. The fact that it works fine before is not really relevant since before it used a different API version and the API behaved differently. stripe-java mostly deserializes the JSON response into a resource, it won't decide to "hide" latest_charge. If you get it null then it's either because you retrieve the PaymentIntent before it's successful or because there's an issue with the API. So sharing all the information you have is going to be what's needed here.