Braintree客户端令牌无效

时间:2015-05-19 05:10:28

标签: php ios braintree

我能够生成客户端令牌但它说BTClient无法初始化,因为当我在iOS客户端使用时提供的clientToken无效

服务器端代码在php中: -

NSURL *clientTokenURL = [NSURL URLWithString:@"http://192.168.1.1:8888/gettoken.php"];
    NSMutableURLRequest *clientTokenRequest = [NSMutableURLRequest requestWithURL:clientTokenURL];
    [clientTokenRequest setValue:@"text/plain" forHTTPHeaderField:@"Accept"];

    [NSURLConnection
     sendAsynchronousRequest:clientTokenRequest
     queue:[NSOperationQueue mainQueue]
     completionHandler:^(NSURLResponse *response, NSData *data, NSError *connectionError) {
         // TODO: Handle errors in [(NSHTTPURLResponse *)response statusCode] and connectionError
         NSString *clientToken = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];

         // Initialize `Braintree` once per checkout session
         self.braintree = [Braintree braintreeWithClientToken:clientToken];

         // As an example, you may wish to present our Drop-In UI at this point.
         // Continue to the next section to learn more...
     }];

编辑1: - 在这里,我只想模仿从我们的服务器获取客户端令牌(就像braintree在这里完成https://braintree-sample-merchant.herokuapp.com/client_token) 我按照你的指示从这里创建了简单的服务器https://developers.braintreepayments.com/ios+php/start/hello-server,我的文件也生成了客户端令牌,但是当我在我的iOS应用程序中使用时,它给出了错误“BTClient无法初始化,因为提供的clientToken无效”

这是我的iOS代码

CGPoint ButtonPoint = [sender convertPoint:CGPointZero toView:self.collectionView];
    NSIndexPath *ButtonIndex = [self.collectionView indexPathForItemAtPoint:ButtonPoint];
buttonindexpath = ButtonIndex.row
[collectionView reloadData];

0 个答案:

没有答案