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

API Updates #1354

Merged
merged 7 commits into from
Oct 11, 2021
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion charge.go
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,10 @@ type ChargePaymentMethodDetailsInteracPresentReceipt struct {

// ChargePaymentMethodDetailsKlarna represents details for the Klarna
// PaymentMethod.
type ChargePaymentMethodDetailsKlarna struct{}
type ChargePaymentMethodDetailsKlarna struct {
PaymentMethodCategory string `json:"payment_method_category"`
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we want to document the possible values for this string enum?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good call, I made it an enum in 181688d

PreferredLocale string `json:"preferred_locale"`
}

// ChargePaymentMethodDetailsMultibanco represents details about the Multibanco PaymentMethod.
type ChargePaymentMethodDetailsMultibanco struct {
Expand Down
14 changes: 14 additions & 0 deletions paymentintent.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ type PaymentIntentPaymentMethodDataParams struct {
FPX *PaymentMethodFPXParams `form:"fpx"`
Grabpay *PaymentMethodGrabpayParams `form:"grabpay"`
Ideal *PaymentMethodIdealParams `form:"ideal"`
Klarna *PaymentMethodKlarnaParams `form:"klarna"`
OXXO *PaymentMethodOXXOParams `form:"oxxo"`
P24 *PaymentMethodP24Params `form:"p24"`
SepaDebit *PaymentMethodSepaDebitParams `form:"sepa_debit"`
Expand Down Expand Up @@ -287,6 +288,11 @@ type PaymentIntentPaymentMethodOptionsCardParams struct {
RequestThreeDSecure *string `form:"request_three_d_secure"`
}

// If this is a `klarna` PaymentMethod, this sub-hash contains details about the Klarna payment method options.
type PaymentIntentPaymentMethodOptionsKlarnaParams struct {
PreferredLocale *string `form:"preferred_locale"`
}

// PaymentIntentPaymentMethodOptionsOXXOParams represents the OXXO-specific options applied to a
// PaymentIntent.
type PaymentIntentPaymentMethodOptionsOXXOParams struct {
Expand Down Expand Up @@ -315,6 +321,7 @@ type PaymentIntentPaymentMethodOptionsParams struct {
Bancontact *PaymentIntentPaymentMethodOptionsBancontactParams `form:"bancontact"`
Boleto *PaymentIntentPaymentMethodOptionsBoletoParams `form:"boleto"`
Card *PaymentIntentPaymentMethodOptionsCardParams `form:"card"`
Klarna *PaymentIntentPaymentMethodOptionsKlarnaParams `form:"klarna"`
OXXO *PaymentIntentPaymentMethodOptionsOXXOParams `form:"oxxo"`
Sofort *PaymentIntentPaymentMethodOptionsSofortParams `form:"sofort"`
WechatPay *PaymentIntentPaymentMethodOptionsWechatPayParams `form:"wechat_pay"`
Expand Down Expand Up @@ -511,6 +518,12 @@ type PaymentIntentPaymentMethodOptionsCard struct {
RequestThreeDSecure PaymentIntentPaymentMethodOptionsCardRequestThreeDSecure `json:"request_three_d_secure"`
}

// PaymentIntentPaymentMethodOptionsKlarna is the set of Klarna-specific options associated
// with that payment intent.
type PaymentIntentPaymentMethodOptionsKlarna struct {
PreferredLocale string `json:"preferred_locale"`
}

// PaymentIntentPaymentMethodOptionsOXXO is the set of OXXO-specific options associated
// with that payment intent.
type PaymentIntentPaymentMethodOptionsOXXO struct {
Expand Down Expand Up @@ -539,6 +552,7 @@ type PaymentIntentPaymentMethodOptions struct {
Bancontact *PaymentIntentPaymentMethodOptionsBancontact `json:"bancontact"`
Boleto *PaymentIntentPaymentMethodOptionsBoleto `json:"boleto"`
Card *PaymentIntentPaymentMethodOptionsCard `json:"card"`
Klarna *PaymentIntentPaymentMethodOptionsKlarna `json:"klarna"`
OXXO *PaymentIntentPaymentMethodOptionsOXXO `json:"oxxo"`
Sofort *PaymentIntentPaymentMethodOptionsSofort `json:"sofort"`
WechatPay *PaymentIntentPaymentMethodOptionsWechatPay `json:"wechat_pay"`
Expand Down
25 changes: 25 additions & 0 deletions paymentmethod.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const (
PaymentMethodTypeGrabpay PaymentMethodType = "grabpay"
PaymentMethodTypeIdeal PaymentMethodType = "ideal"
PaymentMethodTypeInteracPresent PaymentMethodType = "interac_present"
PaymentMethodTypeKlarna PaymentMethodType = "klarna"
PaymentMethodTypeOXXO PaymentMethodType = "oxxo"
PaymentMethodTypeP24 PaymentMethodType = "p24"
PaymentMethodTypeSepaDebit PaymentMethodType = "sepa_debit"
Expand Down Expand Up @@ -178,6 +179,18 @@ type PaymentMethodIdealParams struct {
type PaymentMethodInteracPresentParams struct {
}

// Customer's date of birth
type PaymentMethodKlarnaDOBParams struct {
Day *int64 `form:"day"`
Month *int64 `form:"month"`
Year *int64 `form:"year"`
}

// If this is a `klarna` PaymentMethod, this hash contains details about the Klarna payment method.
type PaymentMethodKlarnaParams struct {
DOB *PaymentMethodKlarnaDOBParams `form:"dob"`
}

// PaymentMethodOXXOParams is the set of parameters allowed for the `oxxo` hash when creating a
// PaymentMethod of type OXXO.
type PaymentMethodOXXOParams struct {
Expand Down Expand Up @@ -225,6 +238,7 @@ type PaymentMethodParams struct {
Grabpay *PaymentMethodGrabpayParams `form:"grabpay"`
Ideal *PaymentMethodIdealParams `form:"ideal"`
InteracPresent *PaymentMethodInteracPresentParams `form:"interac_present"`
Klarna *PaymentMethodKlarnaParams `form:"klarna"`
OXXO *PaymentMethodOXXOParams `form:"oxxo"`
P24 *PaymentMethodP24Params `form:"p24"`
SepaDebit *PaymentMethodSepaDebitParams `form:"sepa_debit"`
Expand Down Expand Up @@ -385,6 +399,16 @@ type PaymentMethodIdeal struct {
type PaymentMethodInteracPresent struct {
}

// The customer's date of birth, if provided.
type PaymentMethodKlarnaDOB struct {
Day int64 `json:"day"`
Month int64 `json:"month"`
Year int64 `json:"year"`
}
type PaymentMethodKlarna struct {
DOB *PaymentMethodKlarnaDOB `json:"dob"`
}

// PaymentMethodOXXO represents the OXXO-specific properties.
type PaymentMethodOXXO struct {
}
Expand Down Expand Up @@ -442,6 +466,7 @@ type PaymentMethod struct {
ID string `json:"id"`
Ideal *PaymentMethodIdeal `json:"ideal"`
InteracPresent *PaymentMethodInteracPresent `json:"interac_present"`
Klarna *PaymentMethodKlarna `json:"klarna"`
Livemode bool `json:"livemode"`
Metadata map[string]string `json:"metadata"`
Object string `json:"object"`
Expand Down