#chronic-go-version
1 messages · Page 1 of 1 (latest)
Hello! Can you share the code that's throwing that error?
sure
`func CreatePaymentSubscription (customerID string, amount int64) (string, error) {
stripe.Key = PK
items := []*stripe.SubscriptionItemsParams{
{
Price: stripe.String(CREDIT_ID),
Quantity: stripe.Int64(amount),
},
}
params := &stripe.SubscriptionParams{
Customer: stripe.String(customerID),
Items: items,
}
s, err := sub.New(params)
if err != nil {
return "", err
}
subID := string(s.ID)
return subID, err
}
`
Hm. That seems correct to me, and seems to match the snippet here: https://stripe.com/docs/api/subscriptions/create?lang=go
If you do the parameters inline like the snippet in the docs above does that work?
same error
unknown field 'Price' in struct literal of type "github.com/stripe/stripe-go".SubscriptionItemsParams
What version though? https://github.com/stripe/stripe-go/blob/master/CHANGELOG.md
im guessing that defaults to current?
👋 Hey @lilac nacelle ! Based on the way you integrate, you are likely on an old version
stripe-go moved to go modules back in early 2020 https://github.com/stripe/stripe-go#installation
you don't seem to use go modules so you get the "most recent version before go modules" which is v71 which is almost 3 years old
and it's right before we added support for the Price APIs and parameters.
You need to change your code to reference the right major version. Currently it's v74. If you just started your integration then it's easy and you follow the steps to the readme
If your integration is already active then it's more work since there are regular breaking changes every time we release a major version so you'll need to read the migration guide(s): https://github.com/stripe/stripe-go/wiki
ill try it again with /74 but was having the same error when I did
you don't just add /74 you also need to install the right version locally, using go modules
you are likely still having the old/cached version in your GOPATH
you just change it in the imports and do mod tidy right
not sure, I usually start fresh. But I can tell you for sure it's your issue at least. So you need to remove the old stripe-go, add the right one to you module and make sure it pulls the right version
chronic-go-version
thanks, works now