Search code examples
stripe-payments

Stripe retrieve customer with related subscriptions (no plan name attached)


--in TEST MODE--
I am retrieving the customer with cus_xxxx
In order to avoid multiple API calls, i expand the customer object by requesting 'subscriptions' related to that customer ID

CURLOPT_POSTFIELDS => http_build_query([
        "expand[]" => 'subscriptions'
    ])

But the subscriptions object does not return the plan name, as it would when retrieving the product itself. https://docs.stripe.com/api/products/retrieve

 [id] => prod_Mxxxxxxx
..
 [name] => My plan Name

Should it be that way, or am i missing something?


Solution

  • I'd recommend listing Subscriptions with the Customer ID in the customer argument, which will yield the same list as the Customer's subscriptions, but this time you can expand[]=>'data.plan.product'and this way get the Product name.