Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

failure payment cases are not handled #1

Open
SuhailAhmed2 opened this issue Apr 6, 2024 · 1 comment
Open

failure payment cases are not handled #1

SuhailAhmed2 opened this issue Apr 6, 2024 · 1 comment

Comments

@SuhailAhmed2
Copy link

if there is payment failure, then we shouldt proceed with reservation
apps/reservations/src/reservations.service.ts
lines create charge doesnt checks for failure
const payemntResponse = await lastValueFrom(this.paymentService.send('create-charge', { ...createReservationDto.charge, email: user.email }))

  const newReservation = await this.reservationsRepository.create({
    ...createReservationDto,
    invoiceId: payemntResponse.id,
    userId: user._id,
    timestamp: new Date(),
    ...createReservationDto.event
  }, { session })

similarly in payemnt service

createCharge({ card, amount, email }: PaymentsCreateChargeDto) {
const paymentIntent = await this.stripe.paymentIntents.create({
amount: amount * 100,
payment_method_types: ['card'],
currency: 'usd',
});

this.notificationsClient.emit(NOTIFICATION_EVENT, {
  email,
  text: `Your payment of $${amount} has completed successfully.`,
});

return paymentIntent;
@mohamedsalem331
Copy link
Owner

@SuhailAhmed2 you right, i haven't check this repo in a while i should've added validation & check for payment failure i guess throw some exception and rollback transaction.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants