【问题标题】:Apple Pay using Stripe send token to server and charge for purchaseApple Pay 使用 Stripe 向服务器发送令牌并收取购买费用
【发布时间】: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


    【解决方案1】:

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

    创建收费需要您的 API 密钥,您的 iPhone 应用程序永远无法访问该密钥。

    【讨论】:

      猜你喜欢
      • 2017-09-05
      • 2023-03-03
      • 1970-01-01
      • 1970-01-01
      • 2020-12-30
      • 1970-01-01
      • 2016-10-15
      • 2015-05-03
      • 1970-01-01
      相关资源
      最近更新 更多