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

Add support for Metadata for PaymentIntentData and SubscriptionData on Checkout Session #1093

Merged
merged 1 commit into from
May 7, 2020

Conversation

remi-stripe
Copy link
Contributor

Fixes #1092

r? @ob-stripe
cc @stripe/api-libraries

@@ -62,6 +62,7 @@ type CheckoutSessionPaymentIntentDataParams struct {
ApplicationFeeAmount *int64 `form:"application_fee_amount"`
CaptureMethod *string `form:"capture_method"`
Description *string `form:"description"`
Metadata map[string]string `form:"metadata"`
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I opted for map[string]string for consistency with plan and price. In theory it should be a pointer I think but in this case it's not updatable so it shouldn't matter right?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maps are kind of a special type in that they're always reference types, and so you shouldn't use a pointer with them. See this blog post on them:

var m map[string]int

Map types are reference types, like pointers or slices, and so the value of m above is nil; it doesn't point to an initialized map. A nil map behaves like an empty map when reading, but attempts to write to a nil map will cause a runtime panic; don't do that. To initialize a map, use the built in make function:

m = make(map[string]int)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah nice, so we didn't overlook this originally when we used map. Thanks for clarifying @brandur-stripe !

Copy link
Contributor

@cjavilla-stripe cjavilla-stripe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@remi-stripe remi-stripe merged commit b930a99 into master May 7, 2020
@stripe-ci stripe-ci assigned remi-stripe and unassigned ob-stripe May 7, 2020
@remi-stripe remi-stripe deleted the remi-fix-checkout-metadata branch May 7, 2020 23:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Missing "Metadata" for "CheckoutSessionSubscriptionDataParams"
5 participants