stripe / stripe-java

Java library for the Stripe API.

Home Page:https://stripe.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

View Subscriptions from Customer.retrieve properly

brr53 opened this issue · comments

commented

Describe the bug

Current Customer.retrieve gives null for subscriptions

To Reproduce

Run Customer.retrieve with customerid that has a subscription and print the toString() of the object. It will have null subscription.

It's due to Stripe-Version: 2022-11-15 that the library uses. It should use the default 2020-03-02 that the default cURL on stripe docs returns (https://stripe.com/docs/api/customers/retrieve)
Using 2022-11-15 gives null subscription even via cURL.

I fixed it by manually setting

var reqOptBuilder = builder();
unsafeSetStripeVersionOverride(reqOptBuilder, "2020-03-02");

Expected behavior

Fetching customer with subscription should display the subscription instead of null.

Code snippets

No response

OS

win

Java version

11

stripe-java version

v20.24.0

API version

2022-11-15

Additional context

No response

@brr53 The stripe-node library uses the most recent API version by default which is expected. We release newer API versions that are better overall in terms of features, design, latency, etc. We have no plan to pin the library to an older API version since that would mean the newer version are less reliable.

If you want to use an older API version, you are definitely allowed to which is what your code seems to do. You're also able to use the Expand feature to expand the subscriptions property and get it as documented in that API version, or you can use the List Subscriptions API separately.

I'm going to close this issue as this is not a change we'll make in the library and you already found a viable workaround. I hope this helps explain why though.