diff --git a/charge.go b/charge.go index bd97abc991..397761ec5a 100644 --- a/charge.go +++ b/charge.go @@ -73,6 +73,18 @@ const ( ChargePaymentMethodDetailsCardThreeDSecureResultReasonRejected ChargePaymentMethodDetailsCardThreeDSecureResultReason = "rejected" ) +// The Klarna payment method used for this transaction. +// Can be one of `pay_later`, `pay_now`, `pay_with_financing`, or `pay_in_installments` +type ChargePaymentMethodDetailsKlarnaPaymentMethodCategory string + +// List of values that ChargePaymentMethodDetailsKlarnaPaymentMethodCategory can take +const ( + ChargePaymentMethodDetailsKlarnaPaymentMethodCategoryPayLater ChargePaymentMethodDetailsKlarnaPaymentMethodCategory = "pay_later" + ChargePaymentMethodDetailsKlarnaPaymentMethodCategoryPayNow ChargePaymentMethodDetailsKlarnaPaymentMethodCategory = "pay_now" + ChargePaymentMethodDetailsKlarnaPaymentMethodCategoryPayWithFinancing ChargePaymentMethodDetailsKlarnaPaymentMethodCategory = "pay_with_financing" + ChargePaymentMethodDetailsKlarnaPaymentMethodCategoryPayInInstallments ChargePaymentMethodDetailsKlarnaPaymentMethodCategory = "pay_in_installments" +) + // ChargePaymentMethodDetailsType is the type of the PaymentMethod associated with the Charge's // payment method details. type ChargePaymentMethodDetailsType string @@ -495,7 +507,10 @@ type ChargePaymentMethodDetailsInteracPresentReceipt struct { // ChargePaymentMethodDetailsKlarna represents details for the Klarna // PaymentMethod. -type ChargePaymentMethodDetailsKlarna struct{} +type ChargePaymentMethodDetailsKlarna struct { + PaymentMethodCategory ChargePaymentMethodDetailsKlarnaPaymentMethodCategory `json:"payment_method_category"` + PreferredLocale string `json:"preferred_locale"` +} // ChargePaymentMethodDetailsMultibanco represents details about the Multibanco PaymentMethod. type ChargePaymentMethodDetailsMultibanco struct { diff --git a/paymentintent.go b/paymentintent.go index fd92ffb60f..d041babc25 100644 --- a/paymentintent.go +++ b/paymentintent.go @@ -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"` @@ -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 { @@ -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"` @@ -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 { @@ -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"` diff --git a/paymentmethod.go b/paymentmethod.go index d147b69065..b13eb96a0b 100644 --- a/paymentmethod.go +++ b/paymentmethod.go @@ -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" @@ -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 { @@ -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"` @@ -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 { } @@ -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"`