#Dooing-customer-sub

1 messages · Page 1 of 1 (latest)

tight bane
echo canyon
#

list? isnt it rather retrieve?

#

Subscription.retrieve(subscriptionId, retrieveParams, requestOptions);

#

And then I probably need 1-2 extends for the price and product?

#

SubscriptionRetrieveParams retrieveParams = SubscriptionRetrieveParams.builder()
.addExpand("items.data.plan.product")
.build();
Subscription subscription = retrieveSubscription(stripeSubscriptionId, retrieveParams);

#

?

tight bane
#

You'd use the retrieve method if you have the sub_xxx ID

#

You can't pass customer to retrieve

#

And that would only return a single object, where as the customer could have multiple subscriptions

tight bane
echo canyon
#

ok. understood, thanks.

#

subscriptionCollection.getData()

#

will this return object be NULL when there isno subscription?

#

or can I call get Data to retrieve the list of subscriptions in any case?

#

Again, will this list be empty or null, when there is no subscription?
In our case, it would just always be just one subscription per customer, at least at this point

#

List<Subscription> subscriptions = subscriptionCollection.getData();
if (subscriptions.isEmpty()) {
return null;
}
Subscription subscription = subscriptions.get(0);
SubscriptionItem subscriptionItem = subscription.getItems().getData().get(0);
String priceId = subscriptionItem.getPrice().getId();
String productId = subscriptionItem.getPlan().getProduct();

#

It seems, get plan.getProduct is the only way to retrieve the product id? Seems still legacy?

tight bane
echo canyon
#

SubscriptionCollection subscriptionCollection = Subscription.list(SubscriptionListParams.builder()
.addExpand("items.data.price.product")
.setCustomer(stripeCustomerId)
.build());

#

like so?

thorn mulch
#

Hey, Taking over for my colleague. Let me catch up.

thorn mulch