#Clawfoot
1 messages · Page 1 of 1 (latest)
And when I print_r() the entire resulting $customers object, there is no 'subscriptions
' field
Hi,
That's expected, because there is no subscription field in the customer object:
https://stripe.com/docs/api/customers.. you can expand the fields that are marked as expandable in the documentation of a Stripe Object, like this one for example in Customer object:
https://stripe.com/docs/api/customers/object#customer_object-tax
You can list all customer's Subscriptions via this API instead:
https://stripe.com/docs/api/subscriptions/list#list_subscriptions-customer
I'm looking at this website
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
and in the 'More attributes' section
there is 'subscriptions'
saying that it is an expandable field
if it's not there, my followup question is, how can I get a list of subscription IDs from a single customer ID?
so, with your subscriptions API, I could basically fetch all subscriptions, loop over them, and stop on the one with the matching customer ID?
No you can filter by customerId when listing subscriptions
Ah yeah sorry, I was seeing other reference, so yeah you can expands it and fetch the customer's subscription using that too
can you share the customer Id ?
OK I see that the customer has this active subscription sub_1MLIshFtGvcbRuR6zTeKLTKo
Can you share the requestId of the API call you are doing please ?
I'm not sure how to get the requestID, can you give some more info on that please?
I can give code of what I'm doing, or the output $customer object
or the input secret client Stripe key?
yes of course, you can follow this article
https://support.stripe.com/questions/finding-the-id-for-an-api-request
req_CCevROuSGXjF9u
Thanks for sharing it looks like you are passing no query for this request, there isn't an expand param
probably the same thing, but I just ran it again
req_pDdLZzXrTW5ExT
and my code still looks like
$customer = \Stripe\Customer::retrieve(
$i_stripeCustomerID,
['expand' => ['subscriptions']]
);
ok let me do a quick test ...
thanks
I just did a test using this code and it works:
$stripe = new \Stripe\StripeClient(
'sk_test_....'
);
$output = $stripe->customers->retrieve(
'cus_N5TqsHRJLP4NDF',
['expand' => ['subscriptions']]
);
use your test secret key and try it
alright, I'll check it
req_7yrMn78uSgR9wd
that absolutely does work, so what's the difference? why doesn't the original syntax in PHP work?
should I switch? and not use
\Stripe\Stripe::setApiKey($stripeApiKeySecret);
or
$customer = \Stripe\Customer::retrieve(...)
Use the syntax that is documented in our official site:
https://stripe.com/docs/api/customers/retrieve?lang=php
ok I'll work with that, thanks so much for your help here
Np!