From 211a1fe003ef6f5308065d8adbeb1bc641bb9236 Mon Sep 17 00:00:00 2001 From: Daniel Jilg Date: Tue, 14 Mar 2023 19:22:36 +0100 Subject: [PATCH] Add automaticTax property to Session.create (#147) --- Sources/StripeKit/Checkout/SessionRoutes.swift | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Sources/StripeKit/Checkout/SessionRoutes.swift b/Sources/StripeKit/Checkout/SessionRoutes.swift index 34e81a8e..0f6c63eb 100644 --- a/Sources/StripeKit/Checkout/SessionRoutes.swift +++ b/Sources/StripeKit/Checkout/SessionRoutes.swift @@ -36,6 +36,7 @@ public protocol SessionRoutes { /// - submitType: Describes the type of transaction being performed by Checkout in order to customize relevant text on the page, such as the submit button. `submit_type` can only be specified on Checkout Sessions in payment mode, but not Checkout Sessions in subscription or setup mode. Supported values are `auto`, `book`, `donate`, or `pay`. /// - subscriptionData: A subset of parameters to be passed to subscription creation. /// - taxIdCollection: Controls tax ID collection settings for the session. + /// - automaticTax: Settings for automatic tax lookup for this session and resulting payments, invoices, and subscriptions /// - expand: An array of propertiies to expand. /// - Returns: A `StripeSession`. func create(cancelUrl: String, @@ -62,6 +63,7 @@ public protocol SessionRoutes { submitType: StripeSessionSubmitType?, subscriptionData: [String: Any]?, taxIdCollection: [String: Any]?, + automaticTax: [String: Any]?, expand: [String]?) -> EventLoopFuture /// A Session can be expired when it is in one of these statuses: open @@ -118,6 +120,7 @@ extension SessionRoutes { submitType: StripeSessionSubmitType? = nil, subscriptionData: [String: Any]? = nil, taxIdCollection: [String: Any]? = nil, + automaticTax: [String: Any]? = nil, expand: [String]? = nil) -> EventLoopFuture { return create(cancelUrl: cancelUrl, paymentMethodTypes: paymentMethodTypes, @@ -143,6 +146,7 @@ extension SessionRoutes { submitType: submitType, subscriptionData: subscriptionData, taxIdCollection: taxIdCollection, + automaticTax: automaticTax, expand: expand) } @@ -197,6 +201,7 @@ public struct StripeSessionRoutes: SessionRoutes { submitType: StripeSessionSubmitType?, subscriptionData: [String: Any]?, taxIdCollection: [String: Any]?, + automaticTax: [String: Any]?, expand: [String]?) -> EventLoopFuture { var body: [String: Any] = ["cancel_url": cancelUrl, "payment_method_types": paymentMethodTypes.map { $0.rawValue }, @@ -286,6 +291,10 @@ public struct StripeSessionRoutes: SessionRoutes { taxIdCollection.forEach { body["tax_id_collection[\($0)]"] = $1 } } + if let automaticTax = automaticTax { + automaticTax.forEach { body["automatic_tax[\($0)]"] = $1 } + } + if let expand = expand { body["expand"] = expand }