Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

158
Visualizações
nodejs - how to handle payment

Background:
I am working on making nodejs function for payment using stripe.

My clients would have their own reward point, which can turn into cash dollar for payment

Current Design
Customer Table(mySQL)

-id: string(primary key)
-rewardPoints: int

Therefore I am working on 2 api seperately.

/transaction/debit-points 
   -this api is used to debit the reward point of clients when they want to turn it into cash dollar(debit the rewardPoints in Customer table)

/payment
   -this api will use stripe api to handle some credit card payment etc

Example
Let's say 100 reward points can turn into $1 cash dollar

Customer A is going to settle payment which is $200.
Customer A have 1000 reward points and want to turn all of it into cash dollar in this payment.

At first, I will use /transaction/debit-points to debit all 1000 reward points for the customer, and then use /payment to settle the payment.

1. /transaction/debit-points
2. /payment (run if /transaction/debit-points is successful)

If /payment fails, I want to reverse the effect of /transaction/debit-points, is it possible to do it in nodejs?

Or is there any better way?

over 4 years ago · Santiago Trujillo
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda