braintree / braintree-web-drop-in

Braintree Drop-in for the web
MIT License
200 stars 126 forks source link

Callback when saved credit cards have been refreshed #540

Open pawelchmara opened 5 years ago

pawelchmara commented 5 years ago

General information

Issue description

When Drop-in is in management mode (vaultManager: true) and new card has been added or removed, there is no callback information that list of credit cards have been refreshed. Also function clearSelectedPaymentMethod() has no callback parameter.

gesa commented 5 years ago

Hey @pawelchmara, thanks for opening this issue and sorry for the delayed response. I plan to take a look at this today and I'll get back to you.

pawelchmara commented 5 years ago

Hey @gesa, maybe have you already looked at this problem?

gesa commented 5 years ago

I'm so sorry @pawelchmara, I totally flaked on you. Not cool of me.

So the paymentMethodRequestable and noPaymentMethodRequestable events fire any time a credit card is added (and, as a result, selected), removed (and, as a result, deselected), or programmatically deselected by calling clearSelectedPaymentMethod().

For your first concern, regarding changes made to the credit card list, I'm not entirely certain I understand what method's callback you'd expect to be firing in that scenario. Is there a reason the event handlers don't fulfill your needs?

On a similar note, what's the situation where clearSelectedPaymentMethod() would need to fire an asynchronous callback (or return a promise)?

I fired up a local server and played around with these behaviors to see if I was missing some obvious piece of functionality that wouldn't occur to me when looking at it from the braintree side but I got nothin.

pawelchmara commented 5 years ago

Maybe I will try explain what I need. Please look at the screen below:

Dropin

I use Drop In like a vault manager and would like to add possibility to customer to select default credit card. So I need clear information that new card has been added or removed to refresh select options.

When you remove credit card, paymentMethodRequestable event is fired. But also when you choose credit card, this event is also fired. So you don't know exactly, if credit card has been removed or existing card is selected. What's more, if you fill in the payment method form with the correct data, the same event will fire again. Ultimately, you can't recognize what really happened.

I need this information to refresh select options. Of course, I can refresh select options every time when paymentMethodRequestable event is fired, but this is not a good solution.

As for the clearSelectedPaymentMethod method, you are right, I do not need callback.

gesa commented 5 years ago

You bring up good points @pawelchmara! We're discussing the best way improve on this and will follow up on this issue.

pawelchmara commented 5 years ago

How about adding a new button "Set as default" in edit mode:

temp

I think it is very easy to do for you and this functionality will be useful for users.

crookedneighbor commented 5 years ago

@pawelchmara It's easy to add it to Drop-in, but we'd also need to update the API to allow authorizing that change from the client. In addition, there would need to be some design exploration to figure out the best UI for how it is presented.

Not impossible to do, and in my opinion, the right solution for what you describe that you need out of Drop-in, just want to note that it's not as simple as it looks at first glance.