#ritzpar_java-sdk-expanding-charge

1 messages · Page 1 of 1 (latest)

unreal rampartBOT
#

👋 Welcome to your new thread!

⏲️ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.

⏱️ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.

🔗 This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1351946480516071546

📝 Have more to share? Add more details, code, screenshots, videos, etc. below.

fervent zinc
#

Hi 👋

What version of the Java SDK are you using?

honest tendon
#

Hello

#

Am I encountering this problem because i queried the object too late ?

fervent zinc
#

That shouldn't matter. Can you tell me what version of the SDK you are using?

honest tendon
#

version 28.2.0

fervent zinc
#

Does the paymentIntent object you are working with return the Charge ID when you print out paymentIntent.latest_charge?

honest tendon
#

checking

#

yes, I see it when the object is converted to String. "latest_charge": "ch_3R3qNqCVUvdI84gC07v6S7mp",

fervent zinc
#

So it definitely should work

honest tendon
#

I see the value when payment intent's toString() method is called but when I evaluate paymentIntent.getLatestChargeObject()
in eclipse it returns null

#

I'll try upgrading to another version of stripe-java library

#

can you confirm maven coordinate for stripe's official java API ? It is <dependency>
<groupId>com.stripe</groupId>
<artifactId>stripe-java</artifactId>
<version>${stripe-java}</version>
</dependency> ?

fervent zinc
#

Okay the current version is 28.4.0 and that is still on the same API version as the version you are using

#

This should work.

honest tendon
#

trying it now

#

still fails
java.lang.NullPointerException: Cannot invoke "com.stripe.model.Charge.getBalanceTransactionObject()" because the return value of "com.stripe.model.PaymentIntent.getLatestChargeObject()" is null

#

Ok, I'll see if i can find the problem. Thanks TTL.

fervent zinc
#

Okay hold on, the latest charge will only return a String unless you have expanded the Charge object.

#

So the java SDK doesn't have the necessary data to return a Charge object.

honest tendon
#

yeah, I noticed that this.latestCharge.getExpanded() was returning a null value. So I'm processing payment intent objects sent by Stripe's webhook.. ok I need to retrieve the object again

#

You can’t receive webhook events with properties auto-expanded. Objects sent in events are always in their minimal form. To access nested values in expandable properties, you must retrieve the object in a separate call within your webhook handler.

#

I'll make the necessary changes. thanks.

fervent zinc
#

Correct. You will need to make another request to ensure you get an expanded Charge object. Let me know if that works for you.