showing more info for stripe members, showing data in proper table

This commit is contained in:
metacryst
2026-03-06 07:58:03 -06:00
parent 4061e86ce7
commit b22b12a7a5
6 changed files with 112 additions and 38 deletions

View File

@@ -8,7 +8,6 @@ export default class PaymentsHandler {
static async finishConnectSetup(req, res) {
const { code, networkId } = req.body;
console.log("onboarded", networkId)
const response = await stripe.oauth.token({
grant_type: "authorization_code",
@@ -54,10 +53,26 @@ export default class PaymentsHandler {
throw new Error("Can't get customers for account that doesn't exist!")
}
const customers = await stripe.customers.list(
{ limit: 100 },
{ limit: 100, expand: ['data.subscriptions'] },
{ stripeAccount: network.stripeAccountId }
);
return customers
console.log(customers)
return customers.data.map(customer => ({
id: customer.id,
email: customer.email,
created: customer.created,
name: customer.name,
phone: customer.phone,
city: customer.address?.city,
subscriptions: customer.subscriptions?.data.map(sub => ({
id: sub.id,
status: sub.status,
amount: sub.items.data[0]?.price.unit_amount / 100, // converts cents to dollars
currency: sub.items.data[0]?.price.currency,
interval: sub.items.data[0]?.price.recurring?.interval
}))
}))
}
static async newSubscription(req, res) {