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 payment_settings to invoice #1247

Merged
merged 4 commits into from
Feb 9, 2021

Conversation

richardm-stripe
Copy link
Contributor

@richardm-stripe richardm-stripe commented Feb 9, 2021

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

Adds support for payment_settings on the Invoice resource, from a recent API Release. (Skipping the "capability" part of that release for now, until that feature is fully released)

invoice.go Outdated
// redirected to.
type InvoicePaymentSettingsPaymentMethodOptionsBancontactPreferredLanguage string

// List of values that InvoicePaymentSettingsPaymentMethodOptionsBancontactPreferredLanguage can take.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure about this -- the general rule is "define enums for resources, but not for params" but we don't seem to be explicit about "language" enums anywhere else.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah I'd recommend punting on constants for languages today. I don't know who we'll handle once we codegen but until then keeping those as strings is easier (because there could be hundreds of constants otherwise, it's like state or country)

Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm, IMO we should probably just make it a string because (1) it's documented as string as opposed to enum in the API ref, (2) this could potentially have a lot of different values, (3) if the product team added a new value without the library I'm not sure that we'd be able to handle it that well, and (4) it looks like it's a string on payment intent, setup attempt, and charge.

Thoughts?

InvoicePaymentSettingsPaymentMethodTypeGiropay InvoicePaymentSettingsPaymentMethodType = "giropay"
InvoicePaymentSettingsPaymentMethodTypeIdeal InvoicePaymentSettingsPaymentMethodType = "ideal"
InvoicePaymentSettingsPaymentMethodTypeSepaCreditTransfer InvoicePaymentSettingsPaymentMethodType = "sepa_credit_transfer"
InvoicePaymentSettingsPaymentMethodTypeSepaDebit InvoicePaymentSettingsPaymentMethodType = "sepa_debit"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's SEPA in account.go, but Sepa in charge.go and payment_intent.go I think. I figure it's better to be consistent with the "payment" resources than account.

Copy link
Contributor

Choose a reason for hiding this comment

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

That's fair, though that will increase the number of breaking changes once we codegen and fix this right? tbh I have no idea how we'll handle codegen-ing specific acronyms having to be in upper case 😓

Copy link
Contributor

Choose a reason for hiding this comment

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

Arg lol. Yeah, that seems okay.

invoice.go Outdated Show resolved Hide resolved

// List of values that InvoicePaymentSettingsPaymentMethodType can take.
const (
InvoicePaymentSettingsPaymentMethodTypeAchCreditTransfer InvoicePaymentSettingsPaymentMethodType = "ach_credit_transfer"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should be ACH, but it's Ach in other places and ACH does not exist anywhere.

Copy link
Contributor

@remi-stripe remi-stripe left a comment

Choose a reason for hiding this comment

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

nitpicky comments but deferring the review to brandur!

invoice.go Outdated
// redirected to.
type InvoicePaymentSettingsPaymentMethodOptionsBancontactPreferredLanguage string

// List of values that InvoicePaymentSettingsPaymentMethodOptionsBancontactPreferredLanguage can take.
Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah I'd recommend punting on constants for languages today. I don't know who we'll handle once we codegen but until then keeping those as strings is easier (because there could be hundreds of constants otherwise, it's like state or country)

InvoicePaymentSettingsPaymentMethodTypeGiropay InvoicePaymentSettingsPaymentMethodType = "giropay"
InvoicePaymentSettingsPaymentMethodTypeIdeal InvoicePaymentSettingsPaymentMethodType = "ideal"
InvoicePaymentSettingsPaymentMethodTypeSepaCreditTransfer InvoicePaymentSettingsPaymentMethodType = "sepa_credit_transfer"
InvoicePaymentSettingsPaymentMethodTypeSepaDebit InvoicePaymentSettingsPaymentMethodType = "sepa_debit"
Copy link
Contributor

Choose a reason for hiding this comment

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

That's fair, though that will increase the number of breaking changes once we codegen and fix this right? tbh I have no idea how we'll handle codegen-ing specific acronyms having to be in upper case 😓

invoice.go Outdated
PreferredLanguage *string `form:"preferred_language"`
}

// InvoicePaymentSettingsParams is the set of parameters allowed for card on payment_method_options on
Copy link
Contributor

Choose a reason for hiding this comment

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

Comment references the wrong type

Copy link
Contributor

Choose a reason for hiding this comment

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

This is a bit nitpicky too, but I'd probably leave out things like payment_method_options just because the user will never directly interact with those API parameter names (i.e. they use Go symbols like PaymentMethodOptions instead).

I usually just keep the docs on these structs as simple as plausibly possible like "is the set of parameters for invoice payment settings". Not super useful I know, but pretty much no documentation will be unless we go for all-the-way API ref style docs (which might be possible with codegen).

invoice.go Outdated
RequestThreeDSecure *string `form:"request_three_d_secure"`
}

// InvoicePaymentSettingsParams is the set of parameters allowed for the payment_method_options on ther
Copy link
Contributor

Choose a reason for hiding this comment

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

Comment references the wrong type

Card *InvoicePaymentSettingsPaymentMethodOptionsCardParams `form:"card"`
}

// InvoicePaymentSettingsParams is the set of parameters allowed for the payment_settings on an invoice.
Copy link
Contributor

Choose a reason for hiding this comment

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

Comment references the wrong type

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Seems right to me

@brandur-stripe
Copy link
Contributor

A couple minor comments (and from Remi as well), but looks fine to me!

ptal @richardm-stripe

invoice.go Outdated Show resolved Hide resolved
invoice.go Outdated Show resolved Hide resolved
invoice.go Outdated Show resolved Hide resolved
invoice.go Outdated Show resolved Hide resolved
@richardm-stripe
Copy link
Contributor Author

r? @brandur-stripe
I

  • Replaced the PreferredLanguage enum with a string.
  • Kept it as Sepa, not SEPA.
  • Kept as Ach, not ACH.
  • Simplified/corrected docstrings for InvoicePaymentSettingsParams and its children.

Copy link
Contributor

@brandur-stripe brandur-stripe left a comment

Choose a reason for hiding this comment

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

Thanks Richard. LGTM.

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

Successfully merging this pull request may close these issues.

3 participants