Apple Pay使用Stripe将令牌发送到服务器并收取购买费用

我在我的iPhone应用程序中使用Apple Pay支付Provider 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]; } 

请建议我们只从服务器收费吗?

谢谢

您需要将令牌发送到您的服务器。

创建费用需要您的秘密API密钥,永远不能从您的iPhone应用程序访问。