Braintree iOS无法令牌化

时间:2014-10-30 17:15:32

标签: ios cocoapods braintree

我正在尝试用Braintree iOS标记信用卡。 这是我docs中的代码。

self.braintree = [Braintree braintreeWithClientToken:self.clientToken];
   BTClientCardRequest *request = [BTClientCardRequest new];
   request.number = @"4111111111111111";
    request.expirationMonth = @"12";
   request.expirationYear = @"2018";

    [self.braintree tokenizeCard:request
                 completion:^(NSString *nonce, NSError *error){

                 }];

不幸的是,我没有在项目中找到BTClientCardRequest类,尽管它位于Braintree API header directory中。

我的Podfile看起来像这样:

# Uncomment this line to define a global platform for your project
# platform :ios, "6.0"

source 'https://github.com/CocoaPods/Specs.git'

target "myproj" do
pod 'Braintree'
pod "Braintree/API"
end

target "myprojTests" do
pod 'Braintree'
pod "Braintree/API"
end

我的Podfile.lock看起来像这样:

PODS:
  - Braintree (3.3.1):
    - Braintree/API
    - Braintree/Drop-In
    - Braintree/Payments
    - Braintree/PayPal
    - Braintree/UI
    - Braintree/Venmo
  - Braintree/API (3.3.1)
  - Braintree/Drop-In (3.3.1):
    - Braintree/API
    - Braintree/Payments
    - Braintree/PayPal
    - Braintree/UI
    - Braintree/Venmo
  - Braintree/Payments (3.3.1):
    - Braintree/API
    - Braintree/PayPal
    - Braintree/Venmo
  - Braintree/PayPal (3.3.1):
    - Braintree/API
    - Braintree/UI
  - Braintree/UI (3.3.1)
  - Braintree/Venmo (3.3.1):
    - Braintree/API

DEPENDENCIES:
  - Braintree
  - Braintree/API

SPEC CHECKSUMS:
  Braintree: 34538ea612eb8aa2a1187fb273ac80fd496f0628

COCOAPODS: 0.34.1

我真的很困惑,为什么我不能在我的项目工作区中拥有这个课程以及其他几个课程。

1 个答案:

答案 0 :(得分:2)

根据您的Podfile.lock,您似乎已经使用旧版本的Braintree iOS(3.3.1)了。在此版本中,-[Braintree tokenizeCard…]与您使用过的$ cd /path/to/your/project $ pod update Braintree slightly different signature,基于[Braintree的在线文档] [2]。

我建议通过在终端中运行此命令来升级到最新版本:

[braintree tokenizeCardWithNumber:@"4111111111111111"
                   expirationMonth:@"12"
                   expirationYear:@"2020"
                       completion:^(NSString *nonce, NSError *error) {
                           /* Check for errors and use the `nonce` here. */
                       }];

changelog here

或者,如果您不想升级,可以将代码更改为this

{{1}}