accept extra params for token POST

This commit is contained in:
Alex MacCaw 2013-02-14 13:46:49 -08:00
parent 85092e7b94
commit 12ba09a56f
3 changed files with 10 additions and 5 deletions

View File

@ -10,7 +10,7 @@ You can install the Stripe iOS bindings in two ways.
[CocoaPods](http://cocoapods.org/) is a library dependency management tool for Objective-C. To use the Stripe iOS bindings with CocoaPods, simply add the following to your `Podfile` and run `pod install`:
pod `Stripe`, :git => 'https://github.com/stripe/stripe-ios.git'
pod 'Stripe', :git => 'https://github.com/stripe/stripe-ios.git'
### Install by adding files to project

View File

@ -21,7 +21,7 @@
@property (readonly) NSDate *created;
@property (readonly) BOOL used;
- (void)postToURL:(NSURL*)url completionHandler:(void (^)(NSURLResponse*, NSData*, NSError*))handler;
- (void)postToURL:(NSURL*)url withParams:(NSDictionary*)params completionHandler:(void (^)(NSURLResponse*, NSData*, NSError*))handler;
/*
This method should not be invoked in your code. This is used by Stripe to

View File

@ -27,13 +27,18 @@
return self;
}
- (void)postToURL:(NSURL*)url completionHandler:(void (^)(NSURLResponse*, NSData*, NSError*))handler
- (void)postToURL:(NSURL*)url withParams:(NSMutableDictionary*)params completionHandler:(void (^)(NSURLResponse*, NSData*, NSError*))handler
{
NSString* params = [NSString stringWithFormat:@"stripeToken=%@", self.tokenId];
NSMutableString *body = [NSMutableString stringWithFormat:@"stripeToken=%@", self.tokenId];
[params enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) {
[body appendFormat:@"&%@=%@", key, obj];
}];
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url];
request.HTTPMethod = @"POST";
request.HTTPBody = [params dataUsingEncoding:NSUTF8StringEncoding];
request.HTTPBody = [body dataUsingEncoding:NSUTF8StringEncoding];
[NSURLConnection sendAsynchronousRequest:request
queue:[NSOperationQueue mainQueue]