Skip to content

Commit

Permalink
Merge pull request #1886 from stakwork/feat/add_failed_rests
Browse files Browse the repository at this point in the history
PR: Added Logs To See V2 Payment Status
  • Loading branch information
elraphty authored Oct 14, 2024
2 parents 94faabf + 0d033d4 commit 273d857
Showing 1 changed file with 24 additions and 18 deletions.
42 changes: 24 additions & 18 deletions handlers/bounty.go
Original file line number Diff line number Diff line change
Expand Up @@ -624,24 +624,25 @@ func (h *bountyHandler) MakeBountyPayment(w http.ResponseWriter, r *http.Request
return
}

log.Printf("[bounty] V2 Status After Making Bounty V2 Payment: amount: %d, pubkey: %s, route_hint: %s is : %s", amount, assignee.OwnerPubKey, assignee.OwnerRouteHint, v2KeysendRes.Status)

now := time.Now()
paymentHistory := db.NewPaymentHistory{
Amount: amount,
SenderPubKey: pubKeyFromAuth,
ReceiverPubKey: assignee.OwnerPubKey,
WorkspaceUuid: bounty.WorkspaceUuid,
BountyId: id,
Created: &now,
Updated: &now,
Status: true,
PaymentType: "payment",
Tag: v2KeysendRes.Tag,
PaymentStatus: v2KeysendRes.Status,
}

// if the payment has a completed status
if v2KeysendRes.Status == db.PaymentComplete {
now := time.Now()

paymentHistory := db.NewPaymentHistory{
Amount: amount,
SenderPubKey: pubKeyFromAuth,
ReceiverPubKey: assignee.OwnerPubKey,
WorkspaceUuid: bounty.WorkspaceUuid,
BountyId: id,
Created: &now,
Updated: &now,
Status: true,
PaymentType: "payment",
Tag: v2KeysendRes.Tag,
PaymentStatus: v2KeysendRes.Status,
}

bounty.Paid = true
bounty.PaidDate = &now
bounty.Completed = true
Expand All @@ -656,7 +657,12 @@ func (h *bountyHandler) MakeBountyPayment(w http.ResponseWriter, r *http.Request
if err == nil {
socket.Conn.WriteJSON(msg)
}
} else { // Send payment status
} else {
// Send payment status
log.Printf("[bounty] V2 Status Was not completed: %s", v2KeysendRes.Status)

h.db.AddPaymentHistory(paymentHistory)

log.Println("Keysend payment not completed ===")
msg["msg"] = "keysend_error"
msg["invoice"] = ""
Expand All @@ -669,7 +675,7 @@ func (h *bountyHandler) MakeBountyPayment(w http.ResponseWriter, r *http.Request
return
}
} else { // Send Payment error
log.Println("Keysend payment error ===")
log.Println("Keysend payment error: Failed to send ===")
msg["msg"] = "keysend_error"
msg["invoice"] = ""

Expand Down

0 comments on commit 273d857

Please sign in to comment.