簡體   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