#meshpaul-prices
1 messages · Page 1 of 1 (latest)
Hi, you can't delete a price that has been used. You can make it inactive so it's not used again: https://stripe.com/docs/api/prices/update#update_price-active
I understand this. So do I am trying to get all products and for each product I get default price object ... Then I try to make it inactive using
Ex.
var price = product.getDefaultPriceObject()
price.udate(PriceUpdateParams.builder().setActive(false).build())
but I don't see any POST v1/prices/ calls in the log
so how to set it inactive using Java API
👋 stepping in
Looks like you are mostly doing this correctly. If you aren't seeing any logs come through at all then you need to check your server for errors.
I a literally doing this interactively in test mode in a test case...
Ok let me see it could be that default PaymentObject is null
this is why it's not making the api call
or rather PriceObject
I guess I have to query Prices by Ids then
You do need the Price ID, yes.
So to my point when invoking product.getDefaultPriceObject() using Java API I am getting null and the expectation is to get Price object... so there is a bug
@pastel quest do you have an example Price/Product I can look at? Like did you explicitly make it the default Price on that Product?
Hmm
Also recommend migrating to our StripeClient implementation which is better than using those instance methods. More details on https://github.com/stripe/stripe-java/wiki/Migration-guide-for-v23#stripeclient
But my gut right now is: you think you have a default Price, but you don't. It's a special/separate feature. You likely just have a Product, and that Product has one (or multiple) Price(s).
So what you want is to call the List Prices API instead (you can pass product: 'prod_123') to get the Price(s) and then update each one separately
Ok will do
Ok what I am getting is this
This price cannot be archived because it is the default price of its product.; request-id: req_GN2iHwSecDMRVb
com.stripe.exception.InvalidRequestException: This price cannot be archived because it is the default price of its product.; request-id: req_GN2iHwSecDMRVb
so the Products can't be deleted
it looks like they stay there forever
Issue is that we created them in test mode
and we didn't fully understood this
you could delete all Test data if that really bothers you!
how
https://stripe.com/docs/test-mode#delete-test-data
But note that it deletes everything in Test mode