ios - Braintree iOS 无法标记卡

标签 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

我真的很困惑,为什么我的项目工作区中没有这个类以及其他几个类。

最佳答案

根据您的 Podfile.lock,您似乎已经引入了旧版本的 Braintree iOS (3.3.1)。在这个版本中,-[Braintree tokenizeCard…] 有一个 slightly different signature来自您使用的那个,它基于 [Braintree 的在线文档][2]。

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

$ cd /path/to/your/project
$ pod update Braintree

有一个changelog here .

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

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

关于ios - Braintree iOS 无法标记卡,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26659310/

相关文章:

ios - Xcode 10 iOS firebase firestore SDK——多个命令在 Firebase 中产生 gRPCCertificates.bundle 错误

ios - TwitterKit 解析错误。预期 ')' 和预期类型

javascript - 坚持将 Braintree 与 Meteor.js 集成

paypal - Braintree - 支付方式改变时的回调

ruby-on-rails - Braintree IOS + rails 错误 91564 不能多次使用 payment_method_nonce

ios - 从底部到顶部动画 UIView 高度

ios - 如何使用 Swift 中的 UnsafeMutablePointer<UnsafeMutablePointer<Void>> 引用?

javascript - YouTube iframe Embed 无法控制 iPad 上的音频

ios - 如何弹出回到不同导航 Controller 中的 View ?

ios - 如何正确使用 CocoaPods