braintree-web-drop-in icon indicating copy to clipboard operation
braintree-web-drop-in copied to clipboard

changeActiveView event doesn't fire for “Choose another way to pay” when credit card is selected

Open ae-michal-mordarski opened this issue 3 years ago • 5 comments

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”.

  1. Enter credit cards details.
  2. requestPaymentMethod (credit card becomes selected)
  3. 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 avatar Feb 17 '22 21:02 ae-michal-mordarski

@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 avatar Feb 18 '22 22:02 jplukarski

@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

ae-michal-mordarski avatar Feb 18 '22 22:02 ae-michal-mordarski

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 avatar Feb 18 '22 22:02 jplukarski

@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?

ae-michal-mordarski avatar Feb 18 '22 23:02 ae-michal-mordarski

@jplukarski would you have time to review this once again?

ae-michal-mordarski avatar Mar 21 '22 18:03 ae-michal-mordarski

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.

Screen Shot 2022-11-15 at 1 25 30 PM

armandodlvr avatar Nov 15 '22 18:11 armandodlvr

closing due to inactivity. Feel free to open a new issue if you encounter similar problems on the latest version of the library

hollabaq86 avatar Apr 05 '23 18:04 hollabaq86