3D Secure
Client-Side Implementation
Generate a client token
Before you can initialize , you will need to set up the SDK and initialize it with a client token generated on your server.
Specify a merchant account
If you would like to use a merchant account ID other than your default, specify the merchant_account_id
when generating the client token.
Using 3DS
Drop-in UI
Custom UI
The following instructions assume your app has already integrated Credit Card payments.
CocoaPods
Carthage
Add github "braintree/braintree_ios"
to your Cartfile
, and add the frameworks to your project.
You must include all of the following frameworks via Carthage:
Implementation
-
If the user successfully completes the 3D Secure process, the
startPaymentFlow
callback block will receive aBTThreeDSecureResult
with atokenizedCard
property. You should transmit thetokenizedCard.nonce
to your server and create a transaction. -
If the user cancels the 3D Secure authentication, the completion block will be called with an
error
wherecode
is . -
If the 3D Secure process fails, the completion block will be called with an
error
.
In order to perform 3D Secure authentication again, a new nonce needs to be supplied.
For each request to verify a card, the completion block will be called exactly once.
Verify a vaulted credit card
First, on the server, generate and return a payment method nonce for the vaulted credit card.
Then on the client, you can use the startPaymentFlow:completion:
method just as before and pass it the newly-generated nonce.
Validation errors
Braintree will evaluate any fields passed against Cardinal's documentation. You will receive a validation error from Braintree if a field is incorrect.
Advanced client-side options
We expose additional information about the authentication request that you can use for more advanced UI flows or risk assessment. You should be aware that making such assessments may result in accepting the liability for fraudulent transactions.
These parameters pass through the client-side first and should not be trusted for your server-side risk assessment. They should be used for UI flow only.
- Swift
// In this example, 'card' is a 'BTCardNonce'.
if (card.threeDSecureInfo.liabilityShiftPossible) {
if (card.threeDSecureInfo.liabilityShifted) {
// 3D Secure authentication success
} else {
// 3D Secure authentication failed
}
} else {
// 3D Secure authentication was not possible
}
liabilityShifted
indicates that 3D Secure worked and authentication succeeded. This will also be true if the issuing bank does not support 3D Secure, but the payment method does. In both cases, the liability for fraud has been shifted to the bank. You should go on creating a transaction using the new nonce.liabilityShiftPossible
indicates that the payment method was eligible for 3D Secure. IfliabilityShifted
isfalse
, then the user failed 3D Secure authentication. In this situation, the card brands recommend asking the user for another form of payment. However, if you have server-side risk assessment processes that allow for it, you can still use the new nonce to create a transaction. If you want to use a nonce that did not pass 3D Secure authentication, you need to set therequired
option tofalse
in your server integration.- If both of the above values are
false
then this card was ineligible for 3D Secure. You can continue to create the transaction with the new nonce. However, liability shift will not apply to this transaction. This case may be useful if you would like to ask the user for additional verification (AVS, etc).
Using 3D Secure with a CVV-only nonce
If you want to use a CVV-only nonce when creating a transaction with 3D Secure, you will need to pass a 3D Secure Authentication ID together with a CVV-only nonce when creating a transaction, creating a payment method, or creating a customer with a payment method
Using 3D Secure Data-Only
To use use the 3D Secure data-only protocol for a given cardbrand, add the dataOnlyRequested
boolean, and check for the resulting status in the onLookupComplete()
callback:
- Swift
let threeDSecureRequest = BTThreeDSecureRequest()
threeDSecureRequest.amount = 10.00
threeDSecureRequest.nonce = tokenizedCard.nonce
threeDSecureRequest.email = "test@email.com"
threeDSecureRequest.dataOnlyRequested = true
Using accountType for combo cards in Brazil
When processing Brazilian cards domestically, customers with combo cards should be given the opportunity to select the account type of their card. To do this, generate a UI for this selection and reflect that choice in the 3D Secure call, as well as the corresponding transaction, payment method or customer API call.
- Swift
let threeDSecureRequest = BTThreeDSecureRequest()
threeDSecureRequest.amount = 10.00
threeDSecureRequest.nonce = tokenizedCard.nonce
threeDSecureRequest.email = "test@email.com"
threeDSecureRequest.accountType = .credit
Next Page: Server-side →