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)
@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:
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.
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?BTCardobject which then has itsnumber,expirationMonthandexpirationYearproperties set based on the ‘UI State’. ThetokenizeCardfunction is then called, passing in thisBTCardobject. 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) thetokenizeCardfunction is called at some stage during the Drop-In flow anyway. Is this correct?paymentDriverfunctions 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?verifyCardfunction being called. Again, this does not seem relevant if using the Drop-In since it is called at some stage during the flow ifrequest.threeDSecureVerification = truewas set and used to initialise theBTDropInController. 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).
So, the card object here
BTThreeDSecureCardNonceis a subclass ofBTCardNoncewhich in turn is a subclass ofBTPaymentMethodNonce. The 2BOOLs,liabilityShiftedandliabilityShiftPossibleare properties of theBTThreeDSecureCardNonceobject. However, by the time:is called this
BTThreeDSecureCardNoncehas been cast all the way up to its parent parent typeBTPaymentMethodNonce. This is then returned in the completion to where we (the developer) first initialised ourBTDropInControllerin the completion block(controller, result, error)- specifically, it is accessible throughresult.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 theBTPaymentMethodNonceobject, we don’t have access to the 2liabilityShift...checkBOOLs meaning it’s not possible for us to do the check.It seems at this stage, I guess we could potentially try casting the
BTPaymentMethodNonceobject back down to aBTThreeDSecureCardNonce, and if it works, we can access thoseBOOLs and proceed knowing 3DS has been shown. Or, if the cast fails, then it never was aBTThreeDSecureCardNoncein 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 theBTThreeDSecureCardNonceobject 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?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
verifyCardfunction returns theBTThreeDSecureCardNoncecard object which has theliabilityShift...checkBOOLproperties). So you seem to contradict the documentation and indeed the actual SDK flow here. Could you clarify?I’m not sure what you mean by ‘run the threeDSecureVerification on a nonce’. From what I can see, the only place anything called
threeDSecureVerificationexists within the SDK is as a property of the initialBTDropInRequestobject used to initialise theBTDropInController, which we set totrueorfalsesimply to tell the Drop-In whether to do 3DS checks. What do you mean here by ‘run the threeDSecureVerification’?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
verifyCardfunction 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?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! 👍