chore(api): improve logging for polar webhook notifications

This commit is contained in:
isra el
2025-02-20 08:46:46 +03:00
parent 5d8dcf87dc
commit 107671840a
2 changed files with 12 additions and 2 deletions

View File

@@ -430,8 +430,10 @@ export class BillingService {
async storePolarWebhookPayload(payload: any) {
const userId = payload.data?.metadata?.userId || payload.data?.userId
const eventType = payload.type
const name = payload.data?.customer?.name
const email = payload.data?.customer?.email
const name = payload.data?.customer?.name || payload.data?.customerName
const email = payload.data?.customer?.email || payload.data?.customerEmail
const productId = payload.data?.product?.id || payload.data?.productId
const productName = payload.data?.product?.name || payload.data?.productName
await this.polarWebhookPayloadModel.create({
userId,
@@ -439,6 +441,8 @@ export class BillingService {
name,
email,
payload,
productId,
productName,
})
}
}

View File

@@ -19,6 +19,12 @@ export class PolarWebhookPayload {
@Prop({ type: Object })
payload: Record<string, any>
@Prop()
productId: string
@Prop()
productName: string
}
export const PolarWebhookPayloadSchema = SchemaFactory.createForClass(PolarWebhookPayload)