Closed dminkovsky closed 4 years ago
👋
You can simply call requestPaymentMethod
after you've determined that is requestable.
braintree.dropin.create({
authorization: 'CLIENT_TOKEN_ENCODED_WITH_CUSTOMER_ID',
container: '#dropin-container'
}).then(function (dropinInstance) {
if (dropinInstance.isPaymentMethodRequestable()) {
// This will be true if you generated the client token
// with a customer ID and there is a saved payment method
// available to tokenize with that customer.
dropinInstance.requestPaymentMethod().then(function (payload) {
// inspect type of payment method: payload.type
});
}
// finish setting up drop-in
});
That's a good approach, thanks.
General information
Issue description
Upon initializing the drop in with
authorization
set to a client token generated using a customer ID for a customer with vaulted payment methods, the drop in displays the existing payment methods. In this situation,paymentMethodRequestable
is not fired, andisPaymentMethodRequestable()
needs to be called to detect whetherrequestPaymentMethod()
can be called.However, unlike the
paymentMethodRequestable
event, which provides handlers with thePaymentMethod
("CreditCard" | "PayPal"),isPaymentMethodRequestable()
just returns a boolean with no payment method type.Is there a way to find out what the payment type is when using
isPaymentMethodRequestable()
on initialization, so that the interface between these two ways is consistent?My use case is that I am displaying a submit button that says "Use this card" or "Use this PayPal account" depending on payment method, and cannot make this distinction when a vaulted payment method exists upon initialization.