我在用Apple Pay
在我的 iPhone 应用程序中与支付提供商Stripe
.
我使用 test_key 实现了 Apple Pay,它返回令牌并获取PKPaymentAuthorizationStatusSuccess
在模拟器中。
事实上,我不知道什么时候可以从真实设备上完成实时支付。
我有一个question是 我需要发送吗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];
}
请建议我们只从服务器收费吗?
Thanks
您需要将令牌发送到您的服务器。
创建费用需要您的秘密 API 密钥,该密钥永远不能从您的 iPhone 应用程序访问。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)