Skip to content

Commit

Permalink
setting fixed number of credits
Browse files Browse the repository at this point in the history
  • Loading branch information
mauriciomb97 committed Oct 15, 2024
1 parent f6baa25 commit 4e4a1c9
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions server/utils/services/checkouts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ export class StripeCheckoutService
const [userDb] = await this.tx
.update(Users)
.set({
imageCredits: sql`${Users.imageCredits} + ${value_images}`,
trainingCredits: sql`${Users.trainingCredits} + ${value_models}`,
imageCredits: `${value_images}`,

Check failure on line 107 in server/utils/services/checkouts.ts

View workflow job for this annotation

GitHub Actions / build

Type 'string' is not assignable to type 'number | SQL<unknown> | undefined'.
trainingCredits: `${value_models}`,

Check failure on line 108 in server/utils/services/checkouts.ts

View workflow job for this annotation

GitHub Actions / build

Type 'string' is not assignable to type 'number | SQL<unknown> | undefined'.
idStripe: `${session.customer}`
})
.where(eq(Users.id, user_id))
Expand All @@ -124,15 +124,15 @@ export class StripeCheckoutService
console.error(`No subscription found for session ${invoice.id}`);
return;
}

const productMetadata = await this.getMetadataProduct(invoice.subscription as string);
const value_images = productMetadata.monthly_images || productMetadata.yearly_images;
const value_models = productMetadata.monthly_models || productMetadata.yearly_models;
const [userDb] = await this.tx
.update(Users)
.set({
imageCredits: sql`${Users.imageCredits} + ${value_images}`,
trainingCredits: sql`${Users.trainingCredits} + ${value_models}`,
imageCredits: `${value_images}`,

Check failure on line 134 in server/utils/services/checkouts.ts

View workflow job for this annotation

GitHub Actions / build

Type 'string' is not assignable to type 'number | SQL<unknown> | undefined'.
trainingCredits: `${value_models}`,

Check failure on line 135 in server/utils/services/checkouts.ts

View workflow job for this annotation

GitHub Actions / build

Type 'string' is not assignable to type 'number | SQL<unknown> | undefined'.
})
.where(eq(Users.idStripe, invoice.customer as string))
.returning();
Expand Down

0 comments on commit 4e4a1c9

Please sign in to comment.