Skip to content

Commit

Permalink
added payment pending flag
Browse files Browse the repository at this point in the history
  • Loading branch information
elraphty committed Oct 22, 2024
1 parent 6c29afa commit c5b4577
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 2 additions & 0 deletions db/structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,7 @@ type Bounty struct {
CodingLanguages pq.StringArray `gorm:"type:text[];not null default:'[]'" json:"coding_languages"`
PhaseUuid *string `json:"phase_uuid"`
PhasePriority *int `json:"phase_priority"`
PaymentPending bool `gorm:"default:false" json:"payment_pending"`
}

// Todo: Change back to Bounty
Expand Down Expand Up @@ -427,6 +428,7 @@ type NewBounty struct {
CodingLanguages pq.StringArray `gorm:"type:text[];not null default:'[]'" json:"coding_languages"`
PhaseUuid string `json:"phase_uuid"`
PhasePriority int `json:"phase_priority"`
PaymentPending bool `gorm:"default:false" json:"payment_pending"`
}

type BountyOwners struct {
Expand Down
20 changes: 19 additions & 1 deletion handlers/bounty.go
Original file line number Diff line number Diff line change
Expand Up @@ -656,14 +656,32 @@ func (h *bountyHandler) MakeBountyPayment(w http.ResponseWriter, r *http.Request
msg["msg"] = "keysend_success"
msg["invoice"] = ""

socket, err := h.getSocketConnections(request.Websocket_token)
if err == nil {
socket.Conn.WriteJSON(msg)
}
} else if v2KeysendRes.Status == db.PaymentPending {
// Send payment status
log.Printf("[bounty] V2 Status is pending: %s", v2KeysendRes.Status)
bounty.Paid = false
bounty.PaymentPending = true
bounty.PaidDate = &now
bounty.Completed = true
bounty.CompletionDate = &now
paymentHistory.Status = true

h.db.ProcessBountyPayment(paymentHistory, bounty)

msg["msg"] = "keysend_pending"
msg["invoice"] = ""

socket, err := h.getSocketConnections(request.Websocket_token)
if err == nil {
socket.Conn.WriteJSON(msg)
}
} else {
// Send payment status
log.Printf("[bounty] V2 Status Was not completed: %s", v2KeysendRes.Status)
paymentHistory.Status = false

h.db.AddPaymentHistory(paymentHistory)

Expand Down

0 comments on commit c5b4577

Please sign in to comment.