Skip to content

Fetching subscriptions returns empty array although there are subscriptions #33

Description

@Tobi696

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions