I am trying to tokenize credit card with Braintree iOS. This is my code like in the 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){
}];
Unfortunately I don't find BTClientCardRequest class in the project, although it is there in Braintree API header directory.
And my Podfile looks like this:
# 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
My Podfile.lock looks like this:
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
I am really confused why I don't have this class as well as several other in my project workspace.
Based on your Podfile.lock
, it looks like you have pulled in an older version of Braintree iOS (3.3.1
). In this version, -[Braintree tokenizeCard…]
has a slightly different signature from the one that you have used, which is based on [Braintree's online documentation][2].
I would recommend upgrading to the latest version by running this command in Terminal:
$ cd /path/to/your/project
$ pod update Braintree
There is a changelog here.
Alternatively, if you do not want to upgrade, you can change your code to look like this:
[braintree tokenizeCardWithNumber:@"4111111111111111"
expirationMonth:@"12"
expirationYear:@"2020"
completion:^(NSString *nonce, NSError *error) {
/* Check for errors and use the `nonce` here. */
}];