diff --git a/bizmatch-server/src/drizzle/schema.ts b/bizmatch-server/src/drizzle/schema.ts index 8fb9115..b90185a 100644 --- a/bizmatch-server/src/drizzle/schema.ts +++ b/bizmatch-server/src/drizzle/schema.ts @@ -31,9 +31,8 @@ export const users = pgTable('users', { updated: timestamp('updated'), latitude: doublePrecision('latitude'), longitude: doublePrecision('longitude'), - stripeCustomerId: text('stripeCustomerId'), subscriptionId: text('subscriptionId'), - subscriptionPlan: subscriptionTypeEnum('subscriptionType'), + subscriptionPlan: subscriptionTypeEnum('subscriptionPlan'), // embedding: vector('embedding', { dimensions: 1536 }), }); diff --git a/bizmatch-server/src/mail/templates/subscriptionConfirmation.hbs b/bizmatch-server/src/mail/templates/subscriptionConfirmation.hbs index b0d7ed5..dde877e 100644 --- a/bizmatch-server/src/mail/templates/subscriptionConfirmation.hbs +++ b/bizmatch-server/src/mail/templates/subscriptionConfirmation.hbs @@ -60,7 +60,7 @@
Your subscription details are as follows:
-{{#if (eq subscriptionPlan "professional")}}Professional (CPA, Attorney, Title Company) Plan{{else if (eq subscriptionPlan "broker")}}Business Broker Plan{{/if}}
+{{#if (eq subscriptionPlan "professional")}}Professional Plan (CPA, Attorney, Title Company, Surveyor, Appraiser){{else if (eq subscriptionPlan "broker")}}Business Broker Plan{{/if}}
If you have any questions or need further assistance, please feel free to contact our support team at any time.
diff --git a/bizmatch-server/src/main.ts b/bizmatch-server/src/main.ts index d3f9216..0eff9f2 100644 --- a/bizmatch-server/src/main.ts +++ b/bizmatch-server/src/main.ts @@ -12,7 +12,7 @@ async function bootstrap() { origin: '*', //origin: 'http://localhost:4200', // Die URL Ihrer Angular-App methods: 'GET,HEAD,PUT,PATCH,POST,DELETE', - allowedHeaders: 'Content-Type, Accept, Authorization', + allowedHeaders: 'Content-Type, Accept, Authorization, x-hide-loading', }); //origin: 'http://localhost:4200', await app.listen(3000); diff --git a/bizmatch-server/src/models/db.model.ts b/bizmatch-server/src/models/db.model.ts index db7f987..ea1be25 100644 --- a/bizmatch-server/src/models/db.model.ts +++ b/bizmatch-server/src/models/db.model.ts @@ -157,10 +157,7 @@ export const UserSchema = z customerSubType: CustomerSubTypeEnum.optional().nullable(), created: z.date().optional().nullable(), updated: z.date().optional().nullable(), - stripeCustomerId: z.string().optional().nullable(), subscriptionId: z.string().optional().nullable(), - planActive: z.boolean().optional().nullable(), - planExpires: z.date().optional().nullable(), subscriptionPlan: SubscriptionTypeEnum.optional().nullable(), }) .superRefine((data, ctx) => { diff --git a/bizmatch-server/src/models/main.model.ts b/bizmatch-server/src/models/main.model.ts index 1e52697..363f3ae 100644 --- a/bizmatch-server/src/models/main.model.ts +++ b/bizmatch-server/src/models/main.model.ts @@ -322,10 +322,7 @@ export function createDefaultUser(email: string, firstname: string, lastname: st customerSubType: null, created: new Date(), updated: new Date(), - stripeCustomerId: null, subscriptionId: null, - planActive: false, - planExpires: null, subscriptionPlan: subscriptionPlan, }; } diff --git a/bizmatch-server/src/payment/payment.controller.ts b/bizmatch-server/src/payment/payment.controller.ts index 254700c..a59a6ea 100644 --- a/bizmatch-server/src/payment/payment.controller.ts +++ b/bizmatch-server/src/payment/payment.controller.ts @@ -21,7 +21,10 @@ export class PaymentController { const signature = req.headers['stripe-signature'] as string; try { - const event = await this.paymentService.constructEvent(req.body, signature); + // Konvertieren Sie den req.body Buffer in einen lesbaren String + const payload = req.body instanceof Buffer ? req.body.toString('utf8') : req.body; + const event = await this.paymentService.constructEvent(payload, signature); + // const event = await this.paymentService.constructEvent(req.body, signature); if (event.type === 'checkout.session.completed') { await this.paymentService.handleCheckoutSessionCompleted(event.data.object as Stripe.Checkout.Session); diff --git a/bizmatch-server/src/payment/payment.service.ts b/bizmatch-server/src/payment/payment.service.ts index 86a8613..f2f7ea7 100644 --- a/bizmatch-server/src/payment/payment.service.ts +++ b/bizmatch-server/src/payment/payment.service.ts @@ -43,6 +43,14 @@ export class PaymentService { const newCustomer = await this.stripe.customers.create({ email: checkout.email, name: checkout.name, + shipping: { + name: checkout.name, + address: { + city: '', + state: '', + country: 'US', + }, + }, }); customerId = newCustomer.id; } @@ -60,7 +68,6 @@ export class PaymentService { ], success_url: `${process.env.WEB_HOST}/success`, cancel_url: `${process.env.WEB_HOST}/pricing`, - // customer_email: checkout.email, customer: customerId, shipping_address_collection: { allowed_countries: ['US'], @@ -84,25 +91,29 @@ export class PaymentService { return this.stripe.webhooks.constructEvent(body, signature, process.env.STRIPE_WEBHOOK_SECRET!); } async handleCheckoutSessionCompleted(session: Stripe.Checkout.Session): Promise+ We regret to inform you that we have not yet received any response from our payment service provider regarding the status of your subscription. Please log in to the + website and check your subscription status under the Account menu. If you have any questions, please contact us at + support@bizmatch.net. +
+ } @else if(user && (user.subscriptionPlan==='professional' || user.subscriptionPlan==='broker')) { diff --git a/bizmatch/src/app/pages/success/success.component.ts b/bizmatch/src/app/pages/success/success.component.ts index e538537..2646f3c 100644 --- a/bizmatch/src/app/pages/success/success.component.ts +++ b/bizmatch/src/app/pages/success/success.component.ts @@ -16,7 +16,10 @@ import { map2User } from '../../utils/utils'; }) export class SuccessComponent { user: User; + maxAttemptsReached: boolean = false; // Neue Variable hinzufügen + constructor(private keycloakService: KeycloakService, private userService: UserService, private logService: LogService, private router: Router) {} + async ngOnInit() { let email = null; try { @@ -29,6 +32,7 @@ export class SuccessComponent { this.checkSubscriptionPlan(email, e.message); } } + async checkSubscriptionPlan(email: string, error?: string) { if (!email) { this.logService.log({ severity: 'error', text: `Unauthorized Access to Success Page ${error}` }); @@ -44,12 +48,13 @@ export class SuccessComponent { if (attempts >= maxAttempts) { clearInterval(intervalId); console.error('Max attempts reached'); + this.maxAttemptsReached = true; // Setze die Variable auf true, wenn die max. Versuche erreicht wurden return; } attempts++; - this.user = await this.userService.getByMail(email); + this.user = await this.userService.getByMail(email, true); if (this.user && this.user.subscriptionPlan) { clearInterval(intervalId); diff --git a/bizmatch/src/app/services/user.service.ts b/bizmatch/src/app/services/user.service.ts index 1bc4cc0..3005f07 100644 --- a/bizmatch/src/app/services/user.service.ts +++ b/bizmatch/src/app/services/user.service.ts @@ -1,4 +1,4 @@ -import { HttpClient } from '@angular/common/http'; +import { HttpClient, HttpHeaders } from '@angular/common/http'; import { Injectable } from '@angular/core'; import { lastValueFrom, Observable } from 'rxjs'; import urlcat from 'urlcat'; @@ -20,12 +20,19 @@ export class UserService { async save(user: User): Promise