Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fetching subscriptions returns empty array although there are subscriptions #33

Open
Tobi696 opened this issue Nov 18, 2023 · 0 comments

Comments

@Tobi696
Copy link

Tobi696 commented Nov 18, 2023

Screenshot 2023-11-18 at 18 50 26

Go function to fetch Subscriptions:

func FetchSubscriptions() ([]entities.Subscription, error) {
	var result []entities.Subscription
	ctx := context.TODO()
	subscriptions, err := goCardLessClient.Subscriptions.List(ctx, gocardless.SubscriptionListParams{Limit: 100})
	if err != nil {
		log.Println("Error in api.FetchSubscriptions 1:", err)
		return result, appjoy.ErrSomethingWentWrong
	}
	for _, subscription := range subscriptions.Subscriptions {
		var eSubscription entities.Subscription
		eSubscription.ID = subscription.Id
		switch subscription.IntervalUnit {
		case "weekly":
			eSubscription.Pricing = fmt.Sprintf("%d€ / w", subscription.Amount/1000)
		case "monthly":
			eSubscription.Pricing = fmt.Sprintf("%d€ / m", subscription.Amount/1000)
		}
		result = append(result, eSubscription)
	}

	return result, nil
}

Desired result: getting the subscriptions
Actual result: no error is returned, but the slice of Subscriptions is empty.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant