Skip to content

Commit 0006397

Browse files
committed
Update subscription expired event handler
1 parent 48071b3 commit 0006397

3 files changed

Lines changed: 15 additions & 8 deletions

File tree

api/go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ require (
88
github.com/GoogleCloudPlatform/opentelemetry-operations-go/exporter/metric v0.36.0
99
github.com/GoogleCloudPlatform/opentelemetry-operations-go/exporter/trace v1.12.0
1010
github.com/NdoleStudio/go-otelroundtripper v0.0.7
11-
github.com/NdoleStudio/lemonsqueezy-go v0.0.8
11+
github.com/NdoleStudio/lemonsqueezy-go v0.0.12
1212
github.com/carlmjohnson/requests v0.23.2
1313
github.com/cheggaaa/pb/v3 v3.0.8
1414
github.com/cloudevents/sdk-go/v2 v2.13.0
@@ -31,7 +31,7 @@ require (
3131
github.com/redis/go-redis/v9 v9.0.2
3232
github.com/rs/zerolog v1.29.0
3333
github.com/sendgrid/sendgrid-go v3.12.0+incompatible
34-
github.com/stretchr/testify v1.8.2
34+
github.com/stretchr/testify v1.8.4
3535
github.com/swaggo/swag v1.8.10
3636
github.com/thedevsaddam/govalidator v1.9.10
3737
github.com/uptrace/uptrace-go v1.13.0

api/go.sum

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ github.com/Masterminds/sprig v2.22.0+incompatible h1:z4yfnGrZ7netVz+0EDJ0Wi+5VZC
7676
github.com/Masterminds/sprig v2.22.0+incompatible/go.mod h1:y6hNFY5UBTIWBxnzTeuNhlNS5hqE0NB0E6fgfo2Br3o=
7777
github.com/NdoleStudio/go-otelroundtripper v0.0.7 h1:4dNXdVDxHdzRIe0TMpxfx/t+p0EJCvayugtbd/yCoOc=
7878
github.com/NdoleStudio/go-otelroundtripper v0.0.7/go.mod h1:keaIZbY7yfCTgm5kffvO/QAw86rUEEY3a8sKBTYxb3U=
79-
github.com/NdoleStudio/lemonsqueezy-go v0.0.8 h1:dHUVRZLWgTJo6u0bsF3k1H5BksbiMW6KhBc0zSlxjbw=
80-
github.com/NdoleStudio/lemonsqueezy-go v0.0.8/go.mod h1:bWUDOXUQywIYY4Ak79Fp5PPKHY8ju0PDOzFWlWM2co0=
79+
github.com/NdoleStudio/lemonsqueezy-go v0.0.12 h1:uG4a6xnqw65csluoCWUH7iiFYOOsu45KGUfArUAOytg=
80+
github.com/NdoleStudio/lemonsqueezy-go v0.0.12/go.mod h1:yRYTtU1RyapMDPTFKypIEKLEjPAbWq9a5PGqqvIn6/Y=
8181
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
8282
github.com/PuerkitoBio/goquery v1.5.0/go.mod h1:qD2PgZ9lccMbQlc7eEOjaeRlFQON7xY8kdmcsrnKqMg=
8383
github.com/PuerkitoBio/goquery v1.5.1/go.mod h1:GsLWisAFVj4WgDibEWF4pvYnkVQBpKBKeU+7zCJoLcc=
@@ -402,8 +402,8 @@ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
402402
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
403403
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
404404
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
405-
github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8=
406-
github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
405+
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
406+
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
407407
github.com/swaggo/files v0.0.0-20220728132757-551d4a08d97a/go.mod h1:lKJPbtWzJ9JhsTN1k1gZgleJWY/cqq0psdoMmaThG3w=
408408
github.com/swaggo/files v1.0.0 h1:1gGXVIeUFCS/dta17rnP0iOpr6CXFwKD7EO5ID233e4=
409409
github.com/swaggo/files v1.0.0/go.mod h1:N59U6URJLyU1PQgFqPM7wXLMhJx7QAolnvfQkqO13kc=

api/pkg/handlers/lemonsqueezy_handler.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,19 +80,26 @@ func (h *LemonsqueezyHandler) handleRequest(ctx context.Context, c *fiber.Ctx) e
8080
eventName := c.Get("X-Event-Name")
8181
switch eventName {
8282
case "subscription_created":
83-
var request lemonsqueezy.WebHookRequestSubscription
83+
var request lemonsqueezy.WebhookRequestSubscription
8484
err := json.Unmarshal(c.Body(), &request)
8585
if err != nil {
8686
return stacktrace.Propagate(err, fmt.Sprintf("cannot marshall [%s] to [%T]", c.Body(), request))
8787
}
8888
return h.service.HandleSubscriptionCreatedEvent(ctx, c.OriginalURL(), &request)
8989
case "subscription_cancelled":
90-
var request lemonsqueezy.WebHookRequestSubscription
90+
var request lemonsqueezy.WebhookRequestSubscription
9191
err := json.Unmarshal(c.Body(), &request)
9292
if err != nil {
9393
return stacktrace.Propagate(err, fmt.Sprintf("cannot marshall [%s] to [%T]", c.Body(), request))
9494
}
9595
return h.service.HandleSubscriptionCanceledEvent(ctx, c.OriginalURL(), &request)
96+
case "subscription_expired":
97+
var request lemonsqueezy.WebhookRequestSubscription
98+
err := json.Unmarshal(c.Body(), &request)
99+
if err != nil {
100+
return stacktrace.Propagate(err, fmt.Sprintf("cannot marshall [%s] to [%T]", c.Body(), request))
101+
}
102+
return h.service.HandleSubscriptionExpiredEvent(ctx, c.OriginalURL(), &request)
96103
default:
97104
return stacktrace.NewError(fmt.Sprintf("invalid event [%s] received with request [%s]", eventName, c.Body()))
98105
}

0 commit comments

Comments
 (0)