Skip to content

Commit

Permalink
Merge pull request #806 from stakwork/fix/payment_logs
Browse files Browse the repository at this point in the history
Fixed Deposit not reflecting bug
  • Loading branch information
elraphty authored Oct 9, 2023
2 parents c0228b3 + e1c2693 commit dad61e9
Showing 1 changed file with 2 additions and 15 deletions.
17 changes: 2 additions & 15 deletions handlers/invoiceCron.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ func InitInvoiceCron() {
invoiceList, _ := db.Store.GetInvoiceCache()
invoiceCount := len(invoiceList)

fmt.Println("Invoice Count ===", invoiceCount)

if invoiceCount > 0 {
for index, inv := range invoiceList {
url := fmt.Sprintf("%s/invoice?payment_request=%s", config.RelayUrl, inv.Invoice)
Expand All @@ -52,15 +50,11 @@ func InitInvoiceCron() {
err = json.Unmarshal(body, &invoiceRes)

if err != nil {
log.Printf("Reading body failed: %s", err)
log.Printf("Reading Invoice body failed: %s", err)
return
}

fmt.Println("Invoice RESPONSE ===", invoiceRes)
fmt.Println("Invoice SETTLED ===", invoiceRes.Response.Settled)

if invoiceRes.Response.Settled {
fmt.Println("IS SETTLED ===", invoiceRes.Response.Settled)
if inv.Invoice == invoiceRes.Response.Payment_request {
/**
If the invoice is settled and still in store
Expand Down Expand Up @@ -181,8 +175,6 @@ func InitInvoiceCron() {
invoiceList, _ := db.Store.GetBudgetInvoiceCache()
invoiceCount := len(invoiceList)

fmt.Println("INVOICE COUNT ===", invoiceCount)

if invoiceCount > 0 {
for index, inv := range invoiceList {
url := fmt.Sprintf("%s/invoice?payment_request=%s", config.RelayUrl, inv.Invoice)
Expand All @@ -206,18 +198,13 @@ func InitInvoiceCron() {
// Unmarshal result
invoiceRes := db.InvoiceResult{}

fmt.Println("Invoice RESPONSE 1 ===", invoiceRes)
fmt.Println("Invoice SETTLED ===", invoiceRes.Response.Settled)

err = json.Unmarshal(body, &invoiceRes)

if err != nil {
log.Printf("Reading Invoice body failed: %s", err)
log.Printf("Reading Organization Invoice body failed: %s", err)
return
}

fmt.Println("Invoice RESPONSE 2 ===", invoiceRes)

if invoiceRes.Response.Settled {
fmt.Sprintln("INVOICE SETTLED")
if inv.Invoice == invoiceRes.Response.Payment_request {
Expand Down

0 comments on commit dad61e9

Please sign in to comment.