#jinliang
1 messages ยท Page 1 of 1 (latest)
๐ happy to help
you can update using price_data https://stripe.com/docs/api/subscriptions/update#update_subscription-items-price_data
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
unfortunately this requires an already created product
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
you can reuse inline products created before
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());
.setProduct(subscription.getItems().getData().get(0).getPrice().getProduct())
this is not possible if the product was created as inline
We don't want to create products and maintain lists, is there any other way?
the only other way is to create the product before updating the subscription
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Can I create temporary products?