簡體   English   中英

有沒有辦法從我的服務器沒有后端費用從iOS應用程序收取卡。(條紋 - iOS)

[英]Is there any way to charge card from iOS App without backend charge from our server.(Stripe - iOS)

我正在使用Stripe付款。 我想從我的應用程序收取卡。 目前我使用下面的代碼來收費卡,但過程是從服務器端完成的。 有沒有辦法從應用程序收取卡而不是發送stripeToken到服務器?

-(void)createBackendChargeWithToken:(STPToken *)token completion:(void (^)(PKPaymentAuthorizationStatus))completion {
    NSURL *url = [NSURL URLWithString:@"https://example.com/token"];
    NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url];
    request.HTTPMethod = @"POST";
    NSString *body     = [NSString stringWithFormat:@"stripeToken=%@&amount=%@", token.tokenId,_txtAmount.text];
    request.HTTPBody   = [body dataUsingEncoding:NSUTF8StringEncoding];
    NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration];
    NSURLSession *session = [NSURLSession sessionWithConfiguration:configuration];
    NSURLSessionDataTask *task =
    [session dataTaskWithRequest:request
               completionHandler:^(NSData *data,
                                   NSURLResponse *response,
                                   NSError *error) {
                   if (error) {
                       completion(PKPaymentAuthorizationStatusFailure);
                       // [self customeAlertView:@"Payment not successful" message:@"Please try again later."];
                       NSLog(@"Payment not successful. Please try again later.");
                   } else {
                       completion(PKPaymentAuthorizationStatusSuccess);
                       // [self customeAlertView:@"Success" message:@"Please enjoy your new purchase."];
                       NSLog(@"Payment Success. Please enjoy your new purchase.");
                   }
               }];
    [task resume];
}

不,這是不可能的。 Stripe的iOSAndroid綁定僅用於收集卡信息和創建令牌,就像Web應用程序中的Stripe.jsCheckout一樣。

創建令牌后,必須將其發送到外部服務器,您可以在API服務器中使用它,例如創建費用

必須使用外部服務器的原因是除了令牌創建之外的所有API請求都必須使用您的秘密API密鑰發布,該密鑰不能直接用於您的應用程序,否則惡意用戶將能夠檢索它並使用它來訪問您的帳戶。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM