From 25ff7ae4d74e8c94473c0cfb399782d6b02819c1 Mon Sep 17 00:00:00 2001 From: Richard Marmorstein Date: Tue, 12 Apr 2022 18:37:25 -0700 Subject: [PATCH] Codegen for openapi e0123a3 --- charge.go | 2 ++ paymentintent.go | 52 +++++++++++++++++++++++++++++++++++++++-- paymentintent/client.go | 16 +++++++++++++ paymentmethod.go | 2 +- setupintent.go | 2 +- 5 files changed, 70 insertions(+), 4 deletions(-) diff --git a/charge.go b/charge.go index 3fd83de19f..d5e506d0a4 100644 --- a/charge.go +++ b/charge.go @@ -603,6 +603,8 @@ type ChargePaymentMethodDetailsCardPresent struct { Funding CardFunding `json:"funding"` // ID of a card PaymentMethod generated from the card_present PaymentMethod that may be attached to a Customer for future transactions. Only present if it was possible to generate a card PaymentMethod. GeneratedCard string `json:"generated_card"` + // Whether this [PaymentIntent](https://stripe.com/docs/api/payment_intents) is eligible for incremental authorizations. Request support using [request_incremental_authorization_support] /docs/api/payment_intents/create#create_payment_intent-payment_method_options-card_present-request_incremental_authorization_support. + IncrementalAuthorizationSupported bool `json:"incremental_authorization_supported"` // The last four digits of the card. Last4 string `json:"last4"` // Identifies which network this charge was processed on. Can be `amex`, `cartes_bancaires`, `diners`, `discover`, `interac`, `jcb`, `mastercard`, `unionpay`, `visa`, or `unknown`. diff --git a/paymentintent.go b/paymentintent.go index a5b1d40037..a43f6fbc03 100644 --- a/paymentintent.go +++ b/paymentintent.go @@ -831,6 +831,8 @@ type PaymentIntentPaymentMethodOptionsCardParams struct { type PaymentIntentPaymentMethodOptionsCardPresentParams struct { // Request ability to capture this payment beyond the standard [authorization validity window](https://stripe.com/docs/terminal/features/extended-authorizations#authorization-validity) RequestExtendedAuthorization *bool `form:"request_extended_authorization"` + // Request ability to [increment](docs/terminal/features/incremental-authorizations) this PaymentIntent if the combination of MCC and card brand is eligible. Check [incremental_authorization_supported](https://stripe.com/docs/api/charges/object#charge_object-payment_method_details-card_present-incremental_authorization_supported) in the [Confirm](https://stripe.com/docs/api/payment_intents/confirm) response to verify support. + RequestIncrementalAuthorizationSupport *bool `form:"request_incremental_authorization_support"` } // If this is a `eps` PaymentMethod, this sub-hash contains details about the EPS payment method options. @@ -1289,6 +1291,50 @@ type PaymentIntentCaptureParams struct { TransferData *PaymentIntentTransferDataParams `form:"transfer_data"` } +// The parameters used to automatically create a Transfer when the payment is captured. +// For more information, see the PaymentIntents [use case for connected accounts](https://stripe.com/docs/payments/connected-accounts). +type PaymentIntentIncrementAuthorizationTransferDataParams struct { + // The amount that will be transferred automatically when a charge succeeds. + Amount *int64 `form:"amount"` +} + +// Perform an incremental authorization on an eligible +// [PaymentIntent](https://stripe.com/docs/api/payment_intents/object). To be eligible, the +// PaymentIntent's status must be requires_capture and +// [incremental_authorization_supported](https://stripe.com/docs/api/charges/object#charge_object-payment_method_details-card_present-incremental_authorization_supported) +// must be true. +// +// Incremental authorizations attempt to increase the authorized amount on +// your customer's card to the new, higher amount provided. As with the +// initial authorization, incremental authorizations may be declined. A +// single PaymentIntent can call this endpoint multiple times to further +// increase the authorized amount. +// +// If the incremental authorization succeeds, the PaymentIntent object is +// returned with the updated +// [amount](https://stripe.com/docs/api/payment_intents/object#payment_intent_object-amount). +// If the incremental authorization fails, a +// [card_declined](https://stripe.com/docs/error-codes#card-declined) error is returned, and no +// fields on the PaymentIntent or Charge are updated. The PaymentIntent +// object remains capturable for the previously authorized amount. +// +// Each PaymentIntent can have a maximum of 10 incremental authorization attempts, including declines. +// Once captured, a PaymentIntent can no longer be incremented. +// +// Learn more about [incremental authorizations](https://stripe.com/docs/terminal/features/incremental-authorizations). +type PaymentIntentIncrementAuthorizationParams struct { + Params `form:"*"` + // The updated total amount you intend to collect from the cardholder. This amount must be greater than the currently authorized amount. + Amount *int64 `form:"amount"` + // The amount of the application fee (if any) that will be requested to be applied to the payment and transferred to the application owner's Stripe account. The amount of the application fee collected will be capped at the total payment amount. For more information, see the PaymentIntents [use case for connected accounts](https://stripe.com/docs/payments/connected-accounts). + ApplicationFeeAmount *int64 `form:"application_fee_amount"` + // An arbitrary string attached to the object. Often useful for displaying to users. + Description *string `form:"description"` + // The parameters used to automatically create a Transfer when the payment is captured. + // For more information, see the PaymentIntents [use case for connected accounts](https://stripe.com/docs/payments/connected-accounts). + TransferData *PaymentIntentIncrementAuthorizationTransferDataParams `form:"transfer_data"` +} + // Verifies microdeposits on a PaymentIntent object. type PaymentIntentVerifyMicrodepositsParams struct { Params `form:"*"` @@ -1626,6 +1672,8 @@ type PaymentIntentPaymentMethodOptionsCard struct { type PaymentIntentPaymentMethodOptionsCardPresent struct { // Request ability to capture this payment beyond the standard [authorization validity window](https://stripe.com/docs/terminal/features/extended-authorizations#authorization-validity) RequestExtendedAuthorization bool `json:"request_extended_authorization"` + // Request ability to [increment](docs/terminal/features/incremental-authorizations) this PaymentIntent if the combination of MCC and card brand is eligible. Check [incremental_authorization_supported](https://stripe.com/docs/api/charges/object#charge_object-payment_method_details-card_present-incremental_authorization_supported) in the [Confirm](https://stripe.com/docs/api/payment_intents/confirm) response to verify support. + RequestIncrementalAuthorizationSupport bool `json:"request_incremental_authorization_support"` } type PaymentIntentPaymentMethodOptionsEPS struct { // Indicates that you intend to make future payments with this PaymentIntent's payment method. @@ -1866,9 +1914,9 @@ type PaymentIntent struct { Charges *ChargeList `json:"charges"` // The client secret of this PaymentIntent. Used for client-side retrieval using a publishable key. // - // The client secret can be used to complete a payment from your frontend. It should not be stored, logged, embedded in URLs, or exposed to anyone other than the customer. Make sure that you have TLS enabled on any page that includes the client secret. + // The client secret can be used to complete a payment from your frontend. It should not be stored, logged, or exposed to anyone other than the customer. Make sure that you have TLS enabled on any page that includes the client secret. // - // Refer to our docs to [accept a payment](https://stripe.com/docs/payments/accept-a-payment?integration=elements) and learn about how `client_secret` should be handled. + // Refer to our docs to [accept a payment](https://stripe.com/docs/payments/accept-a-payment?ui=elements) and learn about how `client_secret` should be handled. ClientSecret string `json:"client_secret"` ConfirmationMethod PaymentIntentConfirmationMethod `json:"confirmation_method"` // Time at which the object was created. Measured in seconds since the Unix epoch. diff --git a/paymentintent/client.go b/paymentintent/client.go index 401e79e883..71f4f96e5e 100644 --- a/paymentintent/client.go +++ b/paymentintent/client.go @@ -119,6 +119,22 @@ func (c Client) Confirm(id string, params *stripe.PaymentIntentConfirmParams) (* return paymentintent, err } +// IncrementAuthorization is the method for the `POST /v1/payment_intents/{intent}/increment_authorization` API. +func IncrementAuthorization(id string, params *stripe.PaymentIntentIncrementAuthorizationParams) (*stripe.PaymentIntent, error) { + return getC().IncrementAuthorization(id, params) +} + +// IncrementAuthorization is the method for the `POST /v1/payment_intents/{intent}/increment_authorization` API. +func (c Client) IncrementAuthorization(id string, params *stripe.PaymentIntentIncrementAuthorizationParams) (*stripe.PaymentIntent, error) { + path := stripe.FormatURLPath( + "/v1/payment_intents/%s/increment_authorization", + id, + ) + paymentintent := &stripe.PaymentIntent{} + err := c.B.Call(http.MethodPost, path, c.Key, params, paymentintent) + return paymentintent, err +} + // VerifyMicrodeposits is the method for the `POST /v1/payment_intents/{intent}/verify_microdeposits` API. func VerifyMicrodeposits(id string, params *stripe.PaymentIntentVerifyMicrodepositsParams) (*stripe.PaymentIntent, error) { return getC().VerifyMicrodeposits(id, params) diff --git a/paymentmethod.go b/paymentmethod.go index e7bf5f102b..ba441d7ee5 100644 --- a/paymentmethod.go +++ b/paymentmethod.go @@ -582,7 +582,7 @@ type PaymentMethodUSBankAccount struct { type PaymentMethodWechatPay struct{} // PaymentMethod objects represent your customer's payment instruments. -// They can be used with [PaymentIntents](https://stripe.com/docs/payments/payment-intents) to collect payments or saved to +// You can use them with [PaymentIntents](https://stripe.com/docs/payments/payment-intents) to collect payments or save them to // Customer objects to store instrument details for future payments. // // Related guides: [Payment Methods](https://stripe.com/docs/payments/payment-methods) and [More Payment Scenarios](https://stripe.com/docs/payments/more-payment-scenarios). diff --git a/setupintent.go b/setupintent.go index 76e0e0c1d6..d247a8ad6c 100644 --- a/setupintent.go +++ b/setupintent.go @@ -497,7 +497,7 @@ type SetupIntent struct { CancellationReason SetupIntentCancellationReason `json:"cancellation_reason"` // The client secret of this SetupIntent. Used for client-side retrieval using a publishable key. // - // The client secret can be used to complete payment setup from your frontend. It should not be stored, logged, embedded in URLs, or exposed to anyone other than the customer. Make sure that you have TLS enabled on any page that includes the client secret. + // The client secret can be used to complete payment setup from your frontend. It should not be stored, logged, or exposed to anyone other than the customer. Make sure that you have TLS enabled on any page that includes the client secret. ClientSecret string `json:"client_secret"` // Time at which the object was created. Measured in seconds since the Unix epoch. Created int64 `json:"created"`