diff --git a/main.go b/main.go index ed9bb34..beac2c5 100644 --- a/main.go +++ b/main.go @@ -106,6 +106,8 @@ func main() { return } + log.Printf("Created initial wspay form (ammount=%d)", amount) + form := wspay.WsPayForm{ ShopID: ShopId, ShoppingCartID: entry.ShoppingCartID, @@ -125,12 +127,16 @@ func main() { c.AbortWithError(http.StatusInternalServerError, err) return } + log.Printf("Received success response for transaction %s", response.ShoppingCartID) entry, err := wspayService.FetchByShoppingCartID(response.ShoppingCartID) if err != nil { + log.Printf("Couldn't find payment info for transaction %s", response.ShoppingCartID) c.AbortWithError(http.StatusInternalServerError, err) return } + if err := wspay.CompareFormReturnSignature(response.Signature, ShopId, ShopSecret, response.ShoppingCartID, response.Success, response.ApprovalCode); err != nil { + log.Printf("Invalid signature for transaction %s", response.ShoppingCartID) c.AbortWithError(http.StatusBadRequest, err) return } @@ -163,8 +169,10 @@ func main() { } if c.Query("iframe") != "" { + log.Printf("Transaction %s received correctly, returning iframe response", response.ShoppingCartID) c.HTML(200, "iframe_handler.gohtml", gin.H{}) } else { + log.Printf("Transaction %s received correctly, returning redirect", response.ShoppingCartID) c.Redirect(http.StatusTemporaryRedirect, "/") } }) @@ -177,8 +185,10 @@ func main() { c.AbortWithError(http.StatusInternalServerError, err) return } + log.Printf("Received error response for transaction %s", response.ShoppingCartID) entry, err := wspayService.FetchByShoppingCartID(response.ShoppingCartID) if err != nil { + log.Printf("Couldn't find payment info for transaction %s", response.ShoppingCartID) c.AbortWithError(http.StatusInternalServerError, err) return } @@ -210,8 +220,10 @@ func main() { } if c.Query("iframe") != "" { + log.Printf("Transaction %s received correctly, returning iframe response", response.ShoppingCartID) c.HTML(200, "iframe_handler.gohtml", gin.H{}) } else { + log.Printf("Transaction %s received correctly, returning redirect", response.ShoppingCartID) c.Redirect(http.StatusTemporaryRedirect, "/") } }) @@ -230,8 +242,10 @@ func main() { c.AbortWithError(http.StatusInternalServerError, err) return } + log.Printf("Received error response for transaction %s", response.ShoppingCartID) entry, err := wspayService.FetchByShoppingCartID(response.ShoppingCartID) if err != nil { + log.Printf("Couldn't find payment info for transaction %s", response.ShoppingCartID) c.AbortWithError(http.StatusInternalServerError, err) return } @@ -243,8 +257,10 @@ func main() { } if c.Query("iframe") != "" { + log.Printf("Transaction %s received correctly, returning iframe response", response.ShoppingCartID) c.HTML(200, "iframe_handler.gohtml", gin.H{}) } else { + log.Printf("Transaction %s received correctly, returning redirect", response.ShoppingCartID) c.Redirect(http.StatusTemporaryRedirect, "/") } })