merge: catch up with feature/helcim-plan-consolidation base

# Conflicts:
#	server/api/auth/member.get.js
#	server/api/members/update-contribution.post.js
#	tests/server/api/update-contribution.test.js
This commit is contained in:
Jennie Robinson Faber 2026-04-19 21:33:40 +01:00
commit 7704557f16
10 changed files with 160 additions and 9 deletions

View file

@ -165,6 +165,10 @@ export default defineEventHandler(async (event) => {
throw createError({ statusCode: 500, statusMessage: 'Subscription creation failed' })
}
const nextBillingDate = subscription.nextBillingDate
? new Date(subscription.nextBillingDate)
: null
// Update member in database
const member = await Member.findOneAndUpdate(
{ helcimCustomerId: body.customerId },
@ -176,6 +180,9 @@ export default defineEventHandler(async (event) => {
billingCadence: cadence,
subscriptionStartDate: new Date(),
status: 'active',
...(nextBillingDate && !Number.isNaN(nextBillingDate.getTime())
? { nextBillingDate }
: {}),
} },
{ new: true, runValidators: false }
)