Skip to content

Commit

Permalink
Add automaticTax property to Session.create (#147)
Browse files Browse the repository at this point in the history
  • Loading branch information
winsmith authored Mar 14, 2023
1 parent 58ea4f4 commit 211a1fe
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Sources/StripeKit/Checkout/SessionRoutes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -62,6 +63,7 @@ public protocol SessionRoutes {
submitType: StripeSessionSubmitType?,
subscriptionData: [String: Any]?,
taxIdCollection: [String: Any]?,
automaticTax: [String: Any]?,
expand: [String]?) -> EventLoopFuture<StripeSession>

/// A Session can be expired when it is in one of these statuses: open
Expand Down Expand Up @@ -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<StripeSession> {
return create(cancelUrl: cancelUrl,
paymentMethodTypes: paymentMethodTypes,
Expand All @@ -143,6 +146,7 @@ extension SessionRoutes {
submitType: submitType,
subscriptionData: subscriptionData,
taxIdCollection: taxIdCollection,
automaticTax: automaticTax,
expand: expand)
}

Expand Down Expand Up @@ -197,6 +201,7 @@ public struct StripeSessionRoutes: SessionRoutes {
submitType: StripeSessionSubmitType?,
subscriptionData: [String: Any]?,
taxIdCollection: [String: Any]?,
automaticTax: [String: Any]?,
expand: [String]?) -> EventLoopFuture<StripeSession> {
var body: [String: Any] = ["cancel_url": cancelUrl,
"payment_method_types": paymentMethodTypes.map { $0.rawValue },
Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit 211a1fe

Please sign in to comment.