#nicefellow1234
1 messages · Page 1 of 1 (latest)
hello! can you share an example subscription id?
Do you mean a subscription ID from the production account?
from whichever account you're not getting the expected response from
sub_1MI7QNJy0xivVYK74RQz98Kp
your subscription is charging the default payment method set on the Customer which is invoice_settings.default_payment_method [0]. So you should expand the customer.invoice_settings.default_payment_method instead
[0] https://stripe.com/docs/api/customers/update#update_customer-invoice_settings-default_payment_method
Thank you, it worked now.
$subscriptions = $stripe->subscriptions->search([
'query' => "status:'active'",
'expand' => ['data.customer.invoice_settings.default_payment_method']
]);
Is there any other way to do it?
what's the context? like what's wrong with the current way?
I mean it's way too long referencing too many objects in there.
There is an another issue I am seeing around 600+ active subscriptions in account while the endpoint only returns around 11 subscriptions.
i'm not exactly following - you use expand to reduce the number of requests that your application needs to make.
But if you want, you can always loop through the subscriptions, and make a subsequent request to retrieve the customer and expand invoice_setting.default_payment_method
That would be definitely bad.
hmm, can you share the request id for your search request?
where you get only 11 subscriptions
Where should I be able to see that? Can you explain what do you mean request ID?
Here it is: req_wknuniapx8dC5W
Can you also confirm if subscriptions with active status only includes subscriptions which are active and not in trial?
https://stripe.com/docs/api/subscriptions/object#subscription_object-status
A subscription that is currently in a trial period is trialing and moves to active when the trial period is over.
so yes, active doesn't cover subscriptions in a trial period
just checking, but did you paginate?
Ok, sure. Thanks for confirming that.
I checked both list endpoint and search endpoint both are returning 11 subscriptions records. I have not provided any extra params. I am not aware about pagination.
$subscriptions = $stripe->subscriptions->search([
'query' => "status:'active'",
'expand' => ['data.customer.invoice_settings.default_payment_method']
]);
the limit for the number of subscriptions returned in that request is 11, if there's more than that, you need to paginate. See - https://stripe.com/docs/api/pagination/auto
Ok, sure.
Thank you it worked now
$counter = 1;
foreach ($subscriptions->autoPagingIterator() as $subscription) {
$counter++;
$card = $subscription->customer->invoice_settings->default_payment_method->card;
echo 'Subscription ID: '.$subscription->id." ".$counter."\n";
echo 'Card Last4: '.$card->last4."\n";
echo 'Card Bin: '.$card->iin."\n\n\n";
}
I like it alot being able to talk to devs directly without any support guys present in between. 🙂
It's very productive and can save alot of precious time.