Skip to content

Commit

Permalink
Merge pull request #1947 from stakwork/fix/payment_error_status
Browse files Browse the repository at this point in the history
PR: added new error status, and check for failed payments
  • Loading branch information
elraphty authored Nov 13, 2024
2 parents 567f321 + 4b6b069 commit 94a8b97
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ node_modules
yarn.lock

frontend/app/coverage
cypress/screenshots
cypress/screenshots
coverage.out
1 change: 0 additions & 1 deletion db/test_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ func InitTestDB() {
db.AutoMigrate(&WorkspaceUsers{})
db.AutoMigrate(&WorkspaceUserRoles{})
db.AutoMigrate(&Bot{})
db.AutoMigrate(&WfRequest{})

people := TestDB.GetAllPeople()
for _, p := range people {
Expand Down
10 changes: 8 additions & 2 deletions handlers/bounty.go
Original file line number Diff line number Diff line change
Expand Up @@ -720,8 +720,8 @@ func (h *bountyHandler) MakeBountyPayment(w http.ResponseWriter, r *http.Request
// Send payment status
log.Printf("[bounty] V2 Status is pending: %s", v2KeysendRes.Status)
bounty.Paid = false
bounty.PaymentPending = true
bounty.PaymentFailed = false
bounty.PaymentPending = true
bounty.PaidDate = &now
bounty.Completed = true
bounty.CompletionDate = &now
Expand Down Expand Up @@ -761,7 +761,7 @@ func (h *bountyHandler) MakeBountyPayment(w http.ResponseWriter, r *http.Request
h.db.UpdateBounty(bounty)

log.Println("Keysend payment not completed ===")
msg["msg"] = "keysend_error"
msg["msg"] = "keysend_failed"
msg["invoice"] = ""

socket, err := h.getSocketConnections(request.Websocket_token)
Expand Down Expand Up @@ -970,6 +970,12 @@ func (h *bountyHandler) UpdateBountyPaymentStatus(w http.ResponseWriter, r *http
return
}

if bounty.PaymentFailed {
w.WriteHeader(http.StatusMethodNotAllowed)
json.NewEncoder(w).Encode("Bounty payment has failed, have to make payment again")
return
}

payment := h.db.GetPaymentByBountyId(bounty.ID)

if payment.Tag != "" {
Expand Down
2 changes: 1 addition & 1 deletion handlers/features.go
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ func (oh *featureHandler) GetFeatureStories(w http.ResponseWriter, r *http.Reque
return
}

log.Panicf("Webhook Feature Output", featureStories.Output)
log.Println("Webhook Feature Output", featureStories.Output)

log.Println("Webhook Feature Stories === ", featureStories.Output.Stories)

Expand Down

0 comments on commit 94a8b97

Please sign in to comment.