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