From 9e1fcbde0c1bf50ad0d4940b2f8abe95d961dbd2 Mon Sep 17 00:00:00 2001 From: Anthony Castelli Date: Sat, 7 Apr 2018 14:15:17 -0700 Subject: [PATCH 1/3] provider: Mark the API Key public Depending on what you are doing (such as connecting accounts together) this API is required in the oAuth call. Marking this public allows easy access to grab the API key thats defineds in one place. --- Sources/Stripe/Provider/Provider.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/Stripe/Provider/Provider.swift b/Sources/Stripe/Provider/Provider.swift index 8189ada..87046cd 100644 --- a/Sources/Stripe/Provider/Provider.swift +++ b/Sources/Stripe/Provider/Provider.swift @@ -9,7 +9,7 @@ import Vapor public struct StripeConfig: Service { - let apiKey: String + public let apiKey: String public init(apiKey: String) { self.apiKey = apiKey } From bdf85a0dfaa37356680d06d2e9f52c28ba54d16f Mon Sep 17 00:00:00 2001 From: Anthony Castelli Date: Sun, 8 Apr 2018 10:38:15 -0700 Subject: [PATCH 2/3] subscriptions: Fix up the items and how they are parsed --- Sources/Stripe/API/Routes/SubscriptionRoutes.swift | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Sources/Stripe/API/Routes/SubscriptionRoutes.swift b/Sources/Stripe/API/Routes/SubscriptionRoutes.swift index 544ac4e..c2c26e8 100644 --- a/Sources/Stripe/API/Routes/SubscriptionRoutes.swift +++ b/Sources/Stripe/API/Routes/SubscriptionRoutes.swift @@ -37,7 +37,7 @@ public struct StripeSubscriptionRoutes: SubscriptionRoutes { billingCycleAnchor: Date? = nil, coupon: String? = nil, daysUntilDue: Int? = nil, - items: [String : Any]? = nil, + items: [[String : Any]]? = nil, metadata: [String : String]? = nil, source: Any? = nil, taxPercent: Decimal? = nil, @@ -68,7 +68,9 @@ public struct StripeSubscriptionRoutes: SubscriptionRoutes { } if let items = items { - items.forEach { body["items[\($0)]"] = $1 } + for (index, item) in items.enumerated() { + item.forEach { body["items[\(index)][\($0)]"] = $1 } + } } if let metadata = metadata { @@ -116,7 +118,7 @@ public struct StripeSubscriptionRoutes: SubscriptionRoutes { billingCycleAnchor: String? = nil, coupon: String? = nil, daysUntilDue: Int? = nil, - items: [String : Any]? = nil, + items: [[String : Any]]? = nil, metadata: [String : String]? = nil, prorate: Bool? = nil, prorationDate: Date? = nil, @@ -146,7 +148,9 @@ public struct StripeSubscriptionRoutes: SubscriptionRoutes { } if let items = items { - items.forEach { body["items[\($0)]"] = $1 } + for (index, item) in items.enumerated() { + item.forEach { body["items[\(index)][\($0)]"] = $1 } + } } if let metadata = metadata { From 4eff3bcfc2ada722c8156f71f82009e2a61ef1cf Mon Sep 17 00:00:00 2001 From: Anthony Castelli Date: Sun, 8 Apr 2018 10:42:08 -0700 Subject: [PATCH 3/3] subscriptions: Forgot to update the protocols --- Sources/Stripe/API/Routes/SubscriptionRoutes.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sources/Stripe/API/Routes/SubscriptionRoutes.swift b/Sources/Stripe/API/Routes/SubscriptionRoutes.swift index c2c26e8..fdef113 100644 --- a/Sources/Stripe/API/Routes/SubscriptionRoutes.swift +++ b/Sources/Stripe/API/Routes/SubscriptionRoutes.swift @@ -14,9 +14,9 @@ public protocol SubscriptionRoutes { associatedtype L: List associatedtype DO: DeletedObject - func create(customer: String, applicationFeePercent: Decimal?, billing: String?, billingCycleAnchor: Date?, coupon: String?, daysUntilDue: Int?, items: [String: Any]?, metadata: [String: String]?, source: Any?, taxPercent: Decimal?, trialEnd: Any?, trialPeriodDays: Int?) throws -> Future + func create(customer: String, applicationFeePercent: Decimal?, billing: String?, billingCycleAnchor: Date?, coupon: String?, daysUntilDue: Int?, items: [[String : Any]]?, metadata: [String: String]?, source: Any?, taxPercent: Decimal?, trialEnd: Any?, trialPeriodDays: Int?) throws -> Future func retrieve(id: String) throws -> Future - func update(subscription: String, applicationFeePercent: Decimal?, billing: String?, billingCycleAnchor: String?, coupon: String?, daysUntilDue: Int?, items: [String: Any]?, metadata: [String: String]?, prorate: Bool?, prorationDate: Date?, source: Any?, taxPercent: Decimal?, trialEnd: Any?) throws -> Future + func update(subscription: String, applicationFeePercent: Decimal?, billing: String?, billingCycleAnchor: String?, coupon: String?, daysUntilDue: Int?, items: [[String : Any]]?, metadata: [String: String]?, prorate: Bool?, prorationDate: Date?, source: Any?, taxPercent: Decimal?, trialEnd: Any?) throws -> Future func cancel(subscription: String, atPeriodEnd: Bool?) throws -> Future func listAll(filter: [String: Any]?) throws -> Future func deleteDiscount(subscription: String) throws -> Future