MCPcopy Index your code
hub / github.com/NdoleStudio/httpsms / GetSubscriptionUpdateURL

Method GetSubscriptionUpdateURL

api/pkg/services/user_service.go:439–456  ·  view source on GitHub ↗

GetSubscriptionUpdateURL initiates the cancelling of a subscription on lemonsqueezy

(ctx context.Context, userID entities.UserID)

Source from the content-addressed store, hash-verified

437
438// GetSubscriptionUpdateURL initiates the cancelling of a subscription on lemonsqueezy
439func (service *UserService) GetSubscriptionUpdateURL(ctx context.Context, userID entities.UserID) (url string, err error) {
440 ctx, span := service.tracer.Start(ctx)
441 defer span.End()
442
443 user, err := service.repository.Load(ctx, userID)
444 if err != nil {
445 msg := fmt.Sprintf("could not get [%T] with with ID [%s]", user, userID)
446 return "", service.tracer.WrapErrorSpan(span, stacktrace.Propagate(err, msg))
447 }
448
449 subscription, _, err := service.lemonsqueezyClient.Subscriptions.Get(ctx, *user.SubscriptionID)
450 if err != nil {
451 msg := fmt.Sprintf("could not get subscription [%s] for [%T] with with ID [%s]", *user.SubscriptionID, user, user.ID)
452 return url, service.tracer.WrapErrorSpan(span, stacktrace.Propagate(err, msg))
453 }
454
455 return subscription.Data.Attributes.Urls.CustomerPortal, nil
456}
457
458// CancelSubscription starts a subscription for an entities.User
459func (service *UserService) CancelSubscription(ctx context.Context, params *events.UserSubscriptionCancelledPayload) error {

Callers 1

subscriptionUpdateURLMethod · 0.80

Calls 4

StartMethod · 0.65
LoadMethod · 0.65
WrapErrorSpanMethod · 0.65
GetMethod · 0.65

Tested by

no test coverage detected