braintree-ios-drop-in: 3DSecure will not show when using drop-in (and possible solution)

Currently 3D Secure does not seem to show when using the iOS drop-in.

The documentation advises that only the following is required to make it work:

let request =  BTDropInRequest()
request.threeDSecureVerification = true
request.amount = "1.00"

Setting request.threeDSecureVerification = true does cause the 3D checks to be started when tapping ‘Add Card’ in the drop-in UI, however, the loading indicator spins and then nothing happens.

Looking at the SDK code, it appears that in BTThreeDSecureDriver.m within the actual Braintree Core library, the following function is called at line 94:

[self informDelegateRequestsPresentationOfViewController:navigationController];

The function that is called (and its sibling dismiss function) both use respondsToSelector checks to make sure that the delegate does actually implement the required paymentDriver functions that are used to show the 3DS dialogue:

#pragma mark Delegate informer helpers

- (void)informDelegateRequestsPresentationOfViewController:(UIViewController *)viewController {
    if ([self.delegate respondsToSelector:@selector(paymentDriver:requestsPresentationOfViewController:)]) {
        [self.delegate paymentDriver:self requestsPresentationOfViewController:viewController];
    }
}

- (void)informDelegateRequestsDismissalOfViewController:(UIViewController *)viewController {
    if ([self.delegate respondsToSelector:@selector(paymentDriver:requestsDismissalOfViewController:)]) {
        [self.delegate paymentDriver:self requestsDismissalOfViewController:viewController];
    }
}

At this stage when using the drop-in UI, the delegate in question is an instance of BTCardFormViewController.m (since this is currently showing the ‘Add Card’ dialogue to the user). This class does not implement those functions and so the check fails and 3DS is never shown.

It seems to me that this should implement these functions or 3DS is never going to work in the drop-in. I have submitted a pull request the changes that I believe should fix it.

Please take a look and get back to me. Cheers! 👍

About this issue

  • Original URL
  • State: closed
  • Created 10 years ago
  • Comments: 23 (16 by maintainers)

Most upvoted comments

@sdcoffey @demerino Ok cheers guys, got a boat load of questions for you here as it’s all getting confusing hah. Apologies about the length of this!

What seems very unclear to me still is if using the drop-in, what parts of this document are relevant. At the start of the doc, it says:

You can structure your native checkout flow however you’d like. If you don’t already have a credit card form, consider our Drop-in UI.

This statement seems to imply that the rest of the page is not relevant if you use the drop-in. So maybe you could re-word the doc here to make it more clear.

Following that, it shows the code examples under the following titles Render a checkout page, Verify a credit card and Advanced client-side options.

  1. So, starting with Render a checkout page, the code in here initialises a BTThreeDSecureDriver. Since an instance of this class is initialised at some stage by the Drop-In, this section of the documentation does not seem relevant if using the Drop-In. Is this correct?
  2. Verify a credit card - so the first code example in this section initialises a BTCard object which then has its number, expirationMonth and expirationYear properties set based on the ‘UI State’. The tokenizeCard function is then called, passing in this BTCard object. This all again seems to not be relevant if using the drop in because (a) we don’t have access to the UI state/card information being entered as the Drop-In is handling it, and (b) the tokenizeCard function is called at some stage during the Drop-In flow anyway. Is this correct?
  3. The next code block has the 2 paymentDriver functions which were implemented in my pull request yesterday. So these again do not seem relevant as the Drop-In is now presenting the 3D Secure dialogue (BTThreeDSecureAuthenticationViewController) over the ‘Add Card’ view controller (BTCardFormViewController) rather than the developer doing it manually. Correct?
  4. The next code example shows the verifyCard function being called. Again, this does not seem relevant if using the Drop-In since it is called at some stage during the flow if request.threeDSecureVerification = true was set and used to initialise the BTDropInController. Is this correct?

Now the following section - Advanced client-side options - does seem necessary whether using the Drop-In or not based on your comments above (but I’m not sure it is possible).

  1. The code example shows the following:
// In this example, `card` is a `BTThreeDSecureCardNonce`.
if card.liabilityShiftPossible && card.liabilityShifted {
    print("liability shift possible and liability shifted")
} else {
    print("3D Secure authentication was attempted but liability shift is not possible")
}

So, the card object here BTThreeDSecureCardNonce is a subclass of BTCardNonce which in turn is a subclass of BTPaymentMethodNonce. The 2 BOOLs, liabilityShifted and liabilityShiftPossible are properties of the BTThreeDSecureCardNonce object. However, by the time:

BTDropInController.m - line 268

- (void)cardTokenizationCompleted:(BTPaymentMethodNonce *)tokenizedCard error:(NSError *)error sender:(BTCardFormViewController *)sender {

is called this BTThreeDSecureCardNonce has been cast all the way up to its parent parent type BTPaymentMethodNonce. This is then returned in the completion to where we (the developer) first initialised our BTDropInController in the completion block (controller, result, error) - specifically, it is accessible through result.paymentMethod. This is the first time we (the developer) have access to any information since initialising the Drop-In - and since we can only see the BTPaymentMethodNonce object, we don’t have access to the 2 liabilityShift... check BOOLs meaning it’s not possible for us to do the check.

It seems at this stage, I guess we could potentially try casting the BTPaymentMethodNonce object back down to a BTThreeDSecureCardNonce, and if it works, we can access those BOOLs and proceed knowing 3DS has been shown. Or, if the cast fails, then it never was a BTThreeDSecureCardNonce in the first place, so we know 3DS didn’t show. However, this feels like a bit of a workaround and seems as though it would make more sense for the SDK to be modified so that we (the developer) can somehow access the BTThreeDSecureCardNonce object without any casting if 3DS was carried out. So, as it stands, it would appear it’s not easily possible to do the liability shift checks, would you agree? And any further thoughts?

  1. @sdcoffey, you say above:

However, if you have 3DS enabled, you always need to check if a liability shift is possible, and if so, walk the user through the 3DS verification a before you can transact with that nonce. I realise our docs might be a little unclear on this, but here’s how you can check for a liability shift, and use BTThreeDSecureDriver to perform additional verifications.

So, apologies if I’m not understanding you correctly here, but you seem to say that we first check if a liability shift is possible, and if so, we then display the 3DS dialogue to the customer. However, based on how the SDK seems to work, we only know this information after the 3DS dialogue has been shown (the completion of the verifyCard function returns the BTThreeDSecureCardNonce card object which has the liabilityShift... check BOOL properties). So you seem to contradict the documentation and indeed the actual SDK flow here. Could you clarify?

  1. @demerino, you say above:

Adding to what @sdcoffey said - you always need to run the threeDSecureVerification on a nonce from Drop-in and check the result to see if further verification is necessary.

I’m not sure what you mean by ‘run the threeDSecureVerification on a nonce’. From what I can see, the only place anything called threeDSecureVerification exists within the SDK is as a property of the initial BTDropInRequest object used to initialise the BTDropInController, which we set to true or false simply to tell the Drop-In whether to do 3DS checks. What do you mean here by ‘run the threeDSecureVerification’?

  1. Ok, so this seems like a bit of a major flaw but maybe this is intentional. If the user selects a recent/saved card rather than adding a new card, 3DS is not shown at all. The verifyCard function is not even called. It seems to me that if 3DS is enabled, it should be for every transaction, regardless of whether the card is new or vaulted, especially since card vaulting is not necessarily unique to devices, and can be vaulted on one device and still shown on another. Thoughts?

  2. Following on from this, in my earlier comment I said I thought it was odd to vault the card before 3DS if it was enabled. First off, is it possible to disable the vaulting at the drop-in when using a client token? I’m assuming not? Does it not feel like odd behaviour to you if your card details were saved, yet you had clicked cancel at 3DS and abandoned the transaction? This behaviour actually appears to create a security hole when taking point 8 above into account. A user could start a transaction, get through to the 3DS dialogue, fail/cancel at this point, but then they are returned back to the start of the Drop-In where the vaulted card is now showing and is selectable. They can now select this as their payment method, and since 3DS checks are not performed on recent cards, their order will be processed successfully? Does this sound correct? Any thoughts?

Again, apologies for the absolute essay here but I’m just trying to be as clear as possible. Please let me know if you don’t follow anything. Cheers! 👍