【发布时间】:2014-06-06 09:34:30
【问题描述】:
我已阅读有关 iOS 应用程序 from here 中的条带集成的所有详细信息。并通过下载from here运行stripe的示例应用。
在运行此应用程序时,我在 iPhone 模拟器上进行测试时遇到以下错误。
收到令牌后调用以下方法::
- (void)hasError:(NSError *)error
{
UIAlertView *message = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Error", @"Error")
message:[error localizedDescription]
delegate:nil
cancelButtonTitle:NSLocalizedString(@"OK", @"OK")
otherButtonTitles:nil];
[message show];
}
//--Called after sucessfully token received ::
- (void)hasToken:(STPToken *)token
{
NSLog(@"Received token %@", token.tokenId);
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:@"https://example.com"]];
request.HTTPMethod = @"POST";
NSString *body = [NSString stringWithFormat:@"stripeToken=%@", token.tokenId];
request.HTTPBody = [body dataUsingEncoding:NSUTF8StringEncoding];
[MBProgressHUD showHUDAddedTo:self.view animated:YES];
[NSURLConnection sendAsynchronousRequest:request
queue:[NSOperationQueue mainQueue]
completionHandler:^(NSURLResponse *response, NSData *data, NSError *error) {
[MBProgressHUD hideHUDForView:self.view animated:YES];
if (error) {
[self hasError:error];
} else {
NSString *str = [[NSString alloc]initWithData:data encoding:NSUTF8StringEncoding];
NSLog(@"\nStr is :::%@",str);
NSLog(@"\n\nResponse is :::%@",response);
[self.navigationController popViewControllerAnimated:YES];
}
}];
}
请告诉我如何解决这个问题并在 iOS 应用上进行信用卡支付,因为在这个示例代码中,有关于支付的信息。
【问题讨论】:
-
这里有一个教程和一个可以帮助你的示例应用程序:monolithapps.com/blog/…。
标签: ios objective-c stripe-payments