繁体   English   中英

如何在iOS中使用条纹进行充电?

[英]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 首先用您自己的服务器地址替换它。

要在Stripe中为卡充电,您需要一个服务器模块。 以下是如何通过服务器模块为卡充电的详细说明。 如果您使用解析作为后端,则可以始终使用云代码来实现此目的。

是raywenderlich对使用python后端制作支付系统的解释。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM