【问题标题】:How to make charge using stripe in iOS?如何在 iOS 中使用 Stripe 进行充电?
【发布时间】: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 应用上进行信用卡支付,因为在这个示例代码中,有关于支付的信息。

【问题讨论】:

标签: ios objective-c stripe-payments


【解决方案1】:

您正在使用example.com。先换成你自己的服务器地址。

【讨论】:

    【解决方案2】:

    要在 Stripe 中为卡充电,您需要一个服务器模块。 Here 详细说明如何通过服务器模块为您的卡充电。如果您使用 parse 作为后端,您始终可以为此目的使用 cloudcode。

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

    【讨论】:

      猜你喜欢
      • 2012-12-21
      • 2021-09-01
      • 2017-12-26
      • 2016-11-17
      • 1970-01-01
      • 2021-11-28
      • 2014-03-30
      • 2016-10-25
      • 1970-01-01
      相关资源
      最近更新 更多