GetSubscriptionUpdateURL initiates the cancelling of a subscription on lemonsqueezy
(ctx context.Context, userID entities.UserID)
| 437 | |
| 438 | // GetSubscriptionUpdateURL initiates the cancelling of a subscription on lemonsqueezy |
| 439 | func (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 |
| 459 | func (service *UserService) CancelSubscription(ctx context.Context, params *events.UserSubscriptionCancelledPayload) error { |
no test coverage detected