diff --git a/OPENAPI_VERSION b/OPENAPI_VERSION index 4e134f2a95..72a2ee91db 100644 --- a/OPENAPI_VERSION +++ b/OPENAPI_VERSION @@ -1 +1 @@ -v223 \ No newline at end of file +v226 \ No newline at end of file diff --git a/account.go b/account.go index 612ce310b2..872574fb04 100644 --- a/account.go +++ b/account.go @@ -1186,11 +1186,13 @@ type AccountTOSAcceptance struct { } // This is an object representing a Stripe account. You can retrieve it to see -// properties on the account like its current e-mail address or if the account is -// enabled yet to make live charges. +// properties on the account like its current requirements or if the account is +// enabled to make live charges or receive payouts. // -// Some properties, marked below, are available only to platforms that want to -// [create and manage Express or Custom accounts](https://stripe.com/docs/connect/accounts). +// For Custom accounts, the properties below are always returned. For other accounts, some properties are returned until that +// account has started to go through Connect Onboarding. Once you create an [Account Link](https://stripe.com/docs/api/account_links) +// for a Standard or Express account, some parameters are no longer returned. These are marked as **Custom Only** or **Custom and Express** +// below. Learn about the differences [between accounts](https://stripe.com/docs/connect/accounts). type Account struct { APIResource // Business information about the account. diff --git a/billingportal_configuration.go b/billingportal_configuration.go index f5ac297276..4f015c4f72 100644 --- a/billingportal_configuration.go +++ b/billingportal_configuration.go @@ -15,6 +15,7 @@ type BillingPortalConfigurationFeaturesCustomerUpdateAllowedUpdate string const ( BillingPortalConfigurationFeaturesCustomerUpdateAllowedUpdateAddress BillingPortalConfigurationFeaturesCustomerUpdateAllowedUpdate = "address" BillingPortalConfigurationFeaturesCustomerUpdateAllowedUpdateEmail BillingPortalConfigurationFeaturesCustomerUpdateAllowedUpdate = "email" + BillingPortalConfigurationFeaturesCustomerUpdateAllowedUpdateName BillingPortalConfigurationFeaturesCustomerUpdateAllowedUpdate = "name" BillingPortalConfigurationFeaturesCustomerUpdateAllowedUpdatePhone BillingPortalConfigurationFeaturesCustomerUpdateAllowedUpdate = "phone" BillingPortalConfigurationFeaturesCustomerUpdateAllowedUpdateShipping BillingPortalConfigurationFeaturesCustomerUpdateAllowedUpdate = "shipping" BillingPortalConfigurationFeaturesCustomerUpdateAllowedUpdateTaxID BillingPortalConfigurationFeaturesCustomerUpdateAllowedUpdate = "tax_id" diff --git a/billingportal_session.go b/billingportal_session.go index 38368123d9..7b67cd9365 100644 --- a/billingportal_session.go +++ b/billingportal_session.go @@ -53,7 +53,7 @@ type BillingPortalSessionFlowDataSubscriptionCancelParams struct { Subscription *string `form:"subscription"` } -// Information about a specific flow for the customer to go through. +// Information about a specific flow for the customer to go through. See the [docs](https://stripe.com/docs/customer-management/portal-deep-links) to learn more about using customer portal deep links and flows. type BillingPortalSessionFlowDataParams struct { // Behavior after the flow is completed. AfterCompletion *BillingPortalSessionFlowDataAfterCompletionParams `form:"after_completion"` @@ -70,7 +70,7 @@ type BillingPortalSessionParams struct { Configuration *string `form:"configuration"` // The ID of an existing customer. Customer *string `form:"customer"` - // Information about a specific flow for the customer to go through. + // Information about a specific flow for the customer to go through. See the [docs](https://stripe.com/docs/customer-management/portal-deep-links) to learn more about using customer portal deep links and flows. FlowData *BillingPortalSessionFlowDataParams `form:"flow_data"` // The IETF language tag of the locale Customer Portal is displayed in. If blank or auto, the customer's `preferred_locales` or browser's locale is used. Locale *string `form:"locale"` @@ -106,7 +106,7 @@ type BillingPortalSessionFlowSubscriptionCancel struct { Subscription string `json:"subscription"` } -// Information about a specific flow for the customer to go through. +// Information about a specific flow for the customer to go through. See the [docs](https://stripe.com/docs/customer-management/portal-deep-links) to learn more about using customer portal deep links and flows. type BillingPortalSessionFlow struct { AfterCompletion *BillingPortalSessionFlowAfterCompletion `json:"after_completion"` // Configuration when `flow.type=subscription_cancel`. @@ -137,7 +137,7 @@ type BillingPortalSession struct { Created int64 `json:"created"` // The ID of the customer for this session. Customer string `json:"customer"` - // Information about a specific flow for the customer to go through. + // Information about a specific flow for the customer to go through. See the [docs](https://stripe.com/docs/customer-management/portal-deep-links) to learn more about using customer portal deep links and flows. Flow *BillingPortalSessionFlow `json:"flow"` // Unique identifier for the object. ID string `json:"id"` diff --git a/checkout_session.go b/checkout_session.go index 34e0c93536..45350e68ae 100644 --- a/checkout_session.go +++ b/checkout_session.go @@ -63,6 +63,24 @@ const ( CheckoutSessionConsentCollectionTermsOfServiceRequired CheckoutSessionConsentCollectionTermsOfService = "required" ) +// The type of the label. +type CheckoutSessionCustomFieldLabelType string + +// List of values that CheckoutSessionCustomFieldLabelType can take +const ( + CheckoutSessionCustomFieldLabelTypeCustom CheckoutSessionCustomFieldLabelType = "custom" +) + +// The type of the field. +type CheckoutSessionCustomFieldType string + +// List of values that CheckoutSessionCustomFieldType can take +const ( + CheckoutSessionCustomFieldTypeDropdown CheckoutSessionCustomFieldType = "dropdown" + CheckoutSessionCustomFieldTypeNumeric CheckoutSessionCustomFieldType = "numeric" + CheckoutSessionCustomFieldTypeText CheckoutSessionCustomFieldType = "text" +) + // Configure whether a Checkout Session creates a Customer when the Checkout Session completes. type CheckoutSessionCustomerCreation string @@ -630,6 +648,42 @@ type CheckoutSessionConsentCollectionParams struct { TermsOfService *string `form:"terms_of_service"` } +// The options available for the customer to select. Up to 200 options allowed. +type CheckoutSessionCustomFieldDropdownOptionParams struct { + // The label for the option, displayed to the customer. Up to 100 characters. + Label *string `form:"label"` + // The value for this option, not displayed to the customer, used by your integration to reconcile the option selected by the customer. Must be unique to this option, alphanumeric, and up to 100 characters. + Value *string `form:"value"` +} + +// Configuration for `type=dropdown` fields. +type CheckoutSessionCustomFieldDropdownParams struct { + // The options available for the customer to select. Up to 200 options allowed. + Options []*CheckoutSessionCustomFieldDropdownOptionParams `form:"options"` +} + +// The label for the field, displayed to the customer. +type CheckoutSessionCustomFieldLabelParams struct { + // Custom text for the label, displayed to the customer. Up to 50 characters. + Custom *string `form:"custom"` + // The type of the label. + Type *string `form:"type"` +} + +// Collect additional information from your customer using custom fields. Up to 2 fields are supported. +type CheckoutSessionCustomFieldParams struct { + // Configuration for `type=dropdown` fields. + Dropdown *CheckoutSessionCustomFieldDropdownParams `form:"dropdown"` + // String of your choice that your integration can use to reconcile this field. Must be unique to this field, alphanumeric, and up to 200 characters. + Key *string `form:"key"` + // The label for the field, displayed to the customer. + Label *CheckoutSessionCustomFieldLabelParams `form:"label"` + // Whether the customer is required to complete the field before completing the Checkout Session. Defaults to `false`. + Optional *bool `form:"optional"` + // The type of the field. + Type *string `form:"type"` +} + // Custom text that should be displayed alongside shipping address collection. type CheckoutSessionCustomTextShippingAddressParams struct { // Text may be up to 1000 characters in length. @@ -1426,6 +1480,8 @@ type CheckoutSessionParams struct { CustomerEmail *string `form:"customer_email"` // Controls what fields on Customer can be updated by the Checkout Session. Can only be provided when `customer` is provided. CustomerUpdate *CheckoutSessionCustomerUpdateParams `form:"customer_update"` + // Collect additional information from your customer using custom fields. Up to 2 fields are supported. + CustomFields []*CheckoutSessionCustomFieldParams `form:"custom_fields"` // Display additional text for your customers using custom text. CustomText *CheckoutSessionCustomTextParams `form:"custom_text"` // The coupon or promotion code to apply to this Session. Currently, only up to one may be specified. @@ -1554,6 +1610,57 @@ type CheckoutSessionConsentCollection struct { TermsOfService CheckoutSessionConsentCollectionTermsOfService `json:"terms_of_service"` } +// The options available for the customer to select. Up to 200 options allowed. +type CheckoutSessionCustomFieldDropdownOption struct { + // The label for the option, displayed to the customer. Up to 100 characters. + Label string `json:"label"` + // The value for this option, not displayed to the customer, used by your integration to reconcile the option selected by the customer. Must be unique to this option, alphanumeric, and up to 100 characters. + Value string `json:"value"` +} + +// Configuration for `type=dropdown` fields. +type CheckoutSessionCustomFieldDropdown struct { + // The options available for the customer to select. Up to 200 options allowed. + Options []*CheckoutSessionCustomFieldDropdownOption `json:"options"` + // The option selected by the customer. This will be the `value` for the option. + Value string `json:"value"` +} +type CheckoutSessionCustomFieldLabel struct { + // Custom text for the label, displayed to the customer. Up to 50 characters. + Custom string `json:"custom"` + // The type of the label. + Type CheckoutSessionCustomFieldLabelType `json:"type"` +} + +// Configuration for `type=numeric` fields. +type CheckoutSessionCustomFieldNumeric struct { + // The value entered by the customer, containing only digits. + Value string `json:"value"` +} + +// Configuration for `type=text` fields. +type CheckoutSessionCustomFieldText struct { + // The value entered by the customer. + Value string `json:"value"` +} + +// Collect additional information from your customer using custom fields. Up to 2 fields are supported. +type CheckoutSessionCustomField struct { + // Configuration for `type=dropdown` fields. + Dropdown *CheckoutSessionCustomFieldDropdown `json:"dropdown"` + // String of your choice that your integration can use to reconcile this field. Must be unique to this field, alphanumeric, and up to 200 characters. + Key string `json:"key"` + Label *CheckoutSessionCustomFieldLabel `json:"label"` + // Configuration for `type=numeric` fields. + Numeric *CheckoutSessionCustomFieldNumeric `json:"numeric"` + // Whether the customer is required to complete the field before completing the Checkout Session. Defaults to `false`. + Optional bool `json:"optional"` + // Configuration for `type=text` fields. + Text *CheckoutSessionCustomFieldText `json:"text"` + // The type of the field. + Type CheckoutSessionCustomFieldType `json:"type"` +} + // Custom text that should be displayed alongside shipping address collection. type CheckoutSessionCustomTextShippingAddress struct { // Text may be up to 1000 characters in length. @@ -1999,8 +2106,8 @@ type CheckoutSessionTotalDetails struct { // [PaymentIntent](https://stripe.com/docs/api/payment_intents) or an active // [Subscription](https://stripe.com/docs/api/subscriptions). // -// You can create a Checkout Session on your server and pass its ID to the -// client to begin Checkout. +// You can create a Checkout Session on your server and redirect to its URL +// to begin Checkout. // // Related guide: [Checkout Quickstart](https://stripe.com/docs/checkout/quickstart). type CheckoutSession struct { @@ -2045,12 +2152,13 @@ type CheckoutSession struct { // Use this parameter to prefill customer data if you already have an email // on file. To access information about the customer once the payment flow is // complete, use the `customer` attribute. - CustomerEmail string `json:"customer_email"` - CustomText *CheckoutSessionCustomText `json:"custom_text"` + CustomerEmail string `json:"customer_email"` + // Collect additional information from your customer using custom fields. Up to 2 fields are supported. + CustomFields []*CheckoutSessionCustomField `json:"custom_fields"` + CustomText *CheckoutSessionCustomText `json:"custom_text"` // The timestamp at which the Checkout Session will expire. ExpiresAt int64 `json:"expires_at"` - // Unique identifier for the object. Used to pass to `redirectToCheckout` - // in Stripe.js. + // Unique identifier for the object. ID string `json:"id"` // ID of the invoice created by the Checkout Session, if it exists. Invoice *Invoice `json:"invoice"` diff --git a/example/generated_examples_test.go b/example/generated_examples_test.go index f0ade6afd2..fc42ae56bb 100644 --- a/example/generated_examples_test.go +++ b/example/generated_examples_test.go @@ -619,15 +619,6 @@ func TestCapabilityUpdate(t *testing.T) { assert.NotNil(t, result) } -func TestSubscriptionResume(t *testing.T) { - params := &stripe.SubscriptionResumeParams{ - ProrationDate: stripe.Int64(1675400000), - ProrationBehavior: stripe.String("always_invoice"), - } - result, _ := subscription.Resume("sub_xxxxxxxxxxxxx", params) - assert.NotNil(t, result) -} - func TestPersonList(t *testing.T) { params := &stripe.PersonListParams{ Account: stripe.String("acct_xxxxxxxxxxxxx"), @@ -654,6 +645,18 @@ func TestPersonUpdate(t *testing.T) { assert.NotNil(t, result) } +func TestAppsSecretList2(t *testing.T) { + params := &stripe.AppsSecretListParams{ + Scope: &stripe.AppsSecretListScopeParams{ + Type: stripe.String(string(stripe.AppsSecretScopeTypeAccount)), + }, + } + params.Limit = stripe.Int64(2) + result := apps_secret.List(params) + assert.NotNil(t, result) + assert.Nil(t, result.Err()) +} + func TestAppsSecretCreate2(t *testing.T) { params := &stripe.AppsSecretParams{ Name: stripe.String("my-api-key"), @@ -750,7 +753,7 @@ func TestChargeCreate(t *testing.T) { Amount: stripe.Int64(2000), Currency: stripe.String(string(stripe.CurrencyUSD)), Source: &stripe.PaymentSourceSourceParams{Token: stripe.String("tok_xxxx")}, - Description: stripe.String("My First Test Charge (created for API docs)"), + Description: stripe.String("My First Test Charge (created for API docs at https://www.stripe.com/docs/api)"), } result, _ := charge.New(params) assert.NotNil(t, result) @@ -875,7 +878,7 @@ func TestCustomerList2(t *testing.T) { func TestCustomerCreate(t *testing.T) { params := &stripe.CustomerParams{ - Description: stripe.String("My First Test Customer (created for API docs)"), + Description: stripe.String("My First Test Customer (created for API docs at https://www.stripe.com/docs/api)"), } result, _ := customer.New(params) assert.NotNil(t, result) @@ -1060,6 +1063,15 @@ func TestFinancialConnectionsAccountRetrieve2(t *testing.T) { assert.NotNil(t, result) } +func TestFinancialConnectionsAccountDisconnect2(t *testing.T) { + params := &stripe.FinancialConnectionsAccountDisconnectParams{} + result, _ := financialconnections_account.Disconnect( + "fca_xxxxxxxxxxxxx", + params, + ) + assert.NotNil(t, result) +} + func TestFinancialConnectionsAccountListOwners2(t *testing.T) { params := &stripe.FinancialConnectionsAccountListOwnersParams{ Ownership: stripe.String("fcaowns_xxxxxxxxxxxxx"), @@ -1437,9 +1449,11 @@ func TestPaymentIntentList(t *testing.T) { func TestPaymentIntentCreate2(t *testing.T) { params := &stripe.PaymentIntentParams{ - Amount: stripe.Int64(2000), - Currency: stripe.String(string(stripe.CurrencyUSD)), - PaymentMethodTypes: []*string{stripe.String("card")}, + Amount: stripe.Int64(2000), + Currency: stripe.String(string(stripe.CurrencyUSD)), + AutomaticPaymentMethods: &stripe.PaymentIntentAutomaticPaymentMethodsParams{ + Enabled: stripe.Bool(true), + }, } result, _ := paymentintent.New(params) assert.NotNil(t, result) @@ -1492,6 +1506,14 @@ func TestPaymentIntentIncrementAuthorization(t *testing.T) { assert.NotNil(t, result) } +func TestPaymentIntentVerifyMicrodeposits2(t *testing.T) { + params := &stripe.PaymentIntentVerifyMicrodepositsParams{ + Amounts: []*int64{stripe.Int64(32), stripe.Int64(45)}, + } + result, _ := paymentintent.VerifyMicrodeposits("pi_xxxxxxxxxxxxx", params) + assert.NotNil(t, result) +} + func TestPaymentIntentSearch(t *testing.T) { params := &stripe.PaymentIntentSearchParams{ SearchParams: stripe.SearchParams{ @@ -1932,6 +1954,14 @@ func TestSetupIntentConfirm(t *testing.T) { assert.NotNil(t, result) } +func TestSetupIntentVerifyMicrodeposits2(t *testing.T) { + params := &stripe.SetupIntentVerifyMicrodepositsParams{ + Amounts: []*int64{stripe.Int64(32), stripe.Int64(45)}, + } + result, _ := setupintent.VerifyMicrodeposits("seti_xxxxxxxxxxxxx", params) + assert.NotNil(t, result) +} + func TestShippingRateList2(t *testing.T) { params := &stripe.ShippingRateListParams{} params.Limit = stripe.Int64(3) @@ -2067,7 +2097,7 @@ func TestSubscriptionScheduleList(t *testing.T) { func TestSubscriptionScheduleCreate(t *testing.T) { params := &stripe.SubscriptionScheduleParams{ Customer: stripe.String("cus_xxxxxxxxxxxxx"), - StartDate: stripe.Int64(1652909005), + StartDate: stripe.Int64(1676070661), EndBehavior: stripe.String(string(stripe.SubscriptionScheduleEndBehaviorRelease)), Phases: []*stripe.SubscriptionSchedulePhaseParams{ &stripe.SubscriptionSchedulePhaseParams{ @@ -2268,8 +2298,9 @@ func TestTerminalLocationCreate(t *testing.T) { Address: &stripe.AddressParams{ Line1: stripe.String("1234 Main Street"), City: stripe.String("San Francisco"), - Country: stripe.String("US"), PostalCode: stripe.String("94111"), + State: stripe.String("CA"), + Country: stripe.String("US"), }, } result, _ := terminal_location.New(params) @@ -2343,6 +2374,15 @@ func TestTerminalReaderProcessPaymentIntent(t *testing.T) { assert.NotNil(t, result) } +func TestTerminalReaderProcessSetupIntent(t *testing.T) { + params := &stripe.TerminalReaderProcessSetupIntentParams{ + SetupIntent: stripe.String("seti_xxxxxxxxxxxxx"), + CustomerConsentCollected: stripe.Bool(true), + } + result, _ := terminal_reader.ProcessSetupIntent("tmr_xxxxxxxxxxxxx", params) + assert.NotNil(t, result) +} + func TestTestHelpersTestClockList2(t *testing.T) { params := &stripe.TestHelpersTestClockListParams{} params.Limit = stripe.Int64(3) @@ -2373,7 +2413,7 @@ func TestTestHelpersTestClockRetrieve2(t *testing.T) { func TestTestHelpersTestClockAdvance2(t *testing.T) { params := &stripe.TestHelpersTestClockAdvanceParams{ - FrozenTime: stripe.Int64(1652390605), + FrozenTime: stripe.Int64(1675552261), } result, _ := testhelpers_testclock.Advance("clock_xxxxxxxxxxxxx", params) assert.NotNil(t, result) @@ -2555,19 +2595,6 @@ func TestTreasuryFinancialAccountRetrieveFeatures(t *testing.T) { assert.NotNil(t, result) } -func TestTreasuryFinancialAccountUpdateFeatures(t *testing.T) { - params := &stripe.TreasuryFinancialAccountUpdateFeaturesParams{ - CardIssuing: &stripe.TreasuryFinancialAccountUpdateFeaturesCardIssuingParams{ - Requested: stripe.Bool(false), - }, - } - result, _ := treasury_financialaccount.UpdateFeatures( - "fa_xxxxxxxxxxxxx", - params, - ) - assert.NotNil(t, result) -} - func TestTreasuryInboundTransferList(t *testing.T) { params := &stripe.TreasuryInboundTransferListParams{ FinancialAccount: stripe.String("fa_xxxxxxxxxxxxx"), @@ -2617,7 +2644,7 @@ func TestTreasuryOutboundPaymentCreate(t *testing.T) { FinancialAccount: stripe.String("fa_xxxxxxxxxxxxx"), Amount: stripe.Int64(10000), Currency: stripe.String(string(stripe.CurrencyUSD)), - Customer: stripe.String("cu_xxxxxxxxxxxxx"), + Customer: stripe.String("cus_xxxxxxxxxxxxx"), DestinationPaymentMethod: stripe.String("pm_xxxxxxxxxxxxx"), Description: stripe.String("OutboundPayment to a 3rd party"), } @@ -2627,13 +2654,13 @@ func TestTreasuryOutboundPaymentCreate(t *testing.T) { func TestTreasuryOutboundPaymentRetrieve(t *testing.T) { params := &stripe.TreasuryOutboundPaymentParams{} - result, _ := treasury_outboundpayment.Get("obp_xxxxxxxxxxxxx", params) + result, _ := treasury_outboundpayment.Get("bot_xxxxxxxxxxxxx", params) assert.NotNil(t, result) } func TestTreasuryOutboundPaymentCancel(t *testing.T) { params := &stripe.TreasuryOutboundPaymentCancelParams{} - result, _ := treasury_outboundpayment.Cancel("obp_xxxxxxxxxxxxx", params) + result, _ := treasury_outboundpayment.Cancel("bot_xxxxxxxxxxxxx", params) assert.NotNil(t, result) } diff --git a/invoice.go b/invoice.go index 6581d06e27..e04035ceb2 100644 --- a/invoice.go +++ b/invoice.go @@ -765,7 +765,7 @@ type InvoiceUpcomingLinesInvoiceItemParams struct { // Define thresholds at which an invoice will be sent, and the subscription advanced to a new billing period. When updating, pass an empty string to remove previously-defined thresholds. type InvoiceUpcomingLinesSubscriptionItemBillingThresholdsParams struct { - // Usage threshold that triggers the subscription to advance to a new billing period + // Number of units that meets the billing threshold to advance the subscription to a new billing period (e.g., it takes 10 $5 units to meet a $50 [monetary threshold](https://stripe.com/docs/api/subscriptions/update#update_subscription-billing_thresholds-amount_gte)) UsageGTE *int64 `form:"usage_gte"` } @@ -1213,7 +1213,7 @@ type Invoice struct { LastFinalizationError *Error `json:"last_finalization_error"` // The ID of the most recent non-draft revision of this invoice LatestRevision *Invoice `json:"latest_revision"` - // The individual line items that make up the invoice. `lines` is sorted as follows: invoice items in reverse chronological order, followed by the subscription, if any. + // The individual line items that make up the invoice. `lines` is sorted as follows: (1) pending invoice items (including prorations) in reverse chronological order, (2) subscription items in reverse chronological order, and (3) invoice items added after invoice creation in chronological order. Lines *InvoiceLineItemList `json:"lines"` // 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"` diff --git a/invoiceitem.go b/invoiceitem.go index 21c54194f4..17906e4844 100644 --- a/invoiceitem.go +++ b/invoiceitem.go @@ -88,13 +88,17 @@ type InvoiceItemParams struct { UnitAmountDecimal *float64 `form:"unit_amount_decimal,high_precision"` } -// Sometimes you want to add a charge or credit to a customer, but actually -// charge or credit the customer's card only at the end of a regular billing -// cycle. This is useful for combining several charges (to minimize -// per-transaction fees), or for having Stripe tabulate your usage-based billing -// totals. +// Invoice Items represent the component lines of an [invoice](https://stripe.com/docs/api/invoices). An invoice item is added to an +// invoice by creating or updating it with an `invoice` field, at which point it will be included as +// [an invoice line item](https://stripe.com/docs/api/invoices/line_item) within +// [invoice.lines](https://stripe.com/docs/api/invoices/object#invoice_object-lines). // -// Related guide: [Subscription Invoices](https://stripe.com/docs/billing/invoices/subscription#adding-upcoming-invoice-items). +// Invoice Items can be created before you are ready to actually send the invoice. This can be particularly useful when combined +// with a [subscription](https://stripe.com/docs/api/subscriptions). Sometimes you want to add a charge or credit to a customer, but actually charge +// or credit the customer's card only at the end of a regular billing cycle. This is useful for combining several charges +// (to minimize per-transaction fees), or for having Stripe tabulate your usage-based billing totals. +// +// Related guides: [Integrate with the Invoicing API](https://stripe.com/docs/invoicing/integration), [Subscription Invoices](https://stripe.com/docs/billing/invoices/subscription#adding-upcoming-invoice-items). type InvoiceItem struct { APIResource // Amount (in the `currency` specified) of the invoice item. This should always be equal to `unit_amount * quantity`. diff --git a/invoicelineitem.go b/invoicelineitem.go index 628b5c695f..c8c1e1c463 100644 --- a/invoicelineitem.go +++ b/invoicelineitem.go @@ -74,7 +74,7 @@ type InvoiceLineItem struct { Quantity int64 `json:"quantity"` // The subscription that the invoice item pertains to, if any. Subscription string `json:"subscription"` - // The subscription item that generated this invoice item. Left empty if the line item is not an explicit result of a subscription. + // The subscription item that generated this line item. Left empty if the line item is not an explicit result of a subscription. SubscriptionItem string `json:"subscription_item"` // The amount of tax calculated per tax rate for this line item TaxAmounts []*InvoiceTotalTaxAmount `json:"tax_amounts"` diff --git a/paymentlink.go b/paymentlink.go index f69270ba15..761ea6bb15 100644 --- a/paymentlink.go +++ b/paymentlink.go @@ -44,6 +44,24 @@ const ( PaymentLinkConsentCollectionTermsOfServiceRequired PaymentLinkConsentCollectionTermsOfService = "required" ) +// The type of the label. +type PaymentLinkCustomFieldLabelType string + +// List of values that PaymentLinkCustomFieldLabelType can take +const ( + PaymentLinkCustomFieldLabelTypeCustom PaymentLinkCustomFieldLabelType = "custom" +) + +// The type of the field. +type PaymentLinkCustomFieldType string + +// List of values that PaymentLinkCustomFieldType can take +const ( + PaymentLinkCustomFieldTypeDropdown PaymentLinkCustomFieldType = "dropdown" + PaymentLinkCustomFieldTypeNumeric PaymentLinkCustomFieldType = "numeric" + PaymentLinkCustomFieldTypeText PaymentLinkCustomFieldType = "text" +) + // Configuration for Customer creation during checkout. type PaymentLinkCustomerCreation string @@ -169,6 +187,42 @@ type PaymentLinkConsentCollectionParams struct { TermsOfService *string `form:"terms_of_service"` } +// The options available for the customer to select. Up to 200 options allowed. +type PaymentLinkCustomFieldDropdownOptionParams struct { + // The label for the option, displayed to the customer. Up to 100 characters. + Label *string `form:"label"` + // The value for this option, not displayed to the customer, used by your integration to reconcile the option selected by the customer. Must be unique to this option, alphanumeric, and up to 100 characters. + Value *string `form:"value"` +} + +// Configuration for `type=dropdown` fields. +type PaymentLinkCustomFieldDropdownParams struct { + // The options available for the customer to select. Up to 200 options allowed. + Options []*PaymentLinkCustomFieldDropdownOptionParams `form:"options"` +} + +// The label for the field, displayed to the customer. +type PaymentLinkCustomFieldLabelParams struct { + // Custom text for the label, displayed to the customer. Up to 50 characters. + Custom *string `form:"custom"` + // The type of the label. + Type *string `form:"type"` +} + +// Collect additional information from your customer using custom fields. Up to 2 fields are supported. +type PaymentLinkCustomFieldParams struct { + // Configuration for `type=dropdown` fields. + Dropdown *PaymentLinkCustomFieldDropdownParams `form:"dropdown"` + // String of your choice that your integration can use to reconcile this field. Must be unique to this field, alphanumeric, and up to 200 characters. + Key *string `form:"key"` + // The label for the field, displayed to the customer. + Label *PaymentLinkCustomFieldLabelParams `form:"label"` + // Whether the customer is required to complete the field before completing the Checkout Session. Defaults to `false`. + Optional *bool `form:"optional"` + // The type of the field. + Type *string `form:"type"` +} + // Custom text that should be displayed alongside shipping address collection. type PaymentLinkCustomTextShippingAddressParams struct { // Text may be up to 1000 characters in length. @@ -336,6 +390,8 @@ type PaymentLinkParams struct { Currency *string `form:"currency"` // Configures whether [checkout sessions](https://stripe.com/docs/api/checkout/sessions) created by this payment link create a [Customer](https://stripe.com/docs/api/customers). CustomerCreation *string `form:"customer_creation"` + // Collect additional information from your customer using custom fields. Up to 2 fields are supported. + CustomFields []*PaymentLinkCustomFieldParams `form:"custom_fields"` // Display additional text for your customers using custom text. CustomText *PaymentLinkCustomTextParams `form:"custom_text"` // Generate a post-purchase Invoice for one-time payments. @@ -404,6 +460,39 @@ type PaymentLinkConsentCollection struct { TermsOfService PaymentLinkConsentCollectionTermsOfService `json:"terms_of_service"` } +// The options available for the customer to select. Up to 200 options allowed. +type PaymentLinkCustomFieldDropdownOption struct { + // The label for the option, displayed to the customer. Up to 100 characters. + Label string `json:"label"` + // The value for this option, not displayed to the customer, used by your integration to reconcile the option selected by the customer. Must be unique to this option, alphanumeric, and up to 100 characters. + Value string `json:"value"` +} + +// Configuration for `type=dropdown` fields. +type PaymentLinkCustomFieldDropdown struct { + // The options available for the customer to select. Up to 200 options allowed. + Options []*PaymentLinkCustomFieldDropdownOption `json:"options"` +} +type PaymentLinkCustomFieldLabel struct { + // Custom text for the label, displayed to the customer. Up to 50 characters. + Custom string `json:"custom"` + // The type of the label. + Type PaymentLinkCustomFieldLabelType `json:"type"` +} + +// Collect additional information from your customer using custom fields. Up to 2 fields are supported. +type PaymentLinkCustomField struct { + // Configuration for `type=dropdown` fields. + Dropdown *PaymentLinkCustomFieldDropdown `json:"dropdown"` + // String of your choice that your integration can use to reconcile this field. Must be unique to this field, alphanumeric, and up to 200 characters. + Key string `json:"key"` + Label *PaymentLinkCustomFieldLabel `json:"label"` + // Whether the customer is required to complete the field before completing the Checkout Session. Defaults to `false`. + Optional bool `json:"optional"` + // The type of the field. + Type PaymentLinkCustomFieldType `json:"type"` +} + // Custom text that should be displayed alongside shipping address collection. type PaymentLinkCustomTextShippingAddress struct { // Text may be up to 1000 characters in length. @@ -531,7 +620,9 @@ type PaymentLink struct { Currency Currency `json:"currency"` // Configuration for Customer creation during checkout. CustomerCreation PaymentLinkCustomerCreation `json:"customer_creation"` - CustomText *PaymentLinkCustomText `json:"custom_text"` + // Collect additional information from your customer using custom fields. Up to 2 fields are supported. + CustomFields []*PaymentLinkCustomField `json:"custom_fields"` + CustomText *PaymentLinkCustomText `json:"custom_text"` // Unique identifier for the object. ID string `json:"id"` // Configuration for creating invoice for payment mode payment links. diff --git a/refund.go b/refund.go index a637c9749e..bf16906af5 100644 --- a/refund.go +++ b/refund.go @@ -8,7 +8,7 @@ package stripe import "encoding/json" -// If the refund failed, the reason for refund failure if known. Possible values are `lost_or_stolen_card`, `expired_or_canceled_card`, or `unknown`. +// If the refund failed, the reason for refund failure if known. Possible values are `lost_or_stolen_card`, `expired_or_canceled_card`, `charge_for_pending_refund_disputed`, `insufficient_funds`, `declined`, `merchant_request` or `unknown`. type RefundFailureReason string // List of values that RefundFailureReason can take @@ -119,7 +119,7 @@ type Refund struct { Description string `json:"description"` // If the refund failed, this balance transaction describes the adjustment made on your account balance that reverses the initial balance transaction. FailureBalanceTransaction *BalanceTransaction `json:"failure_balance_transaction"` - // If the refund failed, the reason for refund failure if known. Possible values are `lost_or_stolen_card`, `expired_or_canceled_card`, or `unknown`. + // If the refund failed, the reason for refund failure if known. Possible values are `lost_or_stolen_card`, `expired_or_canceled_card`, `charge_for_pending_refund_disputed`, `insufficient_funds`, `declined`, `merchant_request` or `unknown`. FailureReason RefundFailureReason `json:"failure_reason"` // Unique identifier for the object. ID string `json:"id"` diff --git a/reporting_reportrun.go b/reporting_reportrun.go index 692f8dd030..1bbbc0cc98 100644 --- a/reporting_reportrun.go +++ b/reporting_reportrun.go @@ -61,9 +61,9 @@ type ReportingReportRunParameters struct { ConnectedAccount string `json:"connected_account"` // Currency of objects to be included in the report run. Currency Currency `json:"currency"` - // Ending timestamp of data to be included in the report run (exclusive). + // Ending timestamp of data to be included in the report run. Can be any UTC timestamp between 1 second after the user specified `interval_start` and 1 second before this report's last `data_available_end` value. IntervalEnd int64 `json:"interval_end"` - // Starting timestamp of data to be included in the report run. + // Starting timestamp of data to be included in the report run. Can be any UTC timestamp between 1 second after this report's `data_available_start` and 1 second before the user specified `interval_end` value. IntervalStart int64 `json:"interval_start"` // Payout ID by which to filter the report run. Payout string `json:"payout"` diff --git a/subscriptionitem.go b/subscriptionitem.go index 7b3521dd2b..47ce9b0156 100644 --- a/subscriptionitem.go +++ b/subscriptionitem.go @@ -15,7 +15,7 @@ type SubscriptionItemListParams struct { // Define thresholds at which an invoice will be sent, and the subscription advanced to a new billing period. When updating, pass an empty string to remove previously-defined thresholds. type SubscriptionItemBillingThresholdsParams struct { - // Usage threshold that triggers the subscription to advance to a new billing period + // Number of units that meets the billing threshold to advance the subscription to a new billing period (e.g., it takes 10 $5 units to meet a $50 [monetary threshold](https://stripe.com/docs/api/subscriptions/update#update_subscription-billing_thresholds-amount_gte)) UsageGTE *int64 `form:"usage_gte"` } diff --git a/terminal/reader/client.go b/terminal/reader/client.go index 5d9dcf76f2..ac0b20787a 100644 --- a/terminal/reader/client.go +++ b/terminal/reader/client.go @@ -122,6 +122,19 @@ func (c Client) ProcessSetupIntent(id string, params *stripe.TerminalReaderProce return reader, err } +// RefundPayment is the method for the `POST /v1/terminal/readers/{reader}/refund_payment` API. +func RefundPayment(id string, params *stripe.TerminalReaderRefundPaymentParams) (*stripe.TerminalReader, error) { + return getC().RefundPayment(id, params) +} + +// RefundPayment is the method for the `POST /v1/terminal/readers/{reader}/refund_payment` API. +func (c Client) RefundPayment(id string, params *stripe.TerminalReaderRefundPaymentParams) (*stripe.TerminalReader, error) { + path := stripe.FormatURLPath("/v1/terminal/readers/%s/refund_payment", id) + reader := &stripe.TerminalReader{} + err := c.B.Call(http.MethodPost, path, c.Key, params, reader) + return reader, err +} + // SetReaderDisplay is the method for the `POST /v1/terminal/readers/{reader}/set_reader_display` API. func SetReaderDisplay(id string, params *stripe.TerminalReaderSetReaderDisplayParams) (*stripe.TerminalReader, error) { return getC().SetReaderDisplay(id, params) diff --git a/terminal_reader.go b/terminal_reader.go index 9c4ea4d358..e2032427bb 100644 --- a/terminal_reader.go +++ b/terminal_reader.go @@ -6,6 +6,16 @@ package stripe +// The reason for the refund. +type TerminalReaderActionRefundPaymentReason string + +// List of values that TerminalReaderActionRefundPaymentReason can take +const ( + TerminalReaderActionRefundPaymentReasonDuplicate TerminalReaderActionRefundPaymentReason = "duplicate" + TerminalReaderActionRefundPaymentReasonFraudulent TerminalReaderActionRefundPaymentReason = "fraudulent" + TerminalReaderActionRefundPaymentReasonRequestedByCustomer TerminalReaderActionRefundPaymentReason = "requested_by_customer" +) + // Type of information to be displayed by the reader. type TerminalReaderActionSetReaderDisplayType string @@ -31,6 +41,7 @@ type TerminalReaderActionType string const ( TerminalReaderActionTypeProcessPaymentIntent TerminalReaderActionType = "process_payment_intent" TerminalReaderActionTypeProcessSetupIntent TerminalReaderActionType = "process_setup_intent" + TerminalReaderActionTypeRefundPayment TerminalReaderActionType = "refund_payment" TerminalReaderActionTypeSetReaderDisplay TerminalReaderActionType = "set_reader_display" ) @@ -137,6 +148,21 @@ type TerminalReaderSetReaderDisplayParams struct { Type *string `form:"type"` } +// Initiates a refund on a Reader +type TerminalReaderRefundPaymentParams struct { + Params `form:"*"` + // A positive integer in __cents__ representing how much of this charge to refund. + Amount *int64 `form:"amount"` + // ID of the Charge to refund. + Charge *string `form:"charge"` + // ID of the PaymentIntent to refund. + PaymentIntent *string `form:"payment_intent"` + // Boolean indicating whether the application fee should be refunded when refunding this charge. If a full charge refund is given, the full application fee will be refunded. Otherwise, the application fee will be refunded in an amount proportional to the amount of the charge refunded. An application fee can be refunded only by the application that created the charge. + RefundApplicationFee *bool `form:"refund_application_fee"` + // Boolean indicating whether the transfer should be reversed when refunding this charge. The transfer will be reversed proportionally to the amount being refunded (either the entire or partial amount). A transfer can be reversed only by the application that created the charge. + ReverseTransfer *bool `form:"reverse_transfer"` +} + // Represents a per-transaction tipping configuration type TerminalReaderActionProcessPaymentIntentProcessConfigTipping struct { // Amount used to calculate tip suggestions on tipping selection screen for this transaction. Must be a positive integer in the smallest currency unit (e.g., 100 cents to represent $1.00 or 100 to represent ¥100, a zero-decimal currency). @@ -167,6 +193,26 @@ type TerminalReaderActionProcessSetupIntent struct { SetupIntent *SetupIntent `json:"setup_intent"` } +// Represents a reader action to refund a payment +type TerminalReaderActionRefundPayment struct { + // The amount being refunded. + Amount int64 `json:"amount"` + // Charge that is being refunded. + Charge *Charge `json:"charge"` + // 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"` + // Payment intent that is being refunded. + PaymentIntent *PaymentIntent `json:"payment_intent"` + // The reason for the refund. + Reason TerminalReaderActionRefundPaymentReason `json:"reason"` + // Unique identifier for the refund object. + Refund *Refund `json:"refund"` + // Boolean indicating whether the application fee should be refunded when refunding this charge. If a full charge refund is given, the full application fee will be refunded. Otherwise, the application fee will be refunded in an amount proportional to the amount of the charge refunded. An application fee can be refunded only by the application that created the charge. + RefundApplicationFee bool `json:"refund_application_fee"` + // Boolean indicating whether the transfer should be reversed when refunding this charge. The transfer will be reversed proportionally to the amount being refunded (either the entire or partial amount). A transfer can be reversed only by the application that created the charge. + ReverseTransfer bool `json:"reverse_transfer"` +} + // List of line items in the cart. type TerminalReaderActionSetReaderDisplayCartLineItem struct { // The amount of the line item. A positive integer in the [smallest currency unit](https://stripe.com/docs/currencies#zero-decimal). @@ -207,6 +253,8 @@ type TerminalReaderAction struct { ProcessPaymentIntent *TerminalReaderActionProcessPaymentIntent `json:"process_payment_intent"` // Represents a reader action to process a setup intent ProcessSetupIntent *TerminalReaderActionProcessSetupIntent `json:"process_setup_intent"` + // Represents a reader action to refund a payment + RefundPayment *TerminalReaderActionRefundPayment `json:"refund_payment"` // Represents a reader action to set the reader display SetReaderDisplay *TerminalReaderActionSetReaderDisplay `json:"set_reader_display"` // Status of the action performed by the reader. diff --git a/testhelpersterminal_reader.go b/testhelpersterminal_reader.go index 841115bf2c..33f41c017c 100644 --- a/testhelpersterminal_reader.go +++ b/testhelpersterminal_reader.go @@ -12,11 +12,19 @@ type TestHelpersTerminalReaderPresentPaymentMethodCardPresentParams struct { Number *string `form:"number"` } +// Simulated data for the interac_present payment method +type TestHelpersTerminalReaderPresentPaymentMethodInteracPresentParams struct { + // Card Number + Number *string `form:"number"` +} + // Presents a payment method on a simulated reader. Can be used to simulate accepting a payment, saving a card or refunding a transaction. type TestHelpersTerminalReaderPresentPaymentMethodParams struct { Params `form:"*"` // Simulated data for the card_present payment method CardPresent *TestHelpersTerminalReaderPresentPaymentMethodCardPresentParams `form:"card_present"` + // Simulated data for the interac_present payment method + InteracPresent *TestHelpersTerminalReaderPresentPaymentMethodInteracPresentParams `form:"interac_present"` // Simulated payment type Type *string `form:"type"` }