From a8b9524d09c970c8f51a634c2117f46e9ec2a74b Mon Sep 17 00:00:00 2001 From: Dominic Charley-Roy Date: Mon, 18 Jul 2022 11:43:46 -0400 Subject: [PATCH] Replace the legacy Order API with the new Order API. --- charge.go | 2 - client/api.go | 4 - example/generated_examples_test.go | 59 ++ order.go | 1509 ++++++++++++++++++++++++---- order/client.go | 86 +- orderitem.go | 92 -- orderreturn.go | 79 -- orderreturn/client.go | 77 -- search_iter_test.go | 3 - 9 files changed, 1429 insertions(+), 482 deletions(-) delete mode 100644 orderitem.go delete mode 100644 orderreturn.go delete mode 100644 orderreturn/client.go diff --git a/charge.go b/charge.go index 6975b30b38..758acce6ca 100644 --- a/charge.go +++ b/charge.go @@ -972,8 +972,6 @@ type Charge struct { Object string `json:"object"` // The account (if any) the charge was made on behalf of without triggering an automatic transfer. See the [Connect documentation](https://stripe.com/docs/connect/charges-transfers) for details. OnBehalfOf *Account `json:"on_behalf_of"` - // Deprecated - Order *Order `json:"order"` // Details about whether the payment was accepted, and why. See [understanding declines](https://stripe.com/docs/declines) for details. Outcome *ChargeOutcome `json:"outcome"` // `true` if the charge succeeded, or was successfully authorized for later capture. diff --git a/client/api.go b/client/api.go index 7a4628708a..2fab462e4e 100644 --- a/client/api.go +++ b/client/api.go @@ -51,7 +51,6 @@ import ( "github.com/stripe/stripe-go/v72/mandate" "github.com/stripe/stripe-go/v72/oauth" "github.com/stripe/stripe-go/v72/order" - "github.com/stripe/stripe-go/v72/orderreturn" "github.com/stripe/stripe-go/v72/paymentintent" "github.com/stripe/stripe-go/v72/paymentlink" "github.com/stripe/stripe-go/v72/paymentmethod" @@ -200,8 +199,6 @@ type API struct { Mandates *mandate.Client // OAuth is the client used to invoke /oauth APIs OAuth *oauth.Client - // OrderReturns is the client used to invoke /order_returns APIs. - OrderReturns *orderreturn.Client // Orders is the client used to invoke /orders APIs. Orders *order.Client // PaymentIntents is the client used to invoke /payment_intents APIs. @@ -381,7 +378,6 @@ func (a *API) Init(key string, backends *stripe.Backends) { a.LoginLinks = &loginlink.Client{B: backends.API, Key: key} a.Mandates = &mandate.Client{B: backends.API, Key: key} a.OAuth = &oauth.Client{B: backends.Connect, Key: key} - a.OrderReturns = &orderreturn.Client{B: backends.API, Key: key} a.Orders = &order.Client{B: backends.API, Key: key} a.PaymentIntents = &paymentintent.Client{B: backends.API, Key: key} a.PaymentLinks = &paymentlink.Client{B: backends.API, Key: key} diff --git a/example/generated_examples_test.go b/example/generated_examples_test.go index 7549a68663..ed1349132c 100644 --- a/example/generated_examples_test.go +++ b/example/generated_examples_test.go @@ -34,6 +34,7 @@ import ( issuing_dispute "github.com/stripe/stripe-go/v72/issuing/dispute" issuing_transaction "github.com/stripe/stripe-go/v72/issuing/transaction" mandate "github.com/stripe/stripe-go/v72/mandate" + order "github.com/stripe/stripe-go/v72/order" paymentintent "github.com/stripe/stripe-go/v72/paymentintent" paymentlink "github.com/stripe/stripe-go/v72/paymentlink" paymentmethod "github.com/stripe/stripe-go/v72/paymentmethod" @@ -236,6 +237,56 @@ func TestFinancialConnectionsSessionRetrieve(t *testing.T) { assert.NotNil(t, result) } +func TestOrderCreate(t *testing.T) { + params := &stripe.OrderParams{ + Description: stripe.String("description"), + Currency: stripe.String(string(stripe.CurrencyUSD)), + LineItems: []*stripe.OrderLineItemParams{ + &stripe.OrderLineItemParams{Description: stripe.String("my line item")}, + }, + } + result, _ := order.New(params) + assert.NotNil(t, result) +} + +func TestOrderRetrieve(t *testing.T) { + params := &stripe.OrderParams{} + result, _ := order.Get("order_xyz", params) + assert.NotNil(t, result) +} + +func TestOrderUpdate(t *testing.T) { + params := &stripe.OrderParams{IPAddress: stripe.String("0.0.0.0")} + params.AddMetadata("reference_number", "123") + result, _ := order.Update("order_xyz", params) + assert.NotNil(t, result) +} + +func TestOrderCancel(t *testing.T) { + params := &stripe.OrderCancelParams{} + result, _ := order.Cancel("order_xyz", params) + assert.NotNil(t, result) +} + +func TestOrderListLineItems(t *testing.T) { + params := &stripe.OrderListLineItemsParams{ID: stripe.String("order_xyz")} + result := order.ListLineItems(params) + assert.NotNil(t, result) + assert.Nil(t, result.Err()) +} + +func TestOrderReopen(t *testing.T) { + params := &stripe.OrderReopenParams{} + result, _ := order.Reopen("order_xyz", params) + assert.NotNil(t, result) +} + +func TestOrderSubmit(t *testing.T) { + params := &stripe.OrderSubmitParams{ExpectedTotal: stripe.Int64(100)} + result, _ := order.Submit("order_xyz", params) + assert.NotNil(t, result) +} + func TestPaymentIntentCreate(t *testing.T) { params := &stripe.PaymentIntentParams{ Amount: stripe.Int64(1099), @@ -1408,6 +1459,14 @@ func TestMandateRetrieve(t *testing.T) { assert.NotNil(t, result) } +func TestOrderList(t *testing.T) { + params := &stripe.OrderListParams{} + params.Limit = stripe.Int64(3) + result := order.List(params) + assert.NotNil(t, result) + assert.Nil(t, result.Err()) +} + func TestPaymentIntentList(t *testing.T) { params := &stripe.PaymentIntentListParams{} params.Limit = stripe.Int64(3) diff --git a/order.go b/order.go index 61a22f9119..77536cfc4d 100644 --- a/order.go +++ b/order.go @@ -6,253 +6,1361 @@ package stripe -import "encoding/json" +// The status of the most recent automated tax calculation for this Order. +type OrderAutomaticTaxStatus string -// OrderStatus represents the statuses of an order object. +// List of values that OrderAutomaticTaxStatus can take +const ( + OrderAutomaticTaxStatusComplete OrderAutomaticTaxStatus = "complete" + OrderAutomaticTaxStatusFailed OrderAutomaticTaxStatus = "failed" + OrderAutomaticTaxStatusRequiresLocationInputs OrderAutomaticTaxStatus = "requires_location_inputs" +) + +// Payment schedule for the mandate. +type OrderPaymentSettingsPaymentMethodOptionsACSSDebitMandateOptionsPaymentSchedule string + +// List of values that OrderPaymentSettingsPaymentMethodOptionsACSSDebitMandateOptionsPaymentSchedule can take +const ( + OrderPaymentSettingsPaymentMethodOptionsACSSDebitMandateOptionsPaymentScheduleCombined OrderPaymentSettingsPaymentMethodOptionsACSSDebitMandateOptionsPaymentSchedule = "combined" + OrderPaymentSettingsPaymentMethodOptionsACSSDebitMandateOptionsPaymentScheduleInterval OrderPaymentSettingsPaymentMethodOptionsACSSDebitMandateOptionsPaymentSchedule = "interval" + OrderPaymentSettingsPaymentMethodOptionsACSSDebitMandateOptionsPaymentScheduleSporadic OrderPaymentSettingsPaymentMethodOptionsACSSDebitMandateOptionsPaymentSchedule = "sporadic" +) + +// Transaction type of the mandate. +type OrderPaymentSettingsPaymentMethodOptionsACSSDebitMandateOptionsTransactionType string + +// List of values that OrderPaymentSettingsPaymentMethodOptionsACSSDebitMandateOptionsTransactionType can take +const ( + OrderPaymentSettingsPaymentMethodOptionsACSSDebitMandateOptionsTransactionTypeBusiness OrderPaymentSettingsPaymentMethodOptionsACSSDebitMandateOptionsTransactionType = "business" + OrderPaymentSettingsPaymentMethodOptionsACSSDebitMandateOptionsTransactionTypePersonal OrderPaymentSettingsPaymentMethodOptionsACSSDebitMandateOptionsTransactionType = "personal" +) + +// Indicates that you intend to make future payments with this PaymentIntent's payment method. +// +// Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. +// +// When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). +type OrderPaymentSettingsPaymentMethodOptionsACSSDebitSetupFutureUsage string + +// List of values that OrderPaymentSettingsPaymentMethodOptionsACSSDebitSetupFutureUsage can take +const ( + OrderPaymentSettingsPaymentMethodOptionsACSSDebitSetupFutureUsageNone OrderPaymentSettingsPaymentMethodOptionsACSSDebitSetupFutureUsage = "none" + OrderPaymentSettingsPaymentMethodOptionsACSSDebitSetupFutureUsageOffSession OrderPaymentSettingsPaymentMethodOptionsACSSDebitSetupFutureUsage = "off_session" + OrderPaymentSettingsPaymentMethodOptionsACSSDebitSetupFutureUsageOnSession OrderPaymentSettingsPaymentMethodOptionsACSSDebitSetupFutureUsage = "on_session" +) + +// Bank account verification method. +type OrderPaymentSettingsPaymentMethodOptionsACSSDebitVerificationMethod string + +// List of values that OrderPaymentSettingsPaymentMethodOptionsACSSDebitVerificationMethod can take +const ( + OrderPaymentSettingsPaymentMethodOptionsACSSDebitVerificationMethodAutomatic OrderPaymentSettingsPaymentMethodOptionsACSSDebitVerificationMethod = "automatic" + OrderPaymentSettingsPaymentMethodOptionsACSSDebitVerificationMethodInstant OrderPaymentSettingsPaymentMethodOptionsACSSDebitVerificationMethod = "instant" + OrderPaymentSettingsPaymentMethodOptionsACSSDebitVerificationMethodMicrodeposits OrderPaymentSettingsPaymentMethodOptionsACSSDebitVerificationMethod = "microdeposits" +) + +// Controls when the funds will be captured from the customer's account. +type OrderPaymentSettingsPaymentMethodOptionsAfterpayClearpayCaptureMethod string + +// List of values that OrderPaymentSettingsPaymentMethodOptionsAfterpayClearpayCaptureMethod can take +const ( + OrderPaymentSettingsPaymentMethodOptionsAfterpayClearpayCaptureMethodAutomatic OrderPaymentSettingsPaymentMethodOptionsAfterpayClearpayCaptureMethod = "automatic" + OrderPaymentSettingsPaymentMethodOptionsAfterpayClearpayCaptureMethodManual OrderPaymentSettingsPaymentMethodOptionsAfterpayClearpayCaptureMethod = "manual" +) + +// Indicates that you intend to make future payments with the payment method. +// +// Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the order's Customer, if present, after the order's PaymentIntent is confirmed and any required actions from the user are complete. If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. +// +// When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). +// +// If `setup_future_usage` is already set and you are performing a request using a publishable key, you may only update the value from `on_session` to `off_session`. +type OrderPaymentSettingsPaymentMethodOptionsAfterpayClearpaySetupFutureUsage string + +// List of values that OrderPaymentSettingsPaymentMethodOptionsAfterpayClearpaySetupFutureUsage can take +const ( + OrderPaymentSettingsPaymentMethodOptionsAfterpayClearpaySetupFutureUsageNone OrderPaymentSettingsPaymentMethodOptionsAfterpayClearpaySetupFutureUsage = "none" +) + +// Indicates that you intend to make future payments with this PaymentIntent's payment method. +// +// Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. +// +// When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). +type OrderPaymentSettingsPaymentMethodOptionsAlipaySetupFutureUsage string + +// List of values that OrderPaymentSettingsPaymentMethodOptionsAlipaySetupFutureUsage can take +const ( + OrderPaymentSettingsPaymentMethodOptionsAlipaySetupFutureUsageNone OrderPaymentSettingsPaymentMethodOptionsAlipaySetupFutureUsage = "none" + OrderPaymentSettingsPaymentMethodOptionsAlipaySetupFutureUsageOffSession OrderPaymentSettingsPaymentMethodOptionsAlipaySetupFutureUsage = "off_session" +) + +// Indicates that you intend to make future payments with this PaymentIntent's payment method. +// +// Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. +// +// When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). +type OrderPaymentSettingsPaymentMethodOptionsBancontactSetupFutureUsage string + +// List of values that OrderPaymentSettingsPaymentMethodOptionsBancontactSetupFutureUsage can take +const ( + OrderPaymentSettingsPaymentMethodOptionsBancontactSetupFutureUsageNone OrderPaymentSettingsPaymentMethodOptionsBancontactSetupFutureUsage = "none" + OrderPaymentSettingsPaymentMethodOptionsBancontactSetupFutureUsageOffSession OrderPaymentSettingsPaymentMethodOptionsBancontactSetupFutureUsage = "off_session" +) + +// Controls when the funds will be captured from the customer's account. +type OrderPaymentSettingsPaymentMethodOptionsCardCaptureMethod string + +// List of values that OrderPaymentSettingsPaymentMethodOptionsCardCaptureMethod can take +const ( + OrderPaymentSettingsPaymentMethodOptionsCardCaptureMethodAutomatic OrderPaymentSettingsPaymentMethodOptionsCardCaptureMethod = "automatic" + OrderPaymentSettingsPaymentMethodOptionsCardCaptureMethodManual OrderPaymentSettingsPaymentMethodOptionsCardCaptureMethod = "manual" +) + +// Indicates that you intend to make future payments with the payment method. +// +// Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the order's Customer, if present, after the order's PaymentIntent is confirmed and any required actions from the user are complete. If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. +// +// When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). +// +// If `setup_future_usage` is already set and you are performing a request using a publishable key, you may only update the value from `on_session` to `off_session`. +type OrderPaymentSettingsPaymentMethodOptionsCardSetupFutureUsage string + +// List of values that OrderPaymentSettingsPaymentMethodOptionsCardSetupFutureUsage can take +const ( + OrderPaymentSettingsPaymentMethodOptionsCardSetupFutureUsageNone OrderPaymentSettingsPaymentMethodOptionsCardSetupFutureUsage = "none" + OrderPaymentSettingsPaymentMethodOptionsCardSetupFutureUsageOffSession OrderPaymentSettingsPaymentMethodOptionsCardSetupFutureUsage = "off_session" + OrderPaymentSettingsPaymentMethodOptionsCardSetupFutureUsageOnSession OrderPaymentSettingsPaymentMethodOptionsCardSetupFutureUsage = "on_session" +) + +// List of address types that should be returned in the financial_addresses response. If not specified, all valid types will be returned. +// +// Permitted values include: `sort_code`, `zengin`, `iban`, or `spei`. +type OrderPaymentSettingsPaymentMethodOptionsCustomerBalanceBankTransferRequestedAddressType string + +// List of values that OrderPaymentSettingsPaymentMethodOptionsCustomerBalanceBankTransferRequestedAddressType can take +const ( + OrderPaymentSettingsPaymentMethodOptionsCustomerBalanceBankTransferRequestedAddressTypeIBAN OrderPaymentSettingsPaymentMethodOptionsCustomerBalanceBankTransferRequestedAddressType = "iban" + OrderPaymentSettingsPaymentMethodOptionsCustomerBalanceBankTransferRequestedAddressTypeSEPA OrderPaymentSettingsPaymentMethodOptionsCustomerBalanceBankTransferRequestedAddressType = "sepa" + OrderPaymentSettingsPaymentMethodOptionsCustomerBalanceBankTransferRequestedAddressTypeSortCode OrderPaymentSettingsPaymentMethodOptionsCustomerBalanceBankTransferRequestedAddressType = "sort_code" + OrderPaymentSettingsPaymentMethodOptionsCustomerBalanceBankTransferRequestedAddressTypeSpei OrderPaymentSettingsPaymentMethodOptionsCustomerBalanceBankTransferRequestedAddressType = "spei" + OrderPaymentSettingsPaymentMethodOptionsCustomerBalanceBankTransferRequestedAddressTypeZengin OrderPaymentSettingsPaymentMethodOptionsCustomerBalanceBankTransferRequestedAddressType = "zengin" +) + +// The bank transfer type that this PaymentIntent is allowed to use for funding Permitted values include: `eu_bank_transfer`, `gb_bank_transfer`, `jp_bank_transfer`, or `mx_bank_transfer`. +type OrderPaymentSettingsPaymentMethodOptionsCustomerBalanceBankTransferType string + +// List of values that OrderPaymentSettingsPaymentMethodOptionsCustomerBalanceBankTransferType can take +const ( + OrderPaymentSettingsPaymentMethodOptionsCustomerBalanceBankTransferTypeEUBankTransfer OrderPaymentSettingsPaymentMethodOptionsCustomerBalanceBankTransferType = "eu_bank_transfer" + OrderPaymentSettingsPaymentMethodOptionsCustomerBalanceBankTransferTypeGBBankTransfer OrderPaymentSettingsPaymentMethodOptionsCustomerBalanceBankTransferType = "gb_bank_transfer" + OrderPaymentSettingsPaymentMethodOptionsCustomerBalanceBankTransferTypeJPBankTransfer OrderPaymentSettingsPaymentMethodOptionsCustomerBalanceBankTransferType = "jp_bank_transfer" + OrderPaymentSettingsPaymentMethodOptionsCustomerBalanceBankTransferTypeMXBankTransfer OrderPaymentSettingsPaymentMethodOptionsCustomerBalanceBankTransferType = "mx_bank_transfer" +) + +// The funding method type to be used when there are not enough funds in the customer balance. Permitted values include: `bank_transfer`. +type OrderPaymentSettingsPaymentMethodOptionsCustomerBalanceFundingType string + +// List of values that OrderPaymentSettingsPaymentMethodOptionsCustomerBalanceFundingType can take +const ( + OrderPaymentSettingsPaymentMethodOptionsCustomerBalanceFundingTypeBankTransfer OrderPaymentSettingsPaymentMethodOptionsCustomerBalanceFundingType = "bank_transfer" +) + +// Indicates that you intend to make future payments with this PaymentIntent's payment method. +// +// Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. +// +// When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). +type OrderPaymentSettingsPaymentMethodOptionsCustomerBalanceSetupFutureUsage string + +// List of values that OrderPaymentSettingsPaymentMethodOptionsCustomerBalanceSetupFutureUsage can take +const ( + OrderPaymentSettingsPaymentMethodOptionsCustomerBalanceSetupFutureUsageNone OrderPaymentSettingsPaymentMethodOptionsCustomerBalanceSetupFutureUsage = "none" +) + +// Indicates that you intend to make future payments with this PaymentIntent's payment method. +// +// Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. +// +// When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). +type OrderPaymentSettingsPaymentMethodOptionsIDEALSetupFutureUsage string + +// List of values that OrderPaymentSettingsPaymentMethodOptionsIDEALSetupFutureUsage can take +const ( + OrderPaymentSettingsPaymentMethodOptionsIDEALSetupFutureUsageNone OrderPaymentSettingsPaymentMethodOptionsIDEALSetupFutureUsage = "none" + OrderPaymentSettingsPaymentMethodOptionsIDEALSetupFutureUsageOffSession OrderPaymentSettingsPaymentMethodOptionsIDEALSetupFutureUsage = "off_session" +) + +// Controls when the funds will be captured from the customer's account. +type OrderPaymentSettingsPaymentMethodOptionsKlarnaCaptureMethod string + +// List of values that OrderPaymentSettingsPaymentMethodOptionsKlarnaCaptureMethod can take +const ( + OrderPaymentSettingsPaymentMethodOptionsKlarnaCaptureMethodManual OrderPaymentSettingsPaymentMethodOptionsKlarnaCaptureMethod = "manual" +) + +// Indicates that you intend to make future payments with this PaymentIntent's payment method. +// +// Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. +// +// When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). +type OrderPaymentSettingsPaymentMethodOptionsKlarnaSetupFutureUsage string + +// List of values that OrderPaymentSettingsPaymentMethodOptionsKlarnaSetupFutureUsage can take +const ( + OrderPaymentSettingsPaymentMethodOptionsKlarnaSetupFutureUsageNone OrderPaymentSettingsPaymentMethodOptionsKlarnaSetupFutureUsage = "none" +) + +// Controls when the funds will be captured from the customer's account. +type OrderPaymentSettingsPaymentMethodOptionsLinkCaptureMethod string + +// List of values that OrderPaymentSettingsPaymentMethodOptionsLinkCaptureMethod can take +const ( + OrderPaymentSettingsPaymentMethodOptionsLinkCaptureMethodManual OrderPaymentSettingsPaymentMethodOptionsLinkCaptureMethod = "manual" +) + +// Indicates that you intend to make future payments with this PaymentIntent's payment method. +// +// Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. +// +// When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). +type OrderPaymentSettingsPaymentMethodOptionsLinkSetupFutureUsage string + +// List of values that OrderPaymentSettingsPaymentMethodOptionsLinkSetupFutureUsage can take +const ( + OrderPaymentSettingsPaymentMethodOptionsLinkSetupFutureUsageNone OrderPaymentSettingsPaymentMethodOptionsLinkSetupFutureUsage = "none" + OrderPaymentSettingsPaymentMethodOptionsLinkSetupFutureUsageOffSession OrderPaymentSettingsPaymentMethodOptionsLinkSetupFutureUsage = "off_session" +) + +// Indicates that you intend to make future payments with this PaymentIntent's payment method. +// +// Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. +// +// When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). +type OrderPaymentSettingsPaymentMethodOptionsOXXOSetupFutureUsage string + +// List of values that OrderPaymentSettingsPaymentMethodOptionsOXXOSetupFutureUsage can take +const ( + OrderPaymentSettingsPaymentMethodOptionsOXXOSetupFutureUsageNone OrderPaymentSettingsPaymentMethodOptionsOXXOSetupFutureUsage = "none" +) + +// Indicates that you intend to make future payments with this PaymentIntent's payment method. +// +// Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. +// +// When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). +type OrderPaymentSettingsPaymentMethodOptionsP24SetupFutureUsage string + +// List of values that OrderPaymentSettingsPaymentMethodOptionsP24SetupFutureUsage can take +const ( + OrderPaymentSettingsPaymentMethodOptionsP24SetupFutureUsageNone OrderPaymentSettingsPaymentMethodOptionsP24SetupFutureUsage = "none" +) + +// Controls when the funds will be captured from the customer's account. +type OrderPaymentSettingsPaymentMethodOptionsPaypalCaptureMethod string + +// List of values that OrderPaymentSettingsPaymentMethodOptionsPaypalCaptureMethod can take +const ( + OrderPaymentSettingsPaymentMethodOptionsPaypalCaptureMethodManual OrderPaymentSettingsPaymentMethodOptionsPaypalCaptureMethod = "manual" +) + +// Indicates that you intend to make future payments with this PaymentIntent's payment method. +// +// Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. +// +// When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). +type OrderPaymentSettingsPaymentMethodOptionsSEPADebitSetupFutureUsage string + +// List of values that OrderPaymentSettingsPaymentMethodOptionsSEPADebitSetupFutureUsage can take +const ( + OrderPaymentSettingsPaymentMethodOptionsSEPADebitSetupFutureUsageNone OrderPaymentSettingsPaymentMethodOptionsSEPADebitSetupFutureUsage = "none" + OrderPaymentSettingsPaymentMethodOptionsSEPADebitSetupFutureUsageOffSession OrderPaymentSettingsPaymentMethodOptionsSEPADebitSetupFutureUsage = "off_session" + OrderPaymentSettingsPaymentMethodOptionsSEPADebitSetupFutureUsageOnSession OrderPaymentSettingsPaymentMethodOptionsSEPADebitSetupFutureUsage = "on_session" +) + +// Indicates that you intend to make future payments with this PaymentIntent's payment method. +// +// Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. +// +// When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). +type OrderPaymentSettingsPaymentMethodOptionsSofortSetupFutureUsage string + +// List of values that OrderPaymentSettingsPaymentMethodOptionsSofortSetupFutureUsage can take +const ( + OrderPaymentSettingsPaymentMethodOptionsSofortSetupFutureUsageNone OrderPaymentSettingsPaymentMethodOptionsSofortSetupFutureUsage = "none" + OrderPaymentSettingsPaymentMethodOptionsSofortSetupFutureUsageOffSession OrderPaymentSettingsPaymentMethodOptionsSofortSetupFutureUsage = "off_session" +) + +// The client type that the end customer will pay from +type OrderPaymentSettingsPaymentMethodOptionsWechatPayClient string + +// List of values that OrderPaymentSettingsPaymentMethodOptionsWechatPayClient can take +const ( + OrderPaymentSettingsPaymentMethodOptionsWechatPayClientAndroid OrderPaymentSettingsPaymentMethodOptionsWechatPayClient = "android" + OrderPaymentSettingsPaymentMethodOptionsWechatPayClientIOS OrderPaymentSettingsPaymentMethodOptionsWechatPayClient = "ios" + OrderPaymentSettingsPaymentMethodOptionsWechatPayClientWeb OrderPaymentSettingsPaymentMethodOptionsWechatPayClient = "web" +) + +// Indicates that you intend to make future payments with this PaymentIntent's payment method. +// +// Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. +// +// When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). +type OrderPaymentSettingsPaymentMethodOptionsWechatPaySetupFutureUsage string + +// List of values that OrderPaymentSettingsPaymentMethodOptionsWechatPaySetupFutureUsage can take +const ( + OrderPaymentSettingsPaymentMethodOptionsWechatPaySetupFutureUsageNone OrderPaymentSettingsPaymentMethodOptionsWechatPaySetupFutureUsage = "none" +) + +// The list of [payment method types](https://stripe.com/docs/payments/payment-methods/overview) to provide to the order's PaymentIntent. Do not include this attribute if you prefer to manage your payment methods from the [Stripe Dashboard](https://dashboard.stripe.com/settings/payment_methods). +type OrderPaymentSettingsPaymentMethodType string + +// List of values that OrderPaymentSettingsPaymentMethodType can take +const ( + OrderPaymentSettingsPaymentMethodTypeACSSDebit OrderPaymentSettingsPaymentMethodType = "acss_debit" + OrderPaymentSettingsPaymentMethodTypeAfterpayClearpay OrderPaymentSettingsPaymentMethodType = "afterpay_clearpay" + OrderPaymentSettingsPaymentMethodTypeAlipay OrderPaymentSettingsPaymentMethodType = "alipay" + OrderPaymentSettingsPaymentMethodTypeAUBECSDebit OrderPaymentSettingsPaymentMethodType = "au_becs_debit" + OrderPaymentSettingsPaymentMethodTypeBACSDebit OrderPaymentSettingsPaymentMethodType = "bacs_debit" + OrderPaymentSettingsPaymentMethodTypeBancontact OrderPaymentSettingsPaymentMethodType = "bancontact" + OrderPaymentSettingsPaymentMethodTypeCard OrderPaymentSettingsPaymentMethodType = "card" + OrderPaymentSettingsPaymentMethodTypeCustomerBalance OrderPaymentSettingsPaymentMethodType = "customer_balance" + OrderPaymentSettingsPaymentMethodTypeEPS OrderPaymentSettingsPaymentMethodType = "eps" + OrderPaymentSettingsPaymentMethodTypeFPX OrderPaymentSettingsPaymentMethodType = "fpx" + OrderPaymentSettingsPaymentMethodTypeGiropay OrderPaymentSettingsPaymentMethodType = "giropay" + OrderPaymentSettingsPaymentMethodTypeGrabpay OrderPaymentSettingsPaymentMethodType = "grabpay" + OrderPaymentSettingsPaymentMethodTypeIDEAL OrderPaymentSettingsPaymentMethodType = "ideal" + OrderPaymentSettingsPaymentMethodTypeKlarna OrderPaymentSettingsPaymentMethodType = "klarna" + OrderPaymentSettingsPaymentMethodTypeLink OrderPaymentSettingsPaymentMethodType = "link" + OrderPaymentSettingsPaymentMethodTypeOXXO OrderPaymentSettingsPaymentMethodType = "oxxo" + OrderPaymentSettingsPaymentMethodTypeP24 OrderPaymentSettingsPaymentMethodType = "p24" + OrderPaymentSettingsPaymentMethodTypePaypal OrderPaymentSettingsPaymentMethodType = "paypal" + OrderPaymentSettingsPaymentMethodTypeSEPADebit OrderPaymentSettingsPaymentMethodType = "sepa_debit" + OrderPaymentSettingsPaymentMethodTypeSofort OrderPaymentSettingsPaymentMethodType = "sofort" + OrderPaymentSettingsPaymentMethodTypeWechatPay OrderPaymentSettingsPaymentMethodType = "wechat_pay" +) + +// The status of the underlying payment associated with this order, if any. Null when the order is `open`. +type OrderPaymentStatus string + +// List of values that OrderPaymentStatus can take +const ( + OrderPaymentStatusCanceled OrderPaymentStatus = "canceled" + OrderPaymentStatusComplete OrderPaymentStatus = "complete" + OrderPaymentStatusNotRequired OrderPaymentStatus = "not_required" + OrderPaymentStatusProcessing OrderPaymentStatus = "processing" + OrderPaymentStatusRequiresAction OrderPaymentStatus = "requires_action" + OrderPaymentStatusRequiresCapture OrderPaymentStatus = "requires_capture" + OrderPaymentStatusRequiresConfirmation OrderPaymentStatus = "requires_confirmation" + OrderPaymentStatusRequiresPaymentMethod OrderPaymentStatus = "requires_payment_method" +) + +// The overall status of the order. type OrderStatus string -// List of values that OrderStatus can take. +// List of values that OrderStatus can take const ( - OrderStatusCanceled OrderStatus = "canceled" - OrderStatusCreated OrderStatus = "created" - OrderStatusFulfilled OrderStatus = "fulfilled" - OrderStatusPaid OrderStatus = "paid" - OrderStatusReturned OrderStatus = "returned" + OrderStatusCanceled OrderStatus = "canceled" + OrderStatusComplete OrderStatus = "complete" + OrderStatusOpen OrderStatus = "open" + OrderStatusProcessing OrderStatus = "processing" + OrderStatusSubmitted OrderStatus = "submitted" ) -// The type of estimate. Must be either `"range"` or `"exact"`. -type OrderDeliveryEstimateType string +// Describes the purchaser's tax exemption status. One of `none`, `exempt`, or `reverse`. +type OrderTaxDetailsTaxExempt string -// List of values that OrderDeliveryEstimateType can take +// List of values that OrderTaxDetailsTaxExempt can take const ( - OrderDeliveryEstimateTypeExact OrderDeliveryEstimateType = "exact" - OrderDeliveryEstimateTypeRange OrderDeliveryEstimateType = "range" + OrderTaxDetailsTaxExemptExempt OrderTaxDetailsTaxExempt = "exempt" + OrderTaxDetailsTaxExemptNone OrderTaxDetailsTaxExempt = "none" + OrderTaxDetailsTaxExemptReverse OrderTaxDetailsTaxExempt = "reverse" ) -// List of items constituting the order. An order can have up to 25 items. -type OrderItemParams struct { - Amount *int64 `form:"amount"` - Currency *string `form:"currency"` +// The type of the tax ID, one of `eu_vat`, `br_cnpj`, `br_cpf`, `eu_oss_vat`, `gb_vat`, `nz_gst`, `au_abn`, `au_arn`, `in_gst`, `no_vat`, `za_vat`, `ch_vat`, `mx_rfc`, `sg_uen`, `ru_inn`, `ru_kpp`, `ca_bn`, `hk_br`, `es_cif`, `tw_vat`, `th_vat`, `jp_cn`, `jp_rn`, `li_uid`, `my_itn`, `us_ein`, `kr_brn`, `ca_qst`, `ca_gst_hst`, `ca_pst_bc`, `ca_pst_mb`, `ca_pst_sk`, `my_sst`, `sg_gst`, `ae_trn`, `cl_tin`, `sa_vat`, `id_npwp`, `my_frp`, `il_vat`, `ge_vat`, `ua_vat`, `is_vat`, `bg_uic`, `hu_tin`, `si_tin`, or `unknown` +type OrderTaxDetailsTaxIDType string + +// List of values that OrderTaxDetailsTaxIDType can take +const ( + OrderTaxDetailsTaxIDTypeAETRN OrderTaxDetailsTaxIDType = "ae_trn" + OrderTaxDetailsTaxIDTypeAUABN OrderTaxDetailsTaxIDType = "au_abn" + OrderTaxDetailsTaxIDTypeAUARN OrderTaxDetailsTaxIDType = "au_arn" + OrderTaxDetailsTaxIDTypeBGUIC OrderTaxDetailsTaxIDType = "bg_uic" + OrderTaxDetailsTaxIDTypeBRCNPJ OrderTaxDetailsTaxIDType = "br_cnpj" + OrderTaxDetailsTaxIDTypeBRCPF OrderTaxDetailsTaxIDType = "br_cpf" + OrderTaxDetailsTaxIDTypeCABN OrderTaxDetailsTaxIDType = "ca_bn" + OrderTaxDetailsTaxIDTypeCAGSTHST OrderTaxDetailsTaxIDType = "ca_gst_hst" + OrderTaxDetailsTaxIDTypeCAPSTBC OrderTaxDetailsTaxIDType = "ca_pst_bc" + OrderTaxDetailsTaxIDTypeCAPSTMB OrderTaxDetailsTaxIDType = "ca_pst_mb" + OrderTaxDetailsTaxIDTypeCAPSTSK OrderTaxDetailsTaxIDType = "ca_pst_sk" + OrderTaxDetailsTaxIDTypeCAQST OrderTaxDetailsTaxIDType = "ca_qst" + OrderTaxDetailsTaxIDTypeCHVAT OrderTaxDetailsTaxIDType = "ch_vat" + OrderTaxDetailsTaxIDTypeCLTIN OrderTaxDetailsTaxIDType = "cl_tin" + OrderTaxDetailsTaxIDTypeESCIF OrderTaxDetailsTaxIDType = "es_cif" + OrderTaxDetailsTaxIDTypeEUOSSVAT OrderTaxDetailsTaxIDType = "eu_oss_vat" + OrderTaxDetailsTaxIDTypeEUVAT OrderTaxDetailsTaxIDType = "eu_vat" + OrderTaxDetailsTaxIDTypeGBVAT OrderTaxDetailsTaxIDType = "gb_vat" + OrderTaxDetailsTaxIDTypeGEVAT OrderTaxDetailsTaxIDType = "ge_vat" + OrderTaxDetailsTaxIDTypeHKBR OrderTaxDetailsTaxIDType = "hk_br" + OrderTaxDetailsTaxIDTypeHUTIN OrderTaxDetailsTaxIDType = "hu_tin" + OrderTaxDetailsTaxIDTypeIDNPWP OrderTaxDetailsTaxIDType = "id_npwp" + OrderTaxDetailsTaxIDTypeILVAT OrderTaxDetailsTaxIDType = "il_vat" + OrderTaxDetailsTaxIDTypeINGST OrderTaxDetailsTaxIDType = "in_gst" + OrderTaxDetailsTaxIDTypeISVAT OrderTaxDetailsTaxIDType = "is_vat" + OrderTaxDetailsTaxIDTypeJPCN OrderTaxDetailsTaxIDType = "jp_cn" + OrderTaxDetailsTaxIDTypeJPRN OrderTaxDetailsTaxIDType = "jp_rn" + OrderTaxDetailsTaxIDTypeKRBRN OrderTaxDetailsTaxIDType = "kr_brn" + OrderTaxDetailsTaxIDTypeLIUID OrderTaxDetailsTaxIDType = "li_uid" + OrderTaxDetailsTaxIDTypeMXRFC OrderTaxDetailsTaxIDType = "mx_rfc" + OrderTaxDetailsTaxIDTypeMYFRP OrderTaxDetailsTaxIDType = "my_frp" + OrderTaxDetailsTaxIDTypeMYITN OrderTaxDetailsTaxIDType = "my_itn" + OrderTaxDetailsTaxIDTypeMYSST OrderTaxDetailsTaxIDType = "my_sst" + OrderTaxDetailsTaxIDTypeNOVAT OrderTaxDetailsTaxIDType = "no_vat" + OrderTaxDetailsTaxIDTypeNZGST OrderTaxDetailsTaxIDType = "nz_gst" + OrderTaxDetailsTaxIDTypeRUINN OrderTaxDetailsTaxIDType = "ru_inn" + OrderTaxDetailsTaxIDTypeRUKPP OrderTaxDetailsTaxIDType = "ru_kpp" + OrderTaxDetailsTaxIDTypeSAVAT OrderTaxDetailsTaxIDType = "sa_vat" + OrderTaxDetailsTaxIDTypeSGGST OrderTaxDetailsTaxIDType = "sg_gst" + OrderTaxDetailsTaxIDTypeSGUEN OrderTaxDetailsTaxIDType = "sg_uen" + OrderTaxDetailsTaxIDTypeSITIN OrderTaxDetailsTaxIDType = "si_tin" + OrderTaxDetailsTaxIDTypeTHVAT OrderTaxDetailsTaxIDType = "th_vat" + OrderTaxDetailsTaxIDTypeTWVAT OrderTaxDetailsTaxIDType = "tw_vat" + OrderTaxDetailsTaxIDTypeUAVAT OrderTaxDetailsTaxIDType = "ua_vat" + OrderTaxDetailsTaxIDTypeUnknown OrderTaxDetailsTaxIDType = "unknown" + OrderTaxDetailsTaxIDTypeUSEIN OrderTaxDetailsTaxIDType = "us_ein" + OrderTaxDetailsTaxIDTypeZAVAT OrderTaxDetailsTaxIDType = "za_vat" +) + +// Settings for automatic tax calculation for this order. +type OrderAutomaticTaxParams struct { + // Enable automatic tax calculation which will automatically compute tax rates on this order. + Enabled *bool `form:"enabled"` +} + +// Billing details for the customer. If a customer is provided, this will be automatically populated with values from that customer if override values are not provided. +type OrderBillingDetailsParams struct { + // The billing address provided by the customer. + Address *AddressParams `form:"address"` + // The billing email provided by the customer. + Email *string `form:"email"` + // The billing name provided by the customer. + Name *string `form:"name"` + // The billing phone number provided by the customer. + Phone *string `form:"phone"` +} + +// The coupons, promotion codes, and/or discounts to apply to the order. +type OrderDiscountParams struct { + // ID of the coupon to create a new discount for. + Coupon *string `form:"coupon"` + // ID of an existing discount on the object (or one of its ancestors) to reuse. + Discount *string `form:"discount"` + // ID of the promotion code to create a new discount for. + PromotionCode *string `form:"promotion_code"` +} + +// The discounts applied to this line item. +type OrderLineItemDiscountParams struct { + // ID of the coupon to create a new discount for. + Coupon *string `form:"coupon"` + // ID of an existing discount on the object (or one of its ancestors) to reuse. + Discount *string `form:"discount"` +} + +// Data used to generate a new [Price](https://stripe.com/docs/api/prices) object inline. One of `product` (with default price) or `price` or `price_data` is required. +type OrderLineItemPriceDataParams struct { + // Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](https://stripe.com/docs/currencies). + Currency *string `form:"currency"` + // The ID of the product that this price will belong to. + Product *string `form:"product"` + // Specifies whether the price is considered inclusive of taxes or exclusive of taxes. One of `inclusive`, `exclusive`, or `unspecified`. Once specified as either `inclusive` or `exclusive`, it cannot be changed. + TaxBehavior *string `form:"tax_behavior"` + // A positive integer in cents (or local equivalent) (or 0 for a free price) representing how much to charge. + UnitAmount *int64 `form:"unit_amount"` + // Same as `unit_amount`, but accepts a decimal value in cents (or local equivalent) with at most 12 decimal places. Only one of `unit_amount` and `unit_amount_decimal` can be set. + UnitAmountDecimal *float64 `form:"unit_amount_decimal,high_precision"` +} + +// A list of line items the customer is ordering. Each line item includes information about the product, the quantity, and the resulting cost. +type OrderLineItemParams struct { + // The description for the line item. Will default to the name of the associated product. Description *string `form:"description"` - // The ID of the SKU being ordered. - Parent *string `form:"parent"` - // The quantity of this order item. When type is `sku`, this is the number of instances of the SKU to be ordered. - Quantity *int64 `form:"quantity"` - Type *string `form:"type"` + // The discounts applied to this line item. + Discounts []*OrderLineItemDiscountParams `form:"discounts"` + // The ID of an existing line item on the order. + ID *string `form:"id"` + // The ID of the price object. One of `product` (with default price) or `price` or `price_data` is required. + Price *string `form:"price"` + // Data used to generate a new [Price](https://stripe.com/docs/api/prices) object inline. One of `product` (with default price) or `price` or `price_data` is required. + PriceData *OrderLineItemPriceDataParams `form:"price_data"` + // The product of the line item. The product must have a default price specified. One of `product` (with default price) or `price` or `price_data` is required. + Product *string `form:"product"` + // The quantity of the line item. + Quantity *int64 `form:"quantity"` + // The tax rates applied to this line item. + TaxRates []*string `form:"tax_rates"` +} + +// Additional fields for Mandate creation +type OrderPaymentSettingsPaymentMethodOptionsACSSDebitMandateOptionsParams struct { + // A URL for custom mandate text to render during confirmation step. + // The URL will be rendered with additional GET parameters `payment_intent` and `payment_intent_client_secret` when confirming a Payment Intent, + // or `setup_intent` and `setup_intent_client_secret` when confirming a Setup Intent. + CustomMandateURL *string `form:"custom_mandate_url"` + // Description of the mandate interval. Only required if 'payment_schedule' parameter is 'interval' or 'combined'. + IntervalDescription *string `form:"interval_description"` + // Payment schedule for the mandate. + PaymentSchedule *string `form:"payment_schedule"` + // Transaction type of the mandate. + TransactionType *string `form:"transaction_type"` +} + +// If paying by `acss_debit`, this sub-hash contains details about the ACSS Debit payment method options to pass to the order's PaymentIntent. +type OrderPaymentSettingsPaymentMethodOptionsACSSDebitParams struct { + // Additional fields for Mandate creation + MandateOptions *OrderPaymentSettingsPaymentMethodOptionsACSSDebitMandateOptionsParams `form:"mandate_options"` + // Indicates that you intend to make future payments with this PaymentIntent's payment method. + // + // Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. + // + // When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). + // + // If `setup_future_usage` is already set and you are performing a request using a publishable key, you may only update the value from `on_session` to `off_session`. + SetupFutureUsage *string `form:"setup_future_usage"` + // Verification method for the intent + VerificationMethod *string `form:"verification_method"` +} + +// If paying by `afterpay_clearpay`, this sub-hash contains details about the AfterpayClearpay payment method options to pass to the order's PaymentIntent. +type OrderPaymentSettingsPaymentMethodOptionsAfterpayClearpayParams struct { + // Controls when the funds will be captured from the customer's account. + // + // If provided, this parameter will override the top-level `capture_method` when finalizing the payment with this payment method type. + // + // If `capture_method` is already set on the PaymentIntent, providing an empty value for this parameter will unset the stored value for this payment method type. + CaptureMethod *string `form:"capture_method"` + // Order identifier shown to the customer in Afterpay's online portal. We recommend using a value that helps you answer any questions a customer might have about + // the payment. The identifier is limited to 128 characters and may contain only letters, digits, underscores, backslashes and dashes. + Reference *string `form:"reference"` + // Indicates that you intend to make future payments with the payment method. + // + // Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the order's Customer, if present, after the order's PaymentIntent is confirmed and any required actions from the user are complete. If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. + // + // When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). + // + // If `setup_future_usage` is already set and you are performing a request using a publishable key, you may only update the value from `on_session` to `off_session`. + SetupFutureUsage *string `form:"setup_future_usage"` +} + +// If paying by `alipay`, this sub-hash contains details about the Alipay payment method options to pass to the order's PaymentIntent. +type OrderPaymentSettingsPaymentMethodOptionsAlipayParams struct { + // Indicates that you intend to make future payments with this PaymentIntent's payment method. + // + // Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. + // + // When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). + // + // If `setup_future_usage` is already set and you are performing a request using a publishable key, you may only update the value from `on_session` to `off_session`. + SetupFutureUsage *string `form:"setup_future_usage"` +} + +// If paying by `bancontact`, this sub-hash contains details about the Bancontact payment method options to pass to the order's PaymentIntent. +type OrderPaymentSettingsPaymentMethodOptionsBancontactParams struct { + // Preferred language of the Bancontact authorization page that the customer is redirected to. + PreferredLanguage *string `form:"preferred_language"` + // Indicates that you intend to make future payments with this PaymentIntent's payment method. + // + // Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. + // + // When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). + // + // If `setup_future_usage` is already set and you are performing a request using a publishable key, you may only update the value from `on_session` to `off_session`. + SetupFutureUsage *string `form:"setup_future_usage"` +} + +// If paying by `card`, this sub-hash contains details about the Card payment method options to pass to the order's PaymentIntent. +type OrderPaymentSettingsPaymentMethodOptionsCardParams struct { + // Controls when the funds will be captured from the customer's account. + CaptureMethod *string `form:"capture_method"` + // Indicates that you intend to make future payments with the payment method. + // + // Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the order's Customer, if present, after the order's PaymentIntent is confirmed and any required actions from the user are complete. If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. + // + // When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). + // + // If `setup_future_usage` is already set and you are performing a request using a publishable key, you may only update the value from `on_session` to `off_session`. + SetupFutureUsage *string `form:"setup_future_usage"` +} +type OrderPaymentSettingsPaymentMethodOptionsCustomerBalanceBankTransferEUBankTransferParams struct { + // The desired country code of the bank account information. Permitted values include: `DE`, `ES`, `FR`, `IE`, or `NL`. + Country *string `form:"country"` +} + +// Configuration for the bank transfer funding type, if the `funding_type` is set to `bank_transfer`. +type OrderPaymentSettingsPaymentMethodOptionsCustomerBalanceBankTransferParams struct { + EUBankTransfer *OrderPaymentSettingsPaymentMethodOptionsCustomerBalanceBankTransferEUBankTransferParams `form:"eu_bank_transfer"` + // List of address types that should be returned in the financial_addresses response. If not specified, all valid types will be returned. + // + // Permitted values include: `sort_code`, `zengin`, `iban`, or `spei`. + RequestedAddressTypes []*string `form:"requested_address_types"` + // The list of bank transfer types that this PaymentIntent is allowed to use for funding Permitted values include: `eu_bank_transfer`, `gb_bank_transfer`, `jp_bank_transfer`, or `mx_bank_transfer`. + Type *string `form:"type"` +} + +// If paying by `customer_balance`, this sub-hash contains details about the Customer Balance payment method options to pass to the order's PaymentIntent. +type OrderPaymentSettingsPaymentMethodOptionsCustomerBalanceParams struct { + // Configuration for the bank transfer funding type, if the `funding_type` is set to `bank_transfer`. + BankTransfer *OrderPaymentSettingsPaymentMethodOptionsCustomerBalanceBankTransferParams `form:"bank_transfer"` + // The funding method type to be used when there are not enough funds in the customer balance. Permitted values include: `bank_transfer`. + FundingType *string `form:"funding_type"` + // Indicates that you intend to make future payments with this PaymentIntent's payment method. + // + // Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. + // + // When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). + // + // If `setup_future_usage` is already set and you are performing a request using a publishable key, you may only update the value from `on_session` to `off_session`. + SetupFutureUsage *string `form:"setup_future_usage"` +} + +// If paying by `ideal`, this sub-hash contains details about the iDEAL payment method options to pass to the order's PaymentIntent. +type OrderPaymentSettingsPaymentMethodOptionsIDEALParams struct { + // Indicates that you intend to make future payments with this PaymentIntent's payment method. + // + // Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. + // + // When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). + // + // If `setup_future_usage` is already set and you are performing a request using a publishable key, you may only update the value from `on_session` to `off_session`. + SetupFutureUsage *string `form:"setup_future_usage"` +} + +// If paying by `klarna`, this sub-hash contains details about the Klarna payment method options to pass to the order's PaymentIntent. +type OrderPaymentSettingsPaymentMethodOptionsKlarnaParams struct { + // Controls when the funds will be captured from the customer's account. + // + // If provided, this parameter will override the top-level `capture_method` when finalizing the payment with this payment method type. + // + // If `capture_method` is already set on the PaymentIntent, providing an empty value for this parameter will unset the stored value for this payment method type. + CaptureMethod *string `form:"capture_method"` + // Preferred language of the Klarna authorization page that the customer is redirected to + PreferredLocale *string `form:"preferred_locale"` + // Indicates that you intend to make future payments with this PaymentIntent's payment method. + // + // Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. + // + // When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). + // + // If `setup_future_usage` is already set and you are performing a request using a publishable key, you may only update the value from `on_session` to `off_session`. + SetupFutureUsage *string `form:"setup_future_usage"` +} + +// If paying by `link`, this sub-hash contains details about the Link payment method options to pass to the order's PaymentIntent. +type OrderPaymentSettingsPaymentMethodOptionsLinkParams struct { + // Controls when the funds will be captured from the customer's account. + // + // If provided, this parameter will override the top-level `capture_method` when finalizing the payment with this payment method type. + // + // If `capture_method` is already set on the PaymentIntent, providing an empty value for this parameter will unset the stored value for this payment method type. + CaptureMethod *string `form:"capture_method"` + // Token used for persistent Link logins. + PersistentToken *string `form:"persistent_token"` + // Indicates that you intend to make future payments with this PaymentIntent's payment method. + // + // Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. + // + // When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). + // + // If `setup_future_usage` is already set and you are performing a request using a publishable key, you may only update the value from `on_session` to `off_session`. + SetupFutureUsage *string `form:"setup_future_usage"` +} + +// If paying by `oxxo`, this sub-hash contains details about the OXXO payment method options to pass to the order's PaymentIntent. +type OrderPaymentSettingsPaymentMethodOptionsOXXOParams struct { + // The number of calendar days before an OXXO voucher expires. For example, if you create an OXXO voucher on Monday and you set expires_after_days to 2, the OXXO invoice will expire on Wednesday at 23:59 America/Mexico_City time. + ExpiresAfterDays *int64 `form:"expires_after_days"` + // Indicates that you intend to make future payments with this PaymentIntent's payment method. + // + // Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. + // + // When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). + // + // If `setup_future_usage` is already set and you are performing a request using a publishable key, you may only update the value from `on_session` to `off_session`. + SetupFutureUsage *string `form:"setup_future_usage"` +} + +// If paying by `p24`, this sub-hash contains details about the P24 payment method options to pass to the order's PaymentIntent. +type OrderPaymentSettingsPaymentMethodOptionsP24Params struct { + // Indicates that you intend to make future payments with this PaymentIntent's payment method. + // + // Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. + // + // When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). + // + // If `setup_future_usage` is already set and you are performing a request using a publishable key, you may only update the value from `on_session` to `off_session`. + SetupFutureUsage *string `form:"setup_future_usage"` + // Confirm that the payer has accepted the P24 terms and conditions. + TOSShownAndAccepted *bool `form:"tos_shown_and_accepted"` +} + +// Additional fields for Mandate creation +type OrderPaymentSettingsPaymentMethodOptionsSEPADebitMandateOptionsParams struct{} + +// If paying by `sepa_debit`, this sub-hash contains details about the SEPA Debit payment method options to pass to the order's PaymentIntent. +type OrderPaymentSettingsPaymentMethodOptionsSEPADebitParams struct { + // Additional fields for Mandate creation + MandateOptions *OrderPaymentSettingsPaymentMethodOptionsSEPADebitMandateOptionsParams `form:"mandate_options"` + // Indicates that you intend to make future payments with this PaymentIntent's payment method. + // + // Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. + // + // When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). + // + // If `setup_future_usage` is already set and you are performing a request using a publishable key, you may only update the value from `on_session` to `off_session`. + SetupFutureUsage *string `form:"setup_future_usage"` +} + +// If paying by `sofort`, this sub-hash contains details about the Sofort payment method options to pass to the order's PaymentIntent. +type OrderPaymentSettingsPaymentMethodOptionsSofortParams struct { + // Language shown to the payer on redirect. + PreferredLanguage *string `form:"preferred_language"` + // Indicates that you intend to make future payments with this PaymentIntent's payment method. + // + // Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. + // + // When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). + // + // If `setup_future_usage` is already set and you are performing a request using a publishable key, you may only update the value from `on_session` to `off_session`. + SetupFutureUsage *string `form:"setup_future_usage"` +} + +// If paying by `wechat_pay`, this sub-hash contains details about the WeChat Pay payment method options to pass to the order's PaymentIntent. +type OrderPaymentSettingsPaymentMethodOptionsWechatPayParams struct { + // The app ID registered with WeChat Pay. Only required when client is ios or android. + AppID *string `form:"app_id"` + // The client type that the end customer will pay from + Client *string `form:"client"` + // Indicates that you intend to make future payments with this PaymentIntent's payment method. + // + // Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. + // + // When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). + // + // If `setup_future_usage` is already set and you are performing a request using a publishable key, you may only update the value from `on_session` to `off_session`. + SetupFutureUsage *string `form:"setup_future_usage"` +} + +// PaymentMethod-specific configuration to provide to the order's PaymentIntent. +type OrderPaymentSettingsPaymentMethodOptionsParams struct { + // If paying by `acss_debit`, this sub-hash contains details about the ACSS Debit payment method options to pass to the order's PaymentIntent. + ACSSDebit *OrderPaymentSettingsPaymentMethodOptionsACSSDebitParams `form:"acss_debit"` + // If paying by `afterpay_clearpay`, this sub-hash contains details about the AfterpayClearpay payment method options to pass to the order's PaymentIntent. + AfterpayClearpay *OrderPaymentSettingsPaymentMethodOptionsAfterpayClearpayParams `form:"afterpay_clearpay"` + // If paying by `alipay`, this sub-hash contains details about the Alipay payment method options to pass to the order's PaymentIntent. + Alipay *OrderPaymentSettingsPaymentMethodOptionsAlipayParams `form:"alipay"` + // If paying by `bancontact`, this sub-hash contains details about the Bancontact payment method options to pass to the order's PaymentIntent. + Bancontact *OrderPaymentSettingsPaymentMethodOptionsBancontactParams `form:"bancontact"` + // If paying by `card`, this sub-hash contains details about the Card payment method options to pass to the order's PaymentIntent. + Card *OrderPaymentSettingsPaymentMethodOptionsCardParams `form:"card"` + // If paying by `customer_balance`, this sub-hash contains details about the Customer Balance payment method options to pass to the order's PaymentIntent. + CustomerBalance *OrderPaymentSettingsPaymentMethodOptionsCustomerBalanceParams `form:"customer_balance"` + // If paying by `ideal`, this sub-hash contains details about the iDEAL payment method options to pass to the order's PaymentIntent. + IDEAL *OrderPaymentSettingsPaymentMethodOptionsIDEALParams `form:"ideal"` + // If paying by `klarna`, this sub-hash contains details about the Klarna payment method options to pass to the order's PaymentIntent. + Klarna *OrderPaymentSettingsPaymentMethodOptionsKlarnaParams `form:"klarna"` + // If paying by `link`, this sub-hash contains details about the Link payment method options to pass to the order's PaymentIntent. + Link *OrderPaymentSettingsPaymentMethodOptionsLinkParams `form:"link"` + // If paying by `oxxo`, this sub-hash contains details about the OXXO payment method options to pass to the order's PaymentIntent. + OXXO *OrderPaymentSettingsPaymentMethodOptionsOXXOParams `form:"oxxo"` + // If paying by `p24`, this sub-hash contains details about the P24 payment method options to pass to the order's PaymentIntent. + P24 *OrderPaymentSettingsPaymentMethodOptionsP24Params `form:"p24"` + // If paying by `sepa_debit`, this sub-hash contains details about the SEPA Debit payment method options to pass to the order's PaymentIntent. + SEPADebit *OrderPaymentSettingsPaymentMethodOptionsSEPADebitParams `form:"sepa_debit"` + // If paying by `sofort`, this sub-hash contains details about the Sofort payment method options to pass to the order's PaymentIntent. + Sofort *OrderPaymentSettingsPaymentMethodOptionsSofortParams `form:"sofort"` + // If paying by `wechat_pay`, this sub-hash contains details about the WeChat Pay payment method options to pass to the order's PaymentIntent. + WechatPay *OrderPaymentSettingsPaymentMethodOptionsWechatPayParams `form:"wechat_pay"` +} + +// Provides configuration for completing a transfer for the order after it is paid. +type OrderPaymentSettingsTransferDataParams struct { + // The amount that will be transferred automatically when the order is paid. If no amount is set, the full amount is transferred. There cannot be any line items with recurring prices when using this field. + Amount *int64 `form:"amount"` + // ID of the Connected account receiving the transfer. + Destination *string `form:"destination"` +} + +// Settings describing how the order should configure generated PaymentIntents. +type OrderPaymentSettingsParams struct { + // 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. + ApplicationFeeAmount *int64 `form:"application_fee_amount"` + // PaymentMethod-specific configuration to provide to the order's PaymentIntent. + PaymentMethodOptions *OrderPaymentSettingsPaymentMethodOptionsParams `form:"payment_method_options"` + // The list of [payment method types](https://stripe.com/docs/payments/payment-methods/overview) to provide to the order's PaymentIntent. Do not include this attribute if you prefer to manage your payment methods from the [Stripe Dashboard](https://dashboard.stripe.com/settings/payment_methods). + PaymentMethodTypes []*string `form:"payment_method_types"` + // The URL to redirect the customer to after they authenticate their payment. + ReturnURL *string `form:"return_url"` + // For non-card charges, you can use this value as the complete description that appears on your customers' statements. Must contain at least one letter, maximum 22 characters. + StatementDescriptor *string `form:"statement_descriptor"` + // Provides information about a card payment that customers see on their statements. Concatenated with the prefix (shortened descriptor) or statement descriptor that's set on the account to form the complete statement descriptor. Maximum 22 characters for the concatenated descriptor. + StatementDescriptorSuffix *string `form:"statement_descriptor_suffix"` + // Provides configuration for completing a transfer for the order after it is paid. + TransferData *OrderPaymentSettingsTransferDataParams `form:"transfer_data"` +} + +// Payment information associated with the order, including payment settings. +type OrderPaymentParams struct { + // Settings describing how the order should configure generated PaymentIntents. + Settings *OrderPaymentSettingsParams `form:"settings"` +} + +// The upper bound of the estimated range. If empty, represents no upper bound i.e., infinite. +type OrderShippingCostShippingRateDataDeliveryEstimateMaximumParams struct { + // A unit of time. + Unit *string `form:"unit"` + // Must be greater than 0. + Value *int64 `form:"value"` +} + +// The lower bound of the estimated range. If empty, represents no lower bound. +type OrderShippingCostShippingRateDataDeliveryEstimateMinimumParams struct { + // A unit of time. + Unit *string `form:"unit"` + // Must be greater than 0. + Value *int64 `form:"value"` +} + +// The estimated range for how long shipping will take, meant to be displayable to the customer. This will appear on CheckoutSessions. +type OrderShippingCostShippingRateDataDeliveryEstimateParams struct { + // The upper bound of the estimated range. If empty, represents no upper bound i.e., infinite. + Maximum *OrderShippingCostShippingRateDataDeliveryEstimateMaximumParams `form:"maximum"` + // The lower bound of the estimated range. If empty, represents no lower bound. + Minimum *OrderShippingCostShippingRateDataDeliveryEstimateMinimumParams `form:"minimum"` +} + +// Shipping rates defined in each available currency option. Each key must be a three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html) and a [supported currency](https://stripe.com/docs/currencies). +type OrderShippingCostShippingRateDataFixedAmountCurrencyOptionsParams struct { + // A non-negative integer in cents representing how much to charge. + Amount *int64 `form:"amount"` + // Specifies whether the rate is considered inclusive of taxes or exclusive of taxes. One of `inclusive`, `exclusive`, or `unspecified`. + TaxBehavior *string `form:"tax_behavior"` +} + +// Describes a fixed amount to charge for shipping. Must be present if type is `fixed_amount`. +type OrderShippingCostShippingRateDataFixedAmountParams struct { + // A non-negative integer in cents representing how much to charge. + Amount *int64 `form:"amount"` + // Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](https://stripe.com/docs/currencies). + Currency *string `form:"currency"` + // Shipping rates defined in each available currency option. Each key must be a three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html) and a [supported currency](https://stripe.com/docs/currencies). + CurrencyOptions map[string]*OrderShippingCostShippingRateDataFixedAmountCurrencyOptionsParams `form:"currency_options"` +} + +// Parameters to create a new ad-hoc shipping rate for this order. +type OrderShippingCostShippingRateDataParams struct { + // The estimated range for how long shipping will take, meant to be displayable to the customer. This will appear on CheckoutSessions. + DeliveryEstimate *OrderShippingCostShippingRateDataDeliveryEstimateParams `form:"delivery_estimate"` + // The name of the shipping rate, meant to be displayable to the customer. This will appear on CheckoutSessions. + DisplayName *string `form:"display_name"` + // Describes a fixed amount to charge for shipping. Must be present if type is `fixed_amount`. + FixedAmount *OrderShippingCostShippingRateDataFixedAmountParams `form:"fixed_amount"` + // Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format. Individual keys can be unset by posting an empty value to them. All keys can be unset by posting an empty value to `metadata`. + Metadata map[string]string `form:"metadata"` + // Specifies whether the rate is considered inclusive of taxes or exclusive of taxes. One of `inclusive`, `exclusive`, or `unspecified`. + TaxBehavior *string `form:"tax_behavior"` + // A [tax code](https://stripe.com/docs/tax/tax-categories) ID. The Shipping tax code is `txcd_92010001`. + TaxCode *string `form:"tax_code"` + // The type of calculation to use on the shipping rate. Can only be `fixed_amount` for now. + Type *string `form:"type"` +} + +// Settings for the customer cost of shipping for this order. +type OrderShippingCostParams struct { + // The ID of the shipping rate to use for this order. + ShippingRate *string `form:"shipping_rate"` + // Parameters to create a new ad-hoc shipping rate for this order. + ShippingRateData *OrderShippingCostShippingRateDataParams `form:"shipping_rate_data"` } -// Shipping address for the order. Required if any of the SKUs are for products that have `shippable` set to true. -type ShippingParams struct { - // Customer shipping address. +// Shipping details for the order. +type OrderShippingDetailsParams struct { + // The shipping address for the order. Address *AddressParams `form:"address"` - // The name of the carrier like `USPS`, `UPS`, or `FedEx`. - Carrier *string `form:"carrier"` - // Customer name. + // The name of the recipient of the order. Name *string `form:"name"` - // Customer phone (including extension). + // The phone number (including extension) for the recipient of the order. Phone *string `form:"phone"` - // The tracking number provided by the carrier. - TrackingNumber *string `form:"tracking_number"` } -// Creates a new order object. +// The purchaser's tax IDs to be used for this order. +type OrderTaxDetailsTaxIDParams struct { + // Type of the tax ID, one of `ae_trn`, `au_abn`, `au_arn`, `bg_uic`, `br_cnpj`, `br_cpf`, `ca_bn`, `ca_gst_hst`, `ca_pst_bc`, `ca_pst_mb`, `ca_pst_sk`, `ca_qst`, `ch_vat`, `cl_tin`, `es_cif`, `eu_oss_vat`, `eu_vat`, `gb_vat`, `ge_vat`, `hk_br`, `hu_tin`, `id_npwp`, `il_vat`, `in_gst`, `is_vat`, `jp_cn`, `jp_rn`, `kr_brn`, `li_uid`, `mx_rfc`, `my_frp`, `my_itn`, `my_sst`, `no_vat`, `nz_gst`, `ru_inn`, `ru_kpp`, `sa_vat`, `sg_gst`, `sg_uen`, `si_tin`, `th_vat`, `tw_vat`, `ua_vat`, `us_ein`, or `za_vat` + Type *string `form:"type"` + // Value of the tax ID. + Value *string `form:"value"` +} + +// Additional tax details about the purchaser to be used for this order. +type OrderTaxDetailsParams struct { + // The purchaser's tax exemption status. One of `none`, `exempt`, or `reverse`. + TaxExempt *string `form:"tax_exempt"` + // The purchaser's tax IDs to be used for this order. + TaxIDs []*OrderTaxDetailsTaxIDParams `form:"tax_ids"` +} + +// Creates a new open order object. type OrderParams struct { Params `form:"*"` - // A coupon code that represents a discount to be applied to this order. Must be one-time duration and in same currency as the order. An order can have multiple coupons. - Coupon *string `form:"coupon"` + // Settings for automatic tax calculation for this order. + AutomaticTax *OrderAutomaticTaxParams `form:"automatic_tax"` + // Billing details for the customer. If a customer is provided, this will be automatically populated with values from that customer if override values are not provided. + BillingDetails *OrderBillingDetailsParams `form:"billing_details"` // Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](https://stripe.com/docs/currencies). Currency *string `form:"currency"` - // The ID of an existing customer to use for this order. If provided, the customer email and shipping address will be used to create the order. Subsequently, the customer will also be charged to pay the order. If `email` or `shipping` are also provided, they will override the values retrieved from the customer object. + // The customer associated with this order. Customer *string `form:"customer"` - // The email address of the customer placing the order. - Email *string `form:"email"` - // List of items constituting the order. An order can have up to 25 items. - Items []*OrderItemParams `form:"items"` - // The shipping method to select for fulfilling this order. If specified, must be one of the `id`s of a shipping method in the `shipping_methods` array. If specified, will overwrite the existing selected shipping method, updating `items` as necessary. - SelectedShippingMethod *string `form:"selected_shipping_method"` - // Tracking information once the order has been fulfilled. - Shipping *ShippingParams `form:"shipping"` - // Current order status. One of `created`, `paid`, `canceled`, `fulfilled`, or `returned`. More detail in the [Orders Guide](https://stripe.com/docs/orders/guide#understanding-order-statuses). - Status *string `form:"status"` -} - -// Filter orders based on when they were paid, fulfilled, canceled, or returned. -type StatusTransitionsFilterParams struct { - // Date this order was canceled. - Canceled *int64 `form:"canceled"` - // Date this order was canceled. - CanceledRange *RangeQueryParams `form:"canceled"` - // Date this order was fulfilled. - Fulfilled *int64 `form:"fulfilled"` - // Date this order was fulfilled. - FulfilledRange *RangeQueryParams `form:"fulfilled"` - // Date this order was paid. - Paid *int64 `form:"paid"` - // Date this order was paid. - PaidRange *RangeQueryParams `form:"paid"` - // Date this order was returned. - Returned *int64 `form:"returned"` - // Date this order was returned. - ReturnedRange *RangeQueryParams `form:"returned"` + // An arbitrary string attached to the object. Often useful for displaying to users. + Description *string `form:"description"` + // The coupons, promotion codes, and/or discounts to apply to the order. Pass the empty string `""` to unset this field. + Discounts []*OrderDiscountParams `form:"discounts"` + // The IP address of the purchaser for this order. + IPAddress *string `form:"ip_address"` + // A list of line items the customer is ordering. Each line item includes information about the product, the quantity, and the resulting cost. + LineItems []*OrderLineItemParams `form:"line_items"` + // Payment information associated with the order, including payment settings. + Payment *OrderPaymentParams `form:"payment"` + // Settings for the customer cost of shipping for this order. + ShippingCost *OrderShippingCostParams `form:"shipping_cost"` + // Shipping details for the order. + ShippingDetails *OrderShippingDetailsParams `form:"shipping_details"` + // Additional tax details about the purchaser to be used for this order. + TaxDetails *OrderTaxDetailsParams `form:"tax_details"` } // Returns a list of your orders. The orders are returned sorted by creation date, with the most recently created orders appearing first. type OrderListParams struct { ListParams `form:"*"` - // Date this order was created. - Created *int64 `form:"created"` - // Date this order was created. - CreatedRange *RangeQueryParams `form:"created"` // Only return orders for the given customer. Customer *string `form:"customer"` - // Only return orders with the given IDs. - IDs []*string `form:"ids"` - // Only return orders that have the given status. One of `created`, `paid`, `fulfilled`, or `refunded`. - Status *string `form:"status"` - // Filter orders based on when they were paid, fulfilled, canceled, or returned. - StatusTransitions *StatusTransitionsFilterParams `form:"status_transitions"` - // Only return orders with the given upstream order IDs. - UpstreamIDs []*string `form:"upstream_ids"` -} - -// Pay an order by providing a source to create a payment. -type OrderPayParams struct { +} + +// Submitting an Order transitions the status to processing and creates a PaymentIntent object so the order can be paid. If the Order has an amount_total of 0, no PaymentIntent object will be created. Once the order is submitted, its contents cannot be changed, unless the [reopen](https://stripe.com/docs/api#reopen_order) method is called. +type OrderSubmitParams struct { Params `form:"*"` - // A fee in %s that will be applied to the order and transferred to the application owner's Stripe account. The request must be made with an OAuth key or the `Stripe-Account` header in order to take an application fee. For more information, see the application fees [documentation](https://stripe.com/docs/connect/direct-charges#collecting-fees). - ApplicationFee *int64 `form:"application_fee"` - // The ID of an existing customer that will be charged for this order. If no customer was attached to the order at creation, either `source` or `customer` is required. Otherwise, the specified customer will be charged instead of the one attached to the order. - Customer *string `form:"customer"` - // The email address of the customer placing the order. Required if not previously specified for the order. - Email *string `form:"email"` - Source *SourceParams `form:"*"` // SourceParams has custom encoding so brought to top level with "*" -} - -// SetSource adds valid sources to a OrderPayParams object, -// returning an error for unsupported sources. -func (p *OrderPayParams) SetSource(sp interface{}) error { - source, err := SourceParamsFor(sp) - p.Source = source - return err -} - -// The estimated delivery date for the given shipping method. Can be either a specific date or a range. -type DeliveryEstimate struct { - // If Type == Exact - // If `type` is `"exact"`, `date` will be the expected delivery date in the format YYYY-MM-DD. - Date string `json:"date"` - // If Type == Range - // If `type` is `"range"`, `earliest` will be be the earliest delivery date in the format YYYY-MM-DD. - Earliest string `json:"earliest"` - // If `type` is `"range"`, `latest` will be the latest delivery date in the format YYYY-MM-DD. - Latest string `json:"latest"` - // The type of estimate. Must be either `"range"` or `"exact"`. - Type OrderDeliveryEstimateType `json:"type"` -} - -// A list of supported shipping methods for this order. The desired shipping method can be specified either by updating the order, or when paying it. -type ShippingMethod struct { - // A positive integer in the smallest currency unit (that is, 100 cents for $1.00, or 1 for ¥1, Japanese Yen being a zero-decimal currency) representing the total amount for the line item. + // `expected_total` should always be set to the order's `amount_total` field. If they don't match, submitting the order will fail. This helps detect race conditions where something else concurrently modifies the order. + ExpectedTotal *int64 `form:"expected_total"` +} + +// Cancels the order as well as the payment intent if one is attached. +type OrderCancelParams struct { + Params `form:"*"` +} + +// Reopens a submitted order. +type OrderReopenParams struct { + Params `form:"*"` +} + +// When retrieving an order, there is an includable line_items property containing the first handful of those items. There is also a URL where you can retrieve the full (paginated) list of line items. +type OrderListLineItemsParams struct { + ListParams `form:"*"` + ID *string `form:"-"` // Included in URL +} +type OrderAutomaticTax struct { + // Whether Stripe automatically computes tax on this Order. + Enabled bool `json:"enabled"` + // The status of the most recent automated tax calculation for this Order. + Status OrderAutomaticTaxStatus `json:"status"` +} + +// Customer billing details associated with the order. +type OrderBillingDetails struct { + // Billing address for the order. + Address *Address `json:"address"` + // Email address for the order. + Email string `json:"email"` + // Full name for the order. + Name string `json:"name"` + // Billing phone number for the order (including extension). + Phone string `json:"phone"` +} + +// Indicates whether order has been opted into using [Stripe Dashboard](https://dashboard.stripe.com/settings/payment_methods) to manage payment method types. +type OrderPaymentSettingsAutomaticPaymentMethods struct { + // Whether this Order has been opted into managing payment method types via the [Stripe Dashboard](https://dashboard.stripe.com/settings/payment_methods). + Enabled bool `json:"enabled"` +} +type OrderPaymentSettingsPaymentMethodOptionsACSSDebitMandateOptions struct { + // A URL for custom mandate text + CustomMandateURL string `json:"custom_mandate_url"` + // Description of the interval. Only required if the 'payment_schedule' parameter is 'interval' or 'combined'. + IntervalDescription string `json:"interval_description"` + // Payment schedule for the mandate. + PaymentSchedule OrderPaymentSettingsPaymentMethodOptionsACSSDebitMandateOptionsPaymentSchedule `json:"payment_schedule"` + // Transaction type of the mandate. + TransactionType OrderPaymentSettingsPaymentMethodOptionsACSSDebitMandateOptionsTransactionType `json:"transaction_type"` +} +type OrderPaymentSettingsPaymentMethodOptionsACSSDebit struct { + MandateOptions *OrderPaymentSettingsPaymentMethodOptionsACSSDebitMandateOptions `json:"mandate_options"` + // Indicates that you intend to make future payments with this PaymentIntent's payment method. + // + // Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. + // + // When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). + SetupFutureUsage OrderPaymentSettingsPaymentMethodOptionsACSSDebitSetupFutureUsage `json:"setup_future_usage"` + // Bank account verification method. + VerificationMethod OrderPaymentSettingsPaymentMethodOptionsACSSDebitVerificationMethod `json:"verification_method"` +} +type OrderPaymentSettingsPaymentMethodOptionsAfterpayClearpay struct { + // Controls when the funds will be captured from the customer's account. + CaptureMethod OrderPaymentSettingsPaymentMethodOptionsAfterpayClearpayCaptureMethod `json:"capture_method"` + // Order identifier shown to the user in Afterpay's online portal. We recommend using a value that helps you answer any questions a customer might have about the payment. The identifier is limited to 128 characters and may contain only letters, digits, underscores, backslashes and dashes. + Reference string `json:"reference"` + // Indicates that you intend to make future payments with the payment method. + // + // Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the order's Customer, if present, after the order's PaymentIntent is confirmed and any required actions from the user are complete. If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. + // + // When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). + // + // If `setup_future_usage` is already set and you are performing a request using a publishable key, you may only update the value from `on_session` to `off_session`. + SetupFutureUsage OrderPaymentSettingsPaymentMethodOptionsAfterpayClearpaySetupFutureUsage `json:"setup_future_usage"` +} +type OrderPaymentSettingsPaymentMethodOptionsAlipay struct { + // Indicates that you intend to make future payments with this PaymentIntent's payment method. + // + // Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. + // + // When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). + SetupFutureUsage OrderPaymentSettingsPaymentMethodOptionsAlipaySetupFutureUsage `json:"setup_future_usage"` +} +type OrderPaymentSettingsPaymentMethodOptionsBancontact struct { + // Preferred language of the Bancontact authorization page that the customer is redirected to. + PreferredLanguage string `json:"preferred_language"` + // Indicates that you intend to make future payments with this PaymentIntent's payment method. + // + // Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. + // + // When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). + SetupFutureUsage OrderPaymentSettingsPaymentMethodOptionsBancontactSetupFutureUsage `json:"setup_future_usage"` +} +type OrderPaymentSettingsPaymentMethodOptionsCard struct { + // Controls when the funds will be captured from the customer's account. + CaptureMethod OrderPaymentSettingsPaymentMethodOptionsCardCaptureMethod `json:"capture_method"` + // Indicates that you intend to make future payments with the payment method. + // + // Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the order's Customer, if present, after the order's PaymentIntent is confirmed and any required actions from the user are complete. If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. + // + // When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). + // + // If `setup_future_usage` is already set and you are performing a request using a publishable key, you may only update the value from `on_session` to `off_session`. + SetupFutureUsage OrderPaymentSettingsPaymentMethodOptionsCardSetupFutureUsage `json:"setup_future_usage"` +} +type OrderPaymentSettingsPaymentMethodOptionsCustomerBalanceBankTransferEUBankTransfer struct { + // The desired country code of the bank account information. Permitted values include: `DE`, `ES`, `FR`, `IE`, or `NL`. + Country string `json:"country"` +} +type OrderPaymentSettingsPaymentMethodOptionsCustomerBalanceBankTransfer struct { + EUBankTransfer *OrderPaymentSettingsPaymentMethodOptionsCustomerBalanceBankTransferEUBankTransfer `json:"eu_bank_transfer"` + // List of address types that should be returned in the financial_addresses response. If not specified, all valid types will be returned. + // + // Permitted values include: `sort_code`, `zengin`, `iban`, or `spei`. + RequestedAddressTypes []OrderPaymentSettingsPaymentMethodOptionsCustomerBalanceBankTransferRequestedAddressType `json:"requested_address_types"` + // The bank transfer type that this PaymentIntent is allowed to use for funding Permitted values include: `eu_bank_transfer`, `gb_bank_transfer`, `jp_bank_transfer`, or `mx_bank_transfer`. + Type OrderPaymentSettingsPaymentMethodOptionsCustomerBalanceBankTransferType `json:"type"` +} +type OrderPaymentSettingsPaymentMethodOptionsCustomerBalance struct { + BankTransfer *OrderPaymentSettingsPaymentMethodOptionsCustomerBalanceBankTransfer `json:"bank_transfer"` + // The funding method type to be used when there are not enough funds in the customer balance. Permitted values include: `bank_transfer`. + FundingType OrderPaymentSettingsPaymentMethodOptionsCustomerBalanceFundingType `json:"funding_type"` + // Indicates that you intend to make future payments with this PaymentIntent's payment method. + // + // Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. + // + // When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). + SetupFutureUsage OrderPaymentSettingsPaymentMethodOptionsCustomerBalanceSetupFutureUsage `json:"setup_future_usage"` +} +type OrderPaymentSettingsPaymentMethodOptionsIDEAL struct { + // Indicates that you intend to make future payments with this PaymentIntent's payment method. + // + // Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. + // + // When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). + SetupFutureUsage OrderPaymentSettingsPaymentMethodOptionsIDEALSetupFutureUsage `json:"setup_future_usage"` +} +type OrderPaymentSettingsPaymentMethodOptionsKlarna struct { + // Controls when the funds will be captured from the customer's account. + CaptureMethod OrderPaymentSettingsPaymentMethodOptionsKlarnaCaptureMethod `json:"capture_method"` + // Preferred locale of the Klarna checkout page that the customer is redirected to. + PreferredLocale string `json:"preferred_locale"` + // Indicates that you intend to make future payments with this PaymentIntent's payment method. + // + // Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. + // + // When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). + SetupFutureUsage OrderPaymentSettingsPaymentMethodOptionsKlarnaSetupFutureUsage `json:"setup_future_usage"` +} +type OrderPaymentSettingsPaymentMethodOptionsLink struct { + // Controls when the funds will be captured from the customer's account. + CaptureMethod OrderPaymentSettingsPaymentMethodOptionsLinkCaptureMethod `json:"capture_method"` + // Token used for persistent Link logins. + PersistentToken string `json:"persistent_token"` + // Indicates that you intend to make future payments with this PaymentIntent's payment method. + // + // Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. + // + // When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). + SetupFutureUsage OrderPaymentSettingsPaymentMethodOptionsLinkSetupFutureUsage `json:"setup_future_usage"` +} +type OrderPaymentSettingsPaymentMethodOptionsOXXO struct { + // The number of calendar days before an OXXO invoice expires. For example, if you create an OXXO invoice on Monday and you set expires_after_days to 2, the OXXO invoice will expire on Wednesday at 23:59 America/Mexico_City time. + ExpiresAfterDays int64 `json:"expires_after_days"` + // Indicates that you intend to make future payments with this PaymentIntent's payment method. + // + // Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. + // + // When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). + SetupFutureUsage OrderPaymentSettingsPaymentMethodOptionsOXXOSetupFutureUsage `json:"setup_future_usage"` +} +type OrderPaymentSettingsPaymentMethodOptionsP24 struct { + // Indicates that you intend to make future payments with this PaymentIntent's payment method. + // + // Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. + // + // When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). + SetupFutureUsage OrderPaymentSettingsPaymentMethodOptionsP24SetupFutureUsage `json:"setup_future_usage"` +} +type OrderPaymentSettingsPaymentMethodOptionsPaypal struct { + // Controls when the funds will be captured from the customer's account. + CaptureMethod OrderPaymentSettingsPaymentMethodOptionsPaypalCaptureMethod `json:"capture_method"` + // Preferred locale of the PayPal checkout page that the customer is redirected to. + PreferredLocale string `json:"preferred_locale"` +} +type OrderPaymentSettingsPaymentMethodOptionsSEPADebitMandateOptions struct{} +type OrderPaymentSettingsPaymentMethodOptionsSEPADebit struct { + MandateOptions *OrderPaymentSettingsPaymentMethodOptionsSEPADebitMandateOptions `json:"mandate_options"` + // Indicates that you intend to make future payments with this PaymentIntent's payment method. + // + // Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. + // + // When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). + SetupFutureUsage OrderPaymentSettingsPaymentMethodOptionsSEPADebitSetupFutureUsage `json:"setup_future_usage"` +} +type OrderPaymentSettingsPaymentMethodOptionsSofort struct { + // Preferred language of the SOFORT authorization page that the customer is redirected to. + PreferredLanguage string `json:"preferred_language"` + // Indicates that you intend to make future payments with this PaymentIntent's payment method. + // + // Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. + // + // When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). + SetupFutureUsage OrderPaymentSettingsPaymentMethodOptionsSofortSetupFutureUsage `json:"setup_future_usage"` +} +type OrderPaymentSettingsPaymentMethodOptionsWechatPay struct { + // The app ID registered with WeChat Pay. Only required when client is ios or android. + AppID string `json:"app_id"` + // The client type that the end customer will pay from + Client OrderPaymentSettingsPaymentMethodOptionsWechatPayClient `json:"client"` + // Indicates that you intend to make future payments with this PaymentIntent's payment method. + // + // Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. + // + // When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). + SetupFutureUsage OrderPaymentSettingsPaymentMethodOptionsWechatPaySetupFutureUsage `json:"setup_future_usage"` +} + +// PaymentMethod-specific configuration to provide to the order's PaymentIntent. +type OrderPaymentSettingsPaymentMethodOptions struct { + ACSSDebit *OrderPaymentSettingsPaymentMethodOptionsACSSDebit `json:"acss_debit"` + AfterpayClearpay *OrderPaymentSettingsPaymentMethodOptionsAfterpayClearpay `json:"afterpay_clearpay"` + Alipay *OrderPaymentSettingsPaymentMethodOptionsAlipay `json:"alipay"` + Bancontact *OrderPaymentSettingsPaymentMethodOptionsBancontact `json:"bancontact"` + Card *OrderPaymentSettingsPaymentMethodOptionsCard `json:"card"` + CustomerBalance *OrderPaymentSettingsPaymentMethodOptionsCustomerBalance `json:"customer_balance"` + IDEAL *OrderPaymentSettingsPaymentMethodOptionsIDEAL `json:"ideal"` + Klarna *OrderPaymentSettingsPaymentMethodOptionsKlarna `json:"klarna"` + Link *OrderPaymentSettingsPaymentMethodOptionsLink `json:"link"` + OXXO *OrderPaymentSettingsPaymentMethodOptionsOXXO `json:"oxxo"` + P24 *OrderPaymentSettingsPaymentMethodOptionsP24 `json:"p24"` + Paypal *OrderPaymentSettingsPaymentMethodOptionsPaypal `json:"paypal"` + SEPADebit *OrderPaymentSettingsPaymentMethodOptionsSEPADebit `json:"sepa_debit"` + Sofort *OrderPaymentSettingsPaymentMethodOptionsSofort `json:"sofort"` + WechatPay *OrderPaymentSettingsPaymentMethodOptionsWechatPay `json:"wechat_pay"` +} + +// Provides configuration for completing a transfer for the order after it is paid. +type OrderPaymentSettingsTransferData struct { + // The amount that will be transferred automatically when the order is paid. If no amount is set, the full amount is transferred. There cannot be any line items with recurring prices when using this field. Amount int64 `json:"amount"` - // Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](https://stripe.com/docs/currencies). - Currency Currency `json:"currency"` - // The estimated delivery date for the given shipping method. Can be either a specific date or a range. - DeliveryEstimate *DeliveryEstimate `json:"delivery_estimate"` - // An arbitrary string attached to the object. Often useful for displaying to users. - Description string `json:"description"` - // Unique identifier for the object. - ID string `json:"id"` + // ID of the Connected account receiving the transfer. + Destination *Account `json:"destination"` } -// The timestamps at which the order status was updated. -type StatusTransitions struct { - // The time that the order was canceled. - Canceled int64 `json:"canceled"` - // The time that the order was fulfilled. - Fulfilled int64 `json:"fulfilled"` - // The time that the order was paid. - Paid int64 `json:"paid"` - // The time that the order was returned. - Returned int64 `json:"returned"` +// Settings describing how the order should configure generated PaymentIntents. +type OrderPaymentSettings struct { + // 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. + ApplicationFeeAmount int64 `json:"application_fee_amount"` + // Indicates whether order has been opted into using [Stripe Dashboard](https://dashboard.stripe.com/settings/payment_methods) to manage payment method types. + AutomaticPaymentMethods *OrderPaymentSettingsAutomaticPaymentMethods `json:"automatic_payment_methods"` + // PaymentMethod-specific configuration to provide to the order's PaymentIntent. + PaymentMethodOptions *OrderPaymentSettingsPaymentMethodOptions `json:"payment_method_options"` + // The list of [payment method types](https://stripe.com/docs/payments/payment-methods/overview) to provide to the order's PaymentIntent. Do not include this attribute if you prefer to manage your payment methods from the [Stripe Dashboard](https://dashboard.stripe.com/settings/payment_methods). + PaymentMethodTypes []OrderPaymentSettingsPaymentMethodType `json:"payment_method_types"` + // The URL to redirect the customer to after they authenticate their payment. + ReturnURL string `json:"return_url"` + // For non-card charges, you can use this value as the complete description that appears on your customers' statements. Must contain at least one letter, maximum 22 characters. + StatementDescriptor string `json:"statement_descriptor"` + // Provides information about a card payment that customers see on their statements. Concatenated with the prefix (shortened descriptor) or statement descriptor that's set on the account to form the complete statement descriptor. Maximum 22 characters for the concatenated descriptor. + StatementDescriptorSuffix string `json:"statement_descriptor_suffix"` + // Provides configuration for completing a transfer for the order after it is paid. + TransferData *OrderPaymentSettingsTransferData `json:"transfer_data"` +} +type OrderPayment struct { + // ID of the payment intent associated with this order. Null when the order is `open`. + PaymentIntent *PaymentIntent `json:"payment_intent"` + // Settings describing how the order should configure generated PaymentIntents. + Settings *OrderPaymentSettings `json:"settings"` + // The status of the underlying payment associated with this order, if any. Null when the order is `open`. + Status OrderPaymentStatus `json:"status"` } -// OrderUpdateParams is the set of parameters that can be used when updating an order. -type OrderUpdateParams struct { - Params `form:"*"` - Coupon *string `form:"coupon"` - SelectedShippingMethod *string `form:"selected_shipping_method"` - Shipping *OrderUpdateShippingParams `form:"shipping"` - Status *string `form:"status"` +// The taxes applied to the shipping rate. +type OrderShippingCostTax struct { + // Amount of tax applied for this rate. + Amount int64 `json:"amount"` + // Tax rates can be applied to [invoices](https://stripe.com/docs/billing/invoices/tax-rates), [subscriptions](https://stripe.com/docs/billing/subscriptions/taxes) and [Checkout Sessions](https://stripe.com/docs/payments/checkout/set-up-a-subscription#tax-rates) to collect tax. + // + // Related guide: [Tax Rates](https://stripe.com/docs/billing/taxes/tax-rates). + Rate *TaxRate `json:"rate"` } -// OrderUpdateShippingParams is the set of parameters that can be used for the shipping -// hash on order update. -type OrderUpdateShippingParams struct { - Carrier *string `form:"carrier"` - TrackingNumber *string `form:"tracking_number"` +// The details of the customer cost of shipping, including the customer chosen ShippingRate. +type OrderShippingCost struct { + // Total shipping cost before any discounts or taxes are applied. + AmountSubtotal int64 `json:"amount_subtotal"` + // Total tax amount applied due to shipping costs. If no tax was applied, defaults to 0. + AmountTax int64 `json:"amount_tax"` + // Total shipping cost after discounts and taxes are applied. + AmountTotal int64 `json:"amount_total"` + // The ID of the ShippingRate for this order. + ShippingRate *ShippingRate `json:"shipping_rate"` + // The taxes applied to the shipping rate. + Taxes []*OrderShippingCostTax `json:"taxes"` } -// Shipping describes the shipping hash on an order. -type Shipping struct { - Address *Address `json:"address"` - Carrier string `json:"carrier"` - Name string `json:"name"` - Phone string `json:"phone"` - TrackingNumber string `json:"tracking_number"` +// Customer shipping information associated with the order. +type OrderShippingDetails struct { + // Recipient shipping address. Required if the order includes products that are shippable. + Address *Address `json:"address"` + // Recipient name. + Name string `json:"name"` + // Recipient phone (including extension). + Phone string `json:"phone"` } -// Order objects are created to handle end customers' purchases of previously -// defined [products](https://stripe.com/docs/api#products). You can create, retrieve, and pay individual orders, as well -// as list all orders. Orders are identified by a unique, random ID. +// The purchaser's tax IDs to be used in calculation of tax for this Order. +type OrderTaxDetailsTaxID struct { + // The type of the tax ID, one of `eu_vat`, `br_cnpj`, `br_cpf`, `eu_oss_vat`, `gb_vat`, `nz_gst`, `au_abn`, `au_arn`, `in_gst`, `no_vat`, `za_vat`, `ch_vat`, `mx_rfc`, `sg_uen`, `ru_inn`, `ru_kpp`, `ca_bn`, `hk_br`, `es_cif`, `tw_vat`, `th_vat`, `jp_cn`, `jp_rn`, `li_uid`, `my_itn`, `us_ein`, `kr_brn`, `ca_qst`, `ca_gst_hst`, `ca_pst_bc`, `ca_pst_mb`, `ca_pst_sk`, `my_sst`, `sg_gst`, `ae_trn`, `cl_tin`, `sa_vat`, `id_npwp`, `my_frp`, `il_vat`, `ge_vat`, `ua_vat`, `is_vat`, `bg_uic`, `hu_tin`, `si_tin`, or `unknown` + Type OrderTaxDetailsTaxIDType `json:"type"` + // The value of the tax ID. + Value string `json:"value"` +} +type OrderTaxDetails struct { + // Describes the purchaser's tax exemption status. One of `none`, `exempt`, or `reverse`. + TaxExempt OrderTaxDetailsTaxExempt `json:"tax_exempt"` + // The purchaser's tax IDs to be used in calculation of tax for this Order. + TaxIDs []*OrderTaxDetailsTaxID `json:"tax_ids"` +} + +// The aggregated discounts. +type OrderTotalDetailsBreakdownDiscount struct { + // The amount discounted. + Amount int64 `json:"amount"` + // A discount represents the actual application of a [coupon](https://stripe.com/docs/api#coupons) or [promotion code](https://stripe.com/docs/api#promotion_codes). + // It contains information about when the discount began, when it will end, and what it is applied to. + // + // Related guide: [Applying Discounts to Subscriptions](https://stripe.com/docs/billing/subscriptions/discounts). + Discount *Discount `json:"discount"` +} + +// The aggregated tax amounts by rate. +type OrderTotalDetailsBreakdownTax struct { + // Amount of tax applied for this rate. + Amount int64 `json:"amount"` + // Tax rates can be applied to [invoices](https://stripe.com/docs/billing/invoices/tax-rates), [subscriptions](https://stripe.com/docs/billing/subscriptions/taxes) and [Checkout Sessions](https://stripe.com/docs/payments/checkout/set-up-a-subscription#tax-rates) to collect tax. + // + // Related guide: [Tax Rates](https://stripe.com/docs/billing/taxes/tax-rates). + Rate *TaxRate `json:"rate"` +} +type OrderTotalDetailsBreakdown struct { + // The aggregated discounts. + Discounts []*OrderTotalDetailsBreakdownDiscount `json:"discounts"` + // The aggregated tax amounts by rate. + Taxes []*OrderTotalDetailsBreakdownTax `json:"taxes"` +} +type OrderTotalDetails struct { + // This is the sum of all the discounts. + AmountDiscount int64 `json:"amount_discount"` + // This is the sum of all the shipping amounts. + AmountShipping int64 `json:"amount_shipping"` + // This is the sum of all the tax amounts. + AmountTax int64 `json:"amount_tax"` + Breakdown *OrderTotalDetailsBreakdown `json:"breakdown"` +} + +// An Order describes a purchase being made by a customer, including the +// products & quantities being purchased, the order status, the payment information, +// and the billing/shipping details. // -// Related guide: [Tax, Shipping, and Inventory](https://stripe.com/docs/orders-legacy). +// Related guide: [Orders overview](https://stripe.com/docs/orders) type Order struct { APIResource - // A positive integer in the smallest currency unit (that is, 100 cents for $1.00, or 1 for ¥1, Japanese Yen being a zero-decimal currency) representing the total amount for the order. - Amount int64 `json:"amount"` - // The total amount that was returned to the customer. - AmountReturned int64 `json:"amount_returned"` - // ID of the Connect Application that created the order. - Application string `json:"application"` - // A fee in cents that will be applied to the order and transferred to the application owner's Stripe account. The request must be made with an OAuth key or the Stripe-Account header in order to take an application fee. For more information, see the application fees documentation. - ApplicationFee int64 `json:"application_fee"` - // The ID of the payment used to pay for the order. Present if the order status is `paid`, `fulfilled`, or `refunded`. - Charge *Charge `json:"charge"` + // Order cost before any discounts or taxes are applied. A positive integer representing the subtotal of the order in the [smallest currency unit](https://stripe.com/docs/currencies#zero-decimal) (e.g., 100 cents to charge $1.00 or 100 to charge ¥100, a zero-decimal currency). + AmountSubtotal int64 `json:"amount_subtotal"` + // Total order cost after discounts and taxes are applied. A positive integer representing the cost of the order in the [smallest currency unit](https://stripe.com/docs/currencies#zero-decimal) (e.g., 100 cents to charge $1.00 or 100 to charge ¥100, a zero-decimal currency). To submit an order, the total must be either 0 or at least $0.50 USD or [equivalent in charge currency](https://stripe.com/docs/currencies#minimum-and-maximum-charge-amounts). + AmountTotal int64 `json:"amount_total"` + // ID of the Connect application that created the Order, if any. + Application *Application `json:"application"` + AutomaticTax *OrderAutomaticTax `json:"automatic_tax"` + // Customer billing details associated with the order. + BillingDetails *OrderBillingDetails `json:"billing_details"` + // The client secret of this Order. Used for client-side retrieval using a publishable key. + // + // The client secret can be used to complete a payment for an Order 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. + // + // Refer to our docs for [creating and processing an order](https://stripe.com/docs/orders-beta/create-and-process) to learn about how client_secret should be handled. + ClientSecret string `json:"client_secret"` // Time at which the object was created. Measured in seconds since the Unix epoch. Created int64 `json:"created"` // Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](https://stripe.com/docs/currencies). Currency Currency `json:"currency"` - // The customer used for the order. - Customer Customer `json:"customer"` - // The email address of the customer placing the order. - Email string `json:"email"` - // External coupon code to load for this order. - ExternalCouponCode string `json:"external_coupon_code"` + // The customer which this orders belongs to. + Customer *Customer `json:"customer"` + // An arbitrary string attached to the object. Often useful for displaying to users. + Description string `json:"description"` + // The discounts applied to the order. Use `expand[]=discounts` to expand each discount. + Discounts []*Discount `json:"discounts"` // Unique identifier for the object. ID string `json:"id"` - // List of items constituting the order. An order can have up to 25 items. - Items []*OrderItem `json:"items"` + // A recent IP address of the purchaser used for tax reporting and tax location inference. + IPAddress string `json:"ip_address"` + // A list of line items the customer is ordering. Each line item includes information about the product, the quantity, and the resulting cost. There is a maximum of 100 line items. + LineItems *LineItemList `json:"line_items"` // Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode. Livemode bool `json:"livemode"` // Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format. Metadata map[string]string `json:"metadata"` // String representing the object's type. Objects of the same type share the same value. - Object string `json:"object"` - // A list of returns that have taken place for this order. - Returns *OrderReturnList `json:"returns"` - // The shipping method that is currently selected for this order, if any. If present, it is equal to one of the `id`s of shipping methods in the `shipping_methods` array. At order creation time, if there are multiple shipping methods, Stripe will automatically selected the first method. - SelectedShippingMethod *string `json:"selected_shipping_method"` - // The shipping address for the order. Present if the order is for goods to be shipped. - Shipping *Shipping `json:"shipping"` - // A list of supported shipping methods for this order. The desired shipping method can be specified either by updating the order, or when paying it. - ShippingMethods []*ShippingMethod `json:"shipping_methods"` - // Current order status. One of `created`, `paid`, `canceled`, `fulfilled`, or `returned`. More details in the [Orders Guide](https://stripe.com/docs/orders/guide#understanding-order-statuses). - Status string `json:"status"` - // The timestamps at which the order status was updated. - StatusTransitions StatusTransitions `json:"status_transitions"` - // Time at which the object was last updated. Measured in seconds since the Unix epoch. - Updated int64 `json:"updated"` - // The user's order ID if it is different from the Stripe order ID. - UpstreamID string `json:"upstream_id"` + Object string `json:"object"` + Payment *OrderPayment `json:"payment"` + // The details of the customer cost of shipping, including the customer chosen ShippingRate. + ShippingCost *OrderShippingCost `json:"shipping_cost"` + // Customer shipping information associated with the order. + ShippingDetails *OrderShippingDetails `json:"shipping_details"` + // The overall status of the order. + Status OrderStatus `json:"status"` + TaxDetails *OrderTaxDetails `json:"tax_details"` + TotalDetails *OrderTotalDetails `json:"total_details"` } // OrderList is a list of Orders as retrieved from a list endpoint. @@ -261,22 +1369,3 @@ type OrderList struct { ListMeta Data []*Order `json:"data"` } - -// UnmarshalJSON handles deserialization of an Order. -// This custom unmarshaling is needed because the resulting -// property may be an id or the full struct if it was expanded. -func (o *Order) UnmarshalJSON(data []byte) error { - if id, ok := ParseID(data); ok { - o.ID = id - return nil - } - - type order Order - var v order - if err := json.Unmarshal(data, &v); err != nil { - return err - } - - *o = Order(v) - return nil -} diff --git a/order/client.go b/order/client.go index d02e7896ee..d434d140fc 100644 --- a/order/client.go +++ b/order/client.go @@ -46,40 +46,53 @@ func (c Client) Get(id string, params *stripe.OrderParams) (*stripe.Order, error } // Update updates an order's properties. -func Update(id string, params *stripe.OrderUpdateParams) (*stripe.Order, error) { +func Update(id string, params *stripe.OrderParams) (*stripe.Order, error) { return getC().Update(id, params) } // Update updates an order's properties. -func (c Client) Update(id string, params *stripe.OrderUpdateParams) (*stripe.Order, error) { +func (c Client) Update(id string, params *stripe.OrderParams) (*stripe.Order, error) { path := stripe.FormatURLPath("/v1/orders/%s", id) order := &stripe.Order{} err := c.B.Call(http.MethodPost, path, c.Key, params, order) return order, err } -// Pay is the method for the `POST /v1/orders/{id}/pay` API. -func Pay(id string, params *stripe.OrderPayParams) (*stripe.Order, error) { - return getC().Pay(id, params) +// Cancel is the method for the `POST /v1/orders/{id}/cancel` API. +func Cancel(id string, params *stripe.OrderCancelParams) (*stripe.Order, error) { + return getC().Cancel(id, params) } -// Pay is the method for the `POST /v1/orders/{id}/pay` API. -func (c Client) Pay(id string, params *stripe.OrderPayParams) (*stripe.Order, error) { - path := stripe.FormatURLPath("/v1/orders/%s/pay", id) +// Cancel is the method for the `POST /v1/orders/{id}/cancel` API. +func (c Client) Cancel(id string, params *stripe.OrderCancelParams) (*stripe.Order, error) { + path := stripe.FormatURLPath("/v1/orders/%s/cancel", id) order := &stripe.Order{} err := c.B.Call(http.MethodPost, path, c.Key, params, order) return order, err } -// Return is the method for the `POST /v1/orders/{id}/returns` API. -func Return(id string, params *stripe.OrderReturnParams) (*stripe.OrderReturn, error) { - return getC().Return(id, params) +// Reopen is the method for the `POST /v1/orders/{id}/reopen` API. +func Reopen(id string, params *stripe.OrderReopenParams) (*stripe.Order, error) { + return getC().Reopen(id, params) } -// Return is the method for the `POST /v1/orders/{id}/returns` API. -func (c Client) Return(id string, params *stripe.OrderReturnParams) (*stripe.OrderReturn, error) { - path := stripe.FormatURLPath("/v1/orders/%s/returns", id) - order := &stripe.OrderReturn{} +// Reopen is the method for the `POST /v1/orders/{id}/reopen` API. +func (c Client) Reopen(id string, params *stripe.OrderReopenParams) (*stripe.Order, error) { + path := stripe.FormatURLPath("/v1/orders/%s/reopen", id) + order := &stripe.Order{} + err := c.B.Call(http.MethodPost, path, c.Key, params, order) + return order, err +} + +// Submit is the method for the `POST /v1/orders/{id}/submit` API. +func Submit(id string, params *stripe.OrderSubmitParams) (*stripe.Order, error) { + return getC().Submit(id, params) +} + +// Submit is the method for the `POST /v1/orders/{id}/submit` API. +func (c Client) Submit(id string, params *stripe.OrderSubmitParams) (*stripe.Order, error) { + path := stripe.FormatURLPath("/v1/orders/%s/submit", id) + order := &stripe.Order{} err := c.B.Call(http.MethodPost, path, c.Key, params, order) return order, err } @@ -123,6 +136,49 @@ func (i *Iter) OrderList() *stripe.OrderList { return i.List().(*stripe.OrderList) } +// ListLineItems is the method for the `GET /v1/orders/{id}/line_items` API. +func ListLineItems(params *stripe.OrderListLineItemsParams) *LineItemIter { + return getC().ListLineItems(params) +} + +// ListLineItems is the method for the `GET /v1/orders/{id}/line_items` API. +func (c Client) ListLineItems(listParams *stripe.OrderListLineItemsParams) *LineItemIter { + path := stripe.FormatURLPath( + "/v1/orders/%s/line_items", + stripe.StringValue(listParams.ID), + ) + return &LineItemIter{ + Iter: stripe.GetIter(listParams, func(p *stripe.Params, b *form.Values) ([]interface{}, stripe.ListContainer, error) { + list := &stripe.LineItemList{} + err := c.B.CallRaw(http.MethodGet, path, c.Key, b, p, list) + + ret := make([]interface{}, len(list.Data)) + for i, v := range list.Data { + ret[i] = v + } + + return ret, list, err + }), + } +} + +// LineItemIter is an iterator for line items. +type LineItemIter struct { + *stripe.Iter +} + +// LineItem returns the line item which the iterator is currently pointing to. +func (i *LineItemIter) LineItem() *stripe.LineItem { + return i.Current().(*stripe.LineItem) +} + +// LineItemList returns the current list object which the iterator is +// currently using. List objects will change as new API calls are made to +// continue pagination. +func (i *LineItemIter) LineItemList() *stripe.LineItemList { + return i.List().(*stripe.LineItemList) +} + func getC() Client { return Client{stripe.GetBackend(stripe.APIBackend), stripe.Key} } diff --git a/orderitem.go b/orderitem.go deleted file mode 100644 index 84af89a462..0000000000 --- a/orderitem.go +++ /dev/null @@ -1,92 +0,0 @@ -// -// -// File generated from our OpenAPI spec -// -// - -package stripe - -import "encoding/json" - -// The type of line item. One of `sku`, `tax`, `shipping`, or `discount`. -type OrderItemType string - -// List of values that OrderItemType can take -const ( - OrderItemTypeCoupon OrderItemType = "coupon" - OrderItemTypeDiscount OrderItemType = "discount" - OrderItemTypeSKU OrderItemType = "sku" - OrderItemTypeShipping OrderItemType = "shipping" - OrderItemTypeTax OrderItemType = "tax" -) - -// OrderItemParentType represents the type of order item parent -type OrderItemParentType string - -// List of values that OrderItemParentType can take. -const ( - OrderItemParentTypeCoupon OrderItemParentType = "coupon" - OrderItemParentTypeDiscount OrderItemParentType = "discount" - OrderItemParentTypeSKU OrderItemParentType = "sku" - OrderItemParentTypeShipping OrderItemParentType = "shipping" - OrderItemParentTypeTax OrderItemParentType = "tax" -) - -// OrderItemParent describes the parent of an order item. -type OrderItemParent struct { - ID string `json:"id"` - SKU *SKU `json:"-"` - Type OrderItemParentType `json:"object"` -} - -// A representation of the constituent items of any given order. Can be used to -// represent [SKUs](https://stripe.com/docs/api#skus), shipping costs, or taxes owed on the order. -// -// Related guide: [Orders](https://stripe.com/docs/orders/guide). -type OrderItem struct { - // A positive integer in the smallest currency unit (that is, 100 cents for $1.00, or 1 for ¥1, Japanese Yen being a zero-decimal currency) representing the total amount for the line item. - Amount int64 `json:"amount"` - // Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](https://stripe.com/docs/currencies). - Currency Currency `json:"currency"` - // Description of the line item, meant to be displayable to the user (e.g., `"Express shipping"`). - Description string `json:"description"` - // String representing the object's type. Objects of the same type share the same value. - Object string `json:"object"` - // The ID of the associated object for this line item. Expandable if not null (e.g., expandable to a SKU). - Parent *OrderItemParent `json:"parent"` - // A positive integer representing the number of instances of `parent` that are included in this order item. Applicable/present only if `type` is `sku`. - Quantity int64 `json:"quantity"` - // The type of line item. One of `sku`, `tax`, `shipping`, or `discount`. - Type OrderItemType `json:"type"` -} - -// UnmarshalJSON handles deserialization of an OrderItemParent. -// This custom unmarshaling is needed because the resulting -// property may be an id or a full SKU struct if it was expanded. -func (p *OrderItemParent) UnmarshalJSON(data []byte) error { - if id, ok := ParseID(data); ok { - p.ID = id - return nil - } - - type orderItemParent OrderItemParent - var v orderItemParent - if err := json.Unmarshal(data, &v); err != nil { - return err - } - - var err error - *p = OrderItemParent(v) - - switch p.Type { - case OrderItemParentTypeSKU: - // Currently only SKUs `parent` is returned as an object when expanded. - // For other items only IDs are returned. - if err = json.Unmarshal(data, &p.SKU); err != nil { - return err - } - p.ID = p.SKU.ID - } - - return nil -} diff --git a/orderreturn.go b/orderreturn.go deleted file mode 100644 index e48e7aa86f..0000000000 --- a/orderreturn.go +++ /dev/null @@ -1,79 +0,0 @@ -// -// -// File generated from our OpenAPI spec -// -// - -package stripe - -import "encoding/json" - -// Returns a list of your order returns. The returns are returned sorted by creation date, with the most recently created return appearing first. -type OrderReturnListParams struct { - ListParams `form:"*"` - // Date this return was created. - Created *int64 `form:"created"` - // Date this return was created. - CreatedRange *RangeQueryParams `form:"created"` - // The order to retrieve returns for. - Order *string `form:"order"` -} - -// Retrieves the details of an existing order return. Supply the unique order ID from either an order return creation request or the order return list, and Stripe will return the corresponding order information. -type OrderReturnParams struct { - Params `form:"*"` - Items []*OrderItemParams `form:"items"` - Order *string `form:"-"` // Included in the URL -} - -// A return represents the full or partial return of a number of [order items](https://stripe.com/docs/api#order_items). -// Returns always belong to an order, and may optionally contain a refund. -// -// Related guide: [Handling Returns](https://stripe.com/docs/orders/guide#handling-returns). -type OrderReturn struct { - APIResource - // A positive integer in the smallest currency unit (that is, 100 cents for $1.00, or 1 for ¥1, Japanese Yen being a zero-decimal currency) representing the total amount for the returned line item. - Amount int64 `json:"amount"` - // Time at which the object was created. Measured in seconds since the Unix epoch. - Created int64 `json:"created"` - // Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](https://stripe.com/docs/currencies). - Currency Currency `json:"currency"` - // Unique identifier for the object. - ID string `json:"id"` - // The items included in this order return. - Items []*OrderItem `json:"items"` - // Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode. - Livemode bool `json:"livemode"` - // String representing the object's type. Objects of the same type share the same value. - Object string `json:"object"` - // The order that this return includes items from. - Order *Order `json:"order"` - // The ID of the refund issued for this return. - Refund *Refund `json:"refund"` -} - -// OrderReturnList is a list of OrderReturns as retrieved from a list endpoint. -type OrderReturnList struct { - APIResource - ListMeta - Data []*OrderReturn `json:"data"` -} - -// UnmarshalJSON handles deserialization of an OrderReturn. -// This custom unmarshaling is needed because the resulting -// property may be an id or the full struct if it was expanded. -func (o *OrderReturn) UnmarshalJSON(data []byte) error { - if id, ok := ParseID(data); ok { - o.ID = id - return nil - } - - type orderReturn OrderReturn - var v orderReturn - if err := json.Unmarshal(data, &v); err != nil { - return err - } - - *o = OrderReturn(v) - return nil -} diff --git a/orderreturn/client.go b/orderreturn/client.go deleted file mode 100644 index cdb92fa43f..0000000000 --- a/orderreturn/client.go +++ /dev/null @@ -1,77 +0,0 @@ -// -// -// File generated from our OpenAPI spec -// -// - -// Package orderreturn provides the /order_returns APIs -package orderreturn - -import ( - "net/http" - - stripe "github.com/stripe/stripe-go/v72" - "github.com/stripe/stripe-go/v72/form" -) - -// Client is used to invoke /order_returns APIs. -type Client struct { - B stripe.Backend - Key string -} - -// Get returns the details of an order return. -func Get(id string, params *stripe.OrderReturnParams) (*stripe.OrderReturn, error) { - return getC().Get(id, params) -} - -// Get returns the details of an order return. -func (c Client) Get(id string, params *stripe.OrderReturnParams) (*stripe.OrderReturn, error) { - path := stripe.FormatURLPath("/v1/order_returns/%s", id) - orderreturn := &stripe.OrderReturn{} - err := c.B.Call(http.MethodGet, path, c.Key, params, orderreturn) - return orderreturn, err -} - -// List returns a list of order returns. -func List(params *stripe.OrderReturnListParams) *Iter { - return getC().List(params) -} - -// List returns a list of order returns. -func (c Client) List(listParams *stripe.OrderReturnListParams) *Iter { - return &Iter{ - Iter: stripe.GetIter(listParams, func(p *stripe.Params, b *form.Values) ([]interface{}, stripe.ListContainer, error) { - list := &stripe.OrderReturnList{} - err := c.B.CallRaw(http.MethodGet, "/v1/order_returns", c.Key, b, p, list) - - ret := make([]interface{}, len(list.Data)) - for i, v := range list.Data { - ret[i] = v - } - - return ret, list, err - }), - } -} - -// Iter is an iterator for order returns. -type Iter struct { - *stripe.Iter -} - -// OrderReturn returns the order return which the iterator is currently pointing to. -func (i *Iter) OrderReturn() *stripe.OrderReturn { - return i.Current().(*stripe.OrderReturn) -} - -// OrderReturnList returns the current list object which the iterator is -// currently using. List objects will change as new API calls are made to -// continue pagination. -func (i *Iter) OrderReturnList() *stripe.OrderReturnList { - return i.List().(*stripe.OrderReturnList) -} - -func getC() Client { - return Client{stripe.GetBackend(stripe.APIBackend), stripe.Key} -} diff --git a/search_iter_test.go b/search_iter_test.go index a8748bb085..060b431f3d 100644 --- a/search_iter_test.go +++ b/search_iter_test.go @@ -127,9 +127,6 @@ func TestSearchIterMultiplePages(t *testing.T) { }) client := Client{B: backend, Key: Key} - p := &OrderReturnParams{} - p.SetStripeAccount("acct_123") - iter := client.Search(&SearchParams{ Query: "my query", })