Skip to content

Commit

Permalink
tokens: Add a new createToken with customerId
Browse files Browse the repository at this point in the history
  • Loading branch information
anthonycastelli committed Jun 6, 2017
1 parent 4ec0087 commit 3990261
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions Sources/API/Routes/TokenRoutes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,18 @@ public final class TokenRoutes {
return try StripeRequest(client: self.client, method: .post, route: .tokens, body: Body.data(body.formURLEncoded()), headers: nil)
}

/**
Create a payment token from a customer

- parameter withCustomerId: The customer ID to generate the token with

- returns: A StripeRequest<> item which you can then use to convert to the corresponding node
*/
public func createToken(withCustomerId customerId: String) throws -> StripeRequest<Token> {
let body = try Node(node: ["customer": customerId])
return try StripeRequest(client: self.client, method: .post, route: .tokens, body: Body.data(body.formURLEncoded()))
}

/**
Retrieve a token
Retrieves the token with the given ID.
Expand Down

0 comments on commit 3990261

Please sign in to comment.