feat: notify supplier and client after payment is done

This commit is contained in:
2023-07-19 21:01:35 +02:00
parent b426a36570
commit e80e75cb8c
9 changed files with 161 additions and 39 deletions

View File

@@ -102,18 +102,22 @@ func (s *RestServer) onNotification(ctx context.Context, notifChan chan domain.N
order.Block = notif.BlockHash
order.Tx = notif.Tx
if err := s.orderSrv.OrderCompleted(ctx, order); err != nil {
order, err = s.orderSrv.OrderCompleted(ctx, order)
if err != nil {
log.Println("OrderCompleted:", err)
continue
}
// Send email to client and provider
if err := s.mailSrv.SendProviderConfirm(mail.SendOK{
TxID: order.Tx,
BlockHash: order.Block,
DocHash: "",
To: "doc.Email",
Tx: order.Tx,
Block: order.Block,
Amount: order.Amount,
ExplorerUrl: s.btcService.Explorer(order.Tx),
CustomerID: order.ClientID,
OrderID: order.OrderID,
Timestamp: order.PaidAt,
To: order.Email,
}); err != nil {
log.Println("error while send confirm email:", err)
continue