[英]How to make charge using stripe in iOS?
我已經從這里閱讀了有關iOS應用程序中條帶集成的所有細節。 並從這里下載運行條帶的示例應用程序。
在運行此應用程序時,我在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應用程序上進行信用卡付款,因為在此示例代碼中,有關於付款的信息。
您正在使用example.com
。 首先用您自己的服務器地址替換它。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.