有什么方法可以从iOS App收取卡费用而无需从我们的服务器收取后端费用。(Stripe-iOS)

Vvk*_*Vvk 3 objective-c ios stripe-payments

我正在使用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];
}
Run Code Online (Sandbox Code Playgroud)

Ywa*_*ain 6

不,这是不可能的。Stripe的iOSAndroid绑定仅用于收集卡信息并创建令牌,就像Stripe.jsCheckout在Web应用程序中一样。

令牌创建完成后,必须将其发送到外部服务器,您可以在此在API请求中使用它,例如创建一个charge

必须使用外部服务器的原因是,除令牌创建外,所有API请求都必须使用您的秘密API密钥发出,该密钥不得直接在您的应用程序中使用,否则恶意用户将能够检索它并使用它来访问您的帐户。