Skip to content

Commit

Permalink
subscriptions: fetch all subscriptions
Browse files Browse the repository at this point in the history
  • Loading branch information
inciner8r committed Apr 9, 2024
1 parent 7bc6d49 commit 79d39ae
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
13 changes: 13 additions & 0 deletions api/v1/subscriptions/subscriptions.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ func ApplyRoutes(r *gin.RouterGroup) {
g.POST("webhook", HandleWebhook)
g.Use(paseto.PASETO(false))
g.POST("/create-payment", CreatePaymentIntent)
g.GET("", CheckSubscription)
}
}

Expand Down Expand Up @@ -145,3 +146,15 @@ func HandleCanceledOrFailedPaymentIntent(eventDataRaw json.RawMessage) error {

return nil
}

func CheckSubscription(c *gin.Context) {
db := dbconfig.GetDb()
var subscriptions *models.Subscription
err := db.Find(&subscriptions).Error
if err != nil {
logwrapper.Errorf("Error fetching subscriptions: %v", err)
c.Status(http.StatusInternalServerError)
return
}
c.JSON(http.StatusOK, gin.H{"data": subscriptions})
}
7 changes: 4 additions & 3 deletions api/v1/webapp/webapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ func ApplyRoutes(r *gin.RouterGroup) {
func WebappAuth(c *gin.Context) {
walletAddress := c.GetString(paseto.CTX_WALLET_ADDRES)

res := webappResponse{
WalletAddress: walletAddress,
}
res :=
webappResponse{
WalletAddress: walletAddress,
}
httpo.NewSuccessResponseP(200, "Auth Successful", res).SendD(c)

}

0 comments on commit 79d39ae

Please sign in to comment.