From 79d39ae0255b9d684795300cd51411b0192266a4 Mon Sep 17 00:00:00 2001 From: Punarv Pawade Date: Tue, 9 Apr 2024 10:29:21 +0530 Subject: [PATCH] subscriptions: fetch all subscriptions --- api/v1/subscriptions/subscriptions.go | 13 +++++++++++++ api/v1/webapp/webapp.go | 7 ++++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/api/v1/subscriptions/subscriptions.go b/api/v1/subscriptions/subscriptions.go index 463c253..122b41f 100644 --- a/api/v1/subscriptions/subscriptions.go +++ b/api/v1/subscriptions/subscriptions.go @@ -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) } } @@ -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}) +} diff --git a/api/v1/webapp/webapp.go b/api/v1/webapp/webapp.go index fdb66ae..32afeca 100644 --- a/api/v1/webapp/webapp.go +++ b/api/v1/webapp/webapp.go @@ -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) }