Client SDK

Migration

Migrating from v5 to v6AnchorIcon

While iOS v6 is a major version bump and contains breaking changes, we kept these changes to a minimum where possible.

Why upgrade to v6?AnchorIcon

  • The SDK has been fully rewritten in Swift to take advantage of language features and type safety
  • Streamlined method names to make adding additional payment methods seamless and reduce integration time
  • Updates for the latest versions of iOS and Xcode

You can find a complete list of changes in iOS v6 in our CHANGELOG.

Minimum requirementsAnchorIcon

The Braintree iOS v6 SDK requires Xcode 14.3+, Swift 5.8+ and a minimum deployment target of iOS 14.0.

If your application contains Objective-C code, the Enable Modules build setting must be set to YES.

InstallationAnchorIcon

iOS v6 supports installation via Swift Package Manager, CocoaPods and Carthage.

The Installation section of the README has more information.

CarthageAnchorIcon

iOS v6 requires Carthage v0.38.0+, which adds support for xcframework binary dependencies.

To update to v6 using carthage you are required to use:
  1. Bash
carthage update --use-xcframeworks

Required code changesAnchorIcon

VenmoAnchorIcon

BTVenmoDriver has been renamed to BTVenmoClient to ensure consistency between feature clients.

BTVenmoRequest must now be initialized with a paymentMethodUsage.

The possible values for BTVenmoPaymentMethodUsage include:

.multiUse - the Venmo payment will be authorized for future payments and can be vaulted. .singleUse - the Venmo payment will be authorized for a one-time payment and cannot be vaulted.

BTVenmoClient.tokenizeVenmoAccount(with:completion:) has been renamed to BTVenmoClient.tokenize(_:completion:)

BTVenmoClient.isiOSAppAvailableForAppSwitch() has been renamed to BTVenmoClient.isVenmoAppInstalled()

An example of a Venmo integration in v6 will look like the following:
  1. Swift
let apiClient = BTAPIClient("<TOKENIZATION_KEY_OR_CLIENT_TOKEN>")
let venmoClient = BTVenmoClient(apiClient: apiClient)
let venmoRequest = BTVenmoRequest(paymentMethodUsage: .multiUse)
venmoRequest.profileID = "my-profile-id"
venmoRequest.vault = true

venmoClient.tokenize(venmoRequest) { venmoAccountNonce, error in
    guard let venmoAccountNonce else {
        // handle error
    }
    // send nonce to server
}

PayPalAnchorIcon

BTPayPalDriver has been renamed to BTPayPalClient to ensure consistency between feature clients.

Removed BTPayPalDriver.requestOneTimePayment and BTPayPalDriver.requestBillingAgreement in favor of BTPayPalClient.tokenize:
  1. Swift
let apiClient = BTAPIClient("<TOKENIZATION_KEY_OR_CLIENT_TOKEN>")
let payPalClient = BTPayPalClient(apiClient: apiClient)
let request = BTPayPalCheckoutRequest(amount: "1")

payPalClient.tokenize(request) { payPalAccountNonce, error in
    guard let payPalAccountNonce else {
        // handle error
    }
    // send nonce to server
}

BTPayPalClient.tokenizePayPalAccount(with:completion:) has been replaced with two methods called: BTPayPalClient.tokenize(_:completion:) each taking in either a BTPayPalCheckoutRequest or BTPayPalVaultRequest

An example of a PayPal integration in v6 will look like the following:
  1. Swift
// BTPayPalCheckoutRequest
let apiClient = BTAPIClient("<TOKENIZATION_KEY_OR_CLIENT_TOKEN>")
let payPalClient = BTPayPalClient(apiClient: apiClient)
let request = BTPayPalCheckoutRequest(amount: "1")

payPalClient.tokenize(request) { payPalAccountNonce, error in 
    guard let payPalAccountNonce else {
        // handle error
    }
    // send nonce to server
}

// BTPayPalVaultRequest
let apiClient = BTAPIClient("<TOKENIZATION_KEY_OR_CLIENT_TOKEN>")
let payPalClient = BTPayPalClient(apiClient: apiClient)
let request = BTPayPalVaultRequest()

payPalClient.tokenize(request) { payPalAccountNonce, error in 
    guard let payPalAccountNonce else {
        // handle error
    }
    // send nonce to server
}

PayPal Native CheckoutAnchorIcon

BTPayPalNativeCheckoutClient.tokenizePayPalAccount(with:completion:) has been replaced with two methods called: BTPayPalNativeCheckoutClient.tokenize(_:completion:) each taking in either a BTPayPalNativeCheckoutRequest or BTPayPalNativeVaultRequest

An example of a PayPal Native Checkout integration in v6 will look like the following:
  1. Swift
// BTPayPalNativeCheckoutRequest
let apiClient = BTAPIClient("<TOKENIZATION_KEY_OR_CLIENT_TOKEN>")
let payPalNativeCheckoutClient = BTPayPalNativeCheckoutClient(apiClient: apiClient)
let request = BTPayPalNativeCheckoutRequest(amount: "1")

payPalNativeCheckoutClient.tokenize(request) { payPalNativeCheckoutAccountNonce, error in 
    guard let payPalNativeCheckoutAccountNonce else {
        // handle error
    }
    // send nonce to server
}

// BTPayPalNativeVaultRequest
let apiClient = BTAPIClient("<TOKENIZATION_KEY_OR_CLIENT_TOKEN>")
let payPalNativeCheckoutClient = BTPayPalNativeCheckoutClient(apiClient: apiClient)
let request = BTPayPalNativeVaultRequest()

payPalNativeCheckoutClient.tokenize(request) { payPalNativeCheckoutAccountNonce, error in 
    guard let payPalNativeCheckoutAccountNonce else {
        // handle error
    }
    // send nonce to server
}

Data CollectorAnchorIcon

Note: Kount is no longer supported via the Braintree iOS SDK.

The PayPalDataCollector module and all containing classes has been removed in favor of a single Data collector module called BraintreeDataCollector. This module should be used for all data collection.

The new integration pattern for collecting device data will look like the following:
  1. Swift
let apiClient = BTAPIClient("<TOKENIZATION_KEY_OR_CLIENT_TOKEN>")
let dataCollector = BTDataCollector(apiClient: apiClient)

dataCollector.collectDeviceData { deviceData, error in
    guard let deviceData else {
        // handle error
    }
    // send deviceData to server
}

Union PayAnchorIcon

The BraintreeUnionPay module, and all containing classes, was removed in v6. UnionPay cards can now be processed as regular cards, through the BraintreeCard module. You no longer need to manage card enrollment via SMS authorization.

To tokenize UnionPay cards in v6 the integration pattern will look like the following:
  1. Swift
let apiClient = BTAPIClient("<TOKENIZATION_KEY_OR_CLIENT_TOKEN>")
let cardClient = BTCardClient(apiClient: apiClient)

let card = BTCard()
card.number = "6243030000000001"
card.expirationMonth = "12"
card.expirationYear = "2025"

cardClient.tokenize(card) { tokenizedCard, error in
    guard let tokenizedCard else {
        // handle error
    }
    // send nonce to server
}

SEPA Direct DebitAnchorIcon

We have removed the context parameter from the BTSEPADirectDebit.tokenize() method.

Additionally, conformance to the ASWebAuthenticationPresentationContextProviding protocol is no longer needed.

BTSEPADirectDebitClient.tokenize(request:context:completion:) has been renamed to BTSEPADirectDebitClient.tokenize(_:completion:)

An example of a SEPA Direct Debit integration in v6 will look like the following:
  1. Swift
let apiClient = BTAPIClient("<TOKENIZATION_KEY_OR_CLIENT_TOKEN>")
let sepaDirectDebitClient = BTSEPADirectDebitClient(apiClient: apiClient)

sepaDirectDebitClient.tokenize(sepaDirectDebitRequest) { sepaDirectDebitNonce, error in
    guard let sepaDirectDebitNonce else {
        // handle error
    }
    // send nonce to server
}

Local PaymentsAnchorIcon

We have renamed the module BraintreePaymentFlow to BraintreeLocalPayment.

We have additionally replaced SFAuthenticationSession with ASWebAuthenticationSession in the Local Payment Method flow. With this change, you no longer need to:

  • Register a URL Scheme or set a return URL via the BTAppContextSwitcher.setReturnURLScheme() method
  • Handle app context switching via the BTAppContextSwitcher.handleOpenURL(context:) or BTAppContextSwitcher.handleOpenURL() method
  • Setting a viewControllerPresentingDelegate is no longer required

Instantiate a BTLocalPaymentClient instead of a BTPaymentFlowDriver. The result returned from the startPaymentFlow() completion no longer needs to be cast to BTLocalPaymentResult.

An example of a Local Payments integration in v6 will look like the following:
  1. Swift
let apiClient = BTAPIClient("<TOKENIZATION_KEY_OR_CLIENT_TOKEN>")
let localPaymentClient = BTLocalPaymentClient(apiClient: self.apiClient)

localPaymentClient.startPaymentFlow(localPaymentRequest) { localPaymentResult, error in
    // Handle result
}

3D SecureAnchorIcon

Instantiate a BTThreeDSecureClient instead of a BTPaymentFlowDriver. The result returned in the startPaymentFlow() completion no longer needs to be cast to BTThreeDSecureResult.

Setting a viewControllerPresentingDelegate is no longer required.

The BTViewControllerPresentingDelegate has been removed, as 3D Secure version 1 is no longer supported. All 3D Secure flows will go through 3D Secure version 2.

An example of a 3D Secure integration in v6 will look like the following:
  1. Swift
let apiClient = BTAPIClient("<TOKENIZATION_KEY_OR_CLIENT_TOKEN>")
let threeDSecureClient = BTThreeDSecureClient(apiClient: self.apiClient)

threeDSecureClient.startPaymentFlow(threeDSecureRequest) { threeDSecureResult, error in
    // Handle result
}

See also

    If you accept cookies, we’ll use them to improve and customize your experience and enable our partners to show you personalized PayPal ads when you visit other sites. Manage cookies and learn more