【发布时间】:2016-04-21 00:30:46
【问题描述】:
我在我的 iPhone 应用程序中使用Apple Pay 和支付提供商Stripe。
我使用 test_key 实现了 Apple Pay,它返回令牌并在模拟器中获取 PKPaymentAuthorizationStatusSuccess。
实际上,我不知道何时会在真实设备上完成实时付款。
我有一个问题是我需要发送
Token到服务器来收费吗 为该付款或将使用 iPhone 应用程序自行收费一次 获得令牌?
按照下面的方法,他们将令牌发送到服务器,所以它只会在服务器上收费?
- (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=%@", token.tokenId];
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);
;
}
else
{
completion(PKPaymentAuthorizationStatusSuccess);
}
}];
[task resume];
}
请建议我们只从服务器收费吗?
谢谢
【问题讨论】:
标签: ios iphone stripe-payments applepay