braintree-web-drop-in
braintree-web-drop-in copied to clipboard
changeActiveView event doesn't fire for “Choose another way to pay” when credit card is selected
General information
- SDK/Library version: 1.33.0
- Environment: Sandbox
- Browser and OS: Latest version of Chrome/Windows 10 Pro
Issue description
changeActiveView doesn't always work when clicking “Choose another way to pay”.
- Enter credit cards details.
- requestPaymentMethod (credit card becomes selected)
- Click “Choose another way to pay”
Expected result: changeActiveView event is triggered Actual result: changeActiveView event is not triggered
instance.on('changeActiveView', function (event) {
console.log('previousViewId: ' + event.previousViewId);
console.log('newViewId: ' + event.newViewId);
});
instance.on('paymentMethodRequestable', function (event) {
if (!event.paymentMethodIsSelected) {
instance.requestPaymentMethod(
{
threeDSecure: getThreeDSecure(),
},
function (err, payload) {
if (err) {
instance.clearSelectedPaymentMethod();
return;
}
console.log(payload);
},
);
}
});
@ae-michal-mordarski Thanks for writing in. We were able to get the changeActiveView
event to trigger using this code snippet you shared. Can you go into more detail about what your actual result is? Were you seeing any errors in the console? Do you have a test site we can use to examine the behavior you are seeing?
@jplukarski Do you see event being triggered when you click “Choose another way to pay” after adding credit card? It does work in other cases, but just not this one.
Please see attached video (around 35 second) and check console log does not output anything in that case. Once you try to use different payment method and then again click “Choose another way to pay” the event is triggered, but not after adding card for the first time.
https://user-images.githubusercontent.com/51924355/154769708-702b1fc2-5b91-40bf-a669-6ec1604666a9.mp4
Thanks for getting back to us so quickly @ae-michal-mordarski . We believe that what you are seeing is expected behavior. When a card is tokenized in requestPaymentMethod
the Drop-In returns to the methods
view, where the tokenized card and the Choose another way to pay
button is displayed. Clicking the Choose another way to pay
in this case doesn't change the view, it just redisplays the other payment options, but it is the same methods
view.
Can you elaborate on what you are trying to achieve by listening for a view change in this case?
@jplukarski isn't the card tokenized at later point? here we are just entering credit cards details.
As you can see on the video we have additional payment for Klarna, which we want to hide when one payment method is selected. With the case I mentioned when Choose another way to pay is clicked Card/PayPal options are shown again, but there is no event triggered so we are not showing Klarna option.
Are you saying showing Card/PayPal again doesn't really change view? How would you go about this limitation? Can you think of any solution?
@jplukarski would you have time to review this once again?
Hi @ae-michal-mordarski , Do you encounter the same problem when updating to the latest version (1.33.7) of the Drop-In UI? I just tested it and I think it works fine.
closing due to inactivity. Feel free to open a new issue if you encounter similar problems on the latest version of the library