使用Stripe的Apple Pay将令牌发送到服务器并收取费用 [英] Apple Pay using Stripe send token to server and charge for purchase

查看:84
本文介绍了使用Stripe的Apple Pay将令牌发送到服务器并收取费用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的iPhone应用程序中将 Apple Pay 与付款提供商 Stripe 一起使用.

I am using Apple Pay in my iPhone application with payment Provider Stripe.

我使用test_key实现了Apple Pay,它返回令牌并在模拟器中获取 PKPaymentAuthorizationStatusSuccess .

I implemented Apple Pay using test_key and it returns token and getting PKPaymentAuthorizationStatusSuccess in simulator.

实际上,我不知道从真实设备完成付款的实时性.

Actually, I don't know the real time payment when it will done from the real device.

我有一个问题,是否需要将 Token 发送到服务器进行收费支付该费用,或者一次使用iPhone应用程序向其收费得到令牌?

I have a question is Do I need to send Token to server to charge for that payment or will charge itself withing iPhone application once get token?

按照以下方法,他们正在向服务器发送令牌,因此它将仅在服务器上收费吗?

As per below method they are sending token to server so It will charge only on server?

- (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];
}

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

Please suggest do we charge only from server?

谢谢

推荐答案

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

You need to send the token to your server.

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

Creating a charge requires your secret API key which should never be accessible from your iPhone app.

这篇关于使用Stripe的Apple Pay将令牌发送到服务器并收取费用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆