Reputation: 6011
It's easy to get a customer's current subscriptions
const stripe = require('stripe')(stripeKey);
// ...
let stripeCustomer = await stripe.customers.retrieve(customerId);
// stripeCustomer.subscriptions.data now contains an array of current subscriptions
But expired/canceled subscriptions are not in this array, and the only way to get subscriptions seems to be with their ID (doc).
Surely there is a way to get a customer's expired subscriptions with just that customer's ID?
(I'm using Node.js, but that's not very important.)
Upvotes: 0
Views: 1630
Reputation: 6011
Turns out, there is a way to get subscriptions using a customer's ID.
let stripeSub = await stripe.subscriptions.list({customer: customerId});
To get canceled subscriptions, simply add status: "canceled"
let stripeSub = await stripe.subscriptions.list({customer: customerId, status: "canceled"});
list
is documented too: stripe docs.
Upvotes: 2