diff --git a/Sources/StripeKit/Checkout/SessionRoutes.swift b/Sources/StripeKit/Checkout/SessionRoutes.swift index ccce857b..d83dfb95 100644 --- a/Sources/StripeKit/Checkout/SessionRoutes.swift +++ b/Sources/StripeKit/Checkout/SessionRoutes.swift @@ -26,6 +26,7 @@ public protocol SessionRoutes { /// - locale: The IETF language tag of the locale Checkout is displayed in. If blank or auto, the browser’s locale is used. Supported values are auto, da, de, en, es, fi, fr, it, ja, nb, nl, pl, pt, sv, or zh. /// - metadata: Set of key-value pairs 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`. /// - mode: The mode of the Checkout Session, one of `payment`, `setup`, or `subscription`. + /// - invoiceCreation: The Invoice creation of the Checkout Session for successful one-time payments. /// - paymentIntentData: A subset of parameters to be passed to PaymentIntent creation. /// - paymentMethodOptions: Payment-method-specific configuration. /// - phoneNumberCollection: Controls phone number collection settings for the session. We recommend that you review your privacy policy and check with your legal contacts before using this feature. Learn more about collecting phone numbers with Checkout. @@ -51,6 +52,7 @@ public protocol SessionRoutes { locale: StripeSessionLocale?, metadata: [String: String]?, mode: StripeSessionMode?, + invoiceCreation: StripeInvoiceCreation?, paymentIntentData: [String: Any]?, paymentMethodOptions: [String: Any]?, phoneNumberCollection: Bool?, @@ -106,6 +108,7 @@ extension SessionRoutes { locale: StripeSessionLocale? = nil, metadata: [String: String]? = nil, mode: StripeSessionMode? = nil, + invoiceCreation: StripeInvoiceCreation? = nil, paymentIntentData: [String: Any]? = nil, paymentMethodOptions: [String: Any]? = nil, phoneNumberCollection: Bool? = nil, @@ -130,6 +133,7 @@ extension SessionRoutes { locale: locale, metadata: metadata, mode: mode, + invoiceCreation: invoiceCreation, paymentIntentData: paymentIntentData, paymentMethodOptions: paymentMethodOptions, phoneNumberCollection: phoneNumberCollection, @@ -183,6 +187,7 @@ public struct StripeSessionRoutes: SessionRoutes { locale: StripeSessionLocale?, metadata: [String: String]?, mode: StripeSessionMode?, + invoiceCreation: StripeInvoiceCreation?, paymentIntentData: [String: Any]?, paymentMethodOptions: [String: Any]?, phoneNumberCollection: Bool?, @@ -241,6 +246,10 @@ public struct StripeSessionRoutes: SessionRoutes { body["mode"] = mode } + if let invoiceCreation = invoiceCreation { + body["invoice_creation"] = invoiceCreation + } + if let paymentIntentData = paymentIntentData { paymentIntentData.forEach { body["payment_intent_data[\($0)]"] = $1 } } diff --git a/Sources/StripeKit/Checkout/Sessions.swift b/Sources/StripeKit/Checkout/Sessions.swift index 68bc19f7..6445c4ab 100644 --- a/Sources/StripeKit/Checkout/Sessions.swift +++ b/Sources/StripeKit/Checkout/Sessions.swift @@ -43,6 +43,8 @@ public struct StripeSession: StripeModel { public var mode: StripeSessionMode? /// The ID of the PaymentIntent created if SKUs or line items were provided. @Expandable public var paymentIntent: String? + /// Enable invoice creation of this CheckoutSession. + public var invoiceCreation: StripeInvoiceCreation? /// Payment-method-specific configuration for the PaymentIntent or SetupIntent of this CheckoutSession. public var paymentMethodOptions: StripeSessionPaymentMethodOptions? /// Details on the state of phone number collection for the session. @@ -196,6 +198,11 @@ public enum StripeSessionMode: String, StripeModel { case subscription } +public struct StripeInvoiceCreation: StripeModel { + /// Indicates whether invoice creation is enabled for the session + public var enabled: Bool +} + public struct StripeSessionPaymentMethodOptions: StripeModel { /// If the Checkout Session’s `payment_method_types` includes `acss_debit`, this hash contains the configurations that will be applied to each payment attempt of that type. public var acssDebit: StripeSessionPaymentMethodOptionsAcssDebit?