From fac46ddb3c0918f2230bc3fa8088fe1403033b9e Mon Sep 17 00:00:00 2001 From: Anthony Castelli Date: Wed, 7 Jun 2017 13:13:36 -0700 Subject: [PATCH] tokens: Add token creation for connect accounts --- Sources/API/Routes/TokenRoutes.swift | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Sources/API/Routes/TokenRoutes.swift b/Sources/API/Routes/TokenRoutes.swift index c8321d7..a939e34 100644 --- a/Sources/API/Routes/TokenRoutes.swift +++ b/Sources/API/Routes/TokenRoutes.swift @@ -156,9 +156,15 @@ public final class TokenRoutes { - returns: A StripeRequest<> item which you can then use to convert to the corresponding node */ - public func createToken(withCustomerId customerId: String) throws -> StripeRequest { + public func createToken(withCustomerId customerId: String, onAccount account: String? = nil) throws -> StripeRequest { let body = try Node(node: ["customer": customerId]) - return try StripeRequest(client: self.client, method: .post, route: .tokens, body: Body.data(body.formURLEncoded())) + var headers: [HeaderKey : String]? + if let account = account { + headers = [ + StripeHeader.Account: account + ] + } + return try StripeRequest(client: self.client, method: .post, route: .tokens, body: Body.data(body.formURLEncoded()), headers: headers) } /**