telebirr service payment verification fix
This commit is contained in:
parent
49d0e73b6f
commit
13f77ba445
|
|
@ -230,6 +230,8 @@ func (s *TelebirrService) HandleTelebirrPaymentCallback(ctx context.Context, pay
|
|||
|
||||
if transfer.Status != string(domain.PaymentStatusPending) {
|
||||
return fmt.Errorf("payment not pending, status: %s", transfer.Status)
|
||||
} else if transfer.Verified == true {
|
||||
return fmt.Errorf("payment already verified")
|
||||
}
|
||||
|
||||
if payload.TradeStatus != "Completed" {
|
||||
|
|
@ -241,17 +243,24 @@ func (s *TelebirrService) HandleTelebirrPaymentCallback(ctx context.Context, pay
|
|||
// return fmt.Errorf("invalid callback signature: %w", err)
|
||||
// }
|
||||
|
||||
if err := s.transferStore.UpdateTransferStatus(ctx, transfer.ID, string(domain.PaymentStatusCompleted)); err != nil {
|
||||
return fmt.Errorf("failed to update transfer status: %w", err)
|
||||
}
|
||||
|
||||
// 4. Parse amount
|
||||
amount, err := strconv.ParseFloat(payload.TotalAmount, 64)
|
||||
if err != nil {
|
||||
return fmt.Errorf("invalid amount format: %s", payload.TotalAmount)
|
||||
}
|
||||
|
||||
_, err = s.walletSvc.AddToWallet(ctx, transfer.SenderWalletID.Value, domain.Currency(amount), domain.ValidInt64{}, domain.TRANSFER_DIRECT, domain.PaymentDetails{}, fmt.Sprintf("Added %v to wallet for Telebirr payment", amount))
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to add amount to wallet: %w", err)
|
||||
}
|
||||
|
||||
if err := s.transferStore.UpdateTransferVerification(ctx, transfer.ID, true); err != nil {
|
||||
return fmt.Errorf("failed to update transfer verification: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user