Credit Cards
Client-Side Implementation
Get the SDK
CocoaPods
Include Braintree in your podfile:
- Ruby
pod 'Braintree'
Swift Package Manager
Include the BraintreeCard framework.
Carthage
Include the BraintreeCore and BraintreeCard framework.
Initialization
To use our card payment processing with your own UI, instantiate a BTCardClient and tokenize the card details.
- Swift
// For client authorization,
// get your tokenization key from the Control Panel
// or fetch a client token
let braintreeClient = BTAPIClient(authorization: "<#CLIENT_AUTHORIZATION#>")!
let cardClient = BTCardClient(apiClient: braintreeClient)
let card = BTCard()
card.number = "4111111111111111"
card.expirationMonth = "12"
card.expirationYear = "2025"
cardClient.tokenizeCard(card) { (tokenizedCard, error) in
// Communicate the tokenizedCard.nonce to your server, or handle error
}
In the completion block, send the resulting nonce to your server for use.
Next Page: Server-side →