Skip to content

Instantly share code, notes, and snippets.

@zra95
Last active April 18, 2016 15:59
Show Gist options
  • Save zra95/094e3520e0ab3ac6f7605c62a23d8139 to your computer and use it in GitHub Desktop.
Save zra95/094e3520e0ab3ac6f7605c62a23d8139 to your computer and use it in GitHub Desktop.
import Foundation
import Stripe
struct StripeTools {
//store stripe secret key
private var stripeSecret = "mysecrettestkey"
//generate token each time you need to get an api call
func generateToken(card: STPCardParams, completion: (token: STPToken?) -> Void) {
STPAPIClient.sharedClient().createTokenWithCard(card) { token, error in
if let token = token {
completion(token: token)
}
else {
print(error)
completion(token: nil)
}
}
}
func getBasicAuth() -> String{
return "Bearer \(self.stripeSecret)"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment