Skip to content

Commit

Permalink
fixed cancel subscribtions
Browse files Browse the repository at this point in the history
  • Loading branch information
TeisNP committed Feb 12, 2024
1 parent e3c819a commit 9302712
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions internal/billing/service.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package billing

import (
"fmt"
"os"
"strconv"

Expand Down Expand Up @@ -120,19 +119,12 @@ func (s *ServiceImpl) CancelSubscribtion(team *entities.Team) (*stripe.Subscript
// Set Customer on session if already a customer

sub := s.GetCustomerSubscribtion(*team.StripeCustomerID)
fmt.Println(sub.SubscriptionList())
sub.Next()
teamSubscription := sub.Subscription()

params := &stripe.SubscriptionParams{
Items: []*stripe.SubscriptionItemsParams{
{
ID: stripe.String(teamSubscription.Items.Data[0].ID),
Deleted: stripe.Bool(true),
},
},
}
result, err := subscription.Update(teamSubscription.ID, params)
params := &stripe.SubscriptionCancelParams{}
result, err := subscription.Cancel(teamSubscription.ID, params)

if err != nil {
return nil, errors.Wrap(err, "failed to update subscription")
}
Expand Down

0 comments on commit 9302712

Please sign in to comment.