#jinliang

1 messages ยท Page 1 of 1 (latest)

coral deltaBOT
cerulean kite
#

๐Ÿ‘‹ happy to help

#

unfortunately this requires an already created product

frozen fable
#

When updating a subscription, these is a exception: com.stripe.exception.InvalidRequestException: The product prod_NkoUPsbL0t0uom is marked as inactive, and thus no new subscriptions can be create to any plans of this product

cerulean kite
#

you can reuse inline products created before

frozen fable
#

Yes, but these is an exception also, here is the code:

#

SubscriptionUpdateParams.Item.PriceData priceData = SubscriptionUpdateParams.Item.PriceData.builder()
.setUnitAmount(price.longValue())
.setCurrency(brandhqConfig.getCurrency())
.setProduct(subscription.getItems().getData().get(0).getPrice().getProduct())
.setRecurring(recurring.build())
.build();
SubscriptionUpdateParams.Item item = SubscriptionUpdateParams.Item.builder()
.setId(subscription.getItems().getData().get(0).getId())
.setPriceData(priceData)
.setQuantity(1L)
.build();
SubscriptionUpdateParams.Builder paramBuilder = SubscriptionUpdateParams.builder()
.setCancelAtPeriodEnd(false)
.setProrationBehavior(SubscriptionUpdateParams.ProrationBehavior.CREATE_PRORATIONS)
.addItem(item);
paramBuilder.setTrialEnd(trialEndAt.getTime());
subscription.update(paramBuilder.build());

cerulean kite
#

.setProduct(subscription.getItems().getData().get(0).getPrice().getProduct())

#

this is not possible if the product was created as inline

frozen fable
#

We don't want to create products and maintain lists, is there any other way?

cerulean kite
#

the only other way is to create the product before updating the subscription

frozen fable
#

Can I create temporary products?