如何让 Braintree v.zero 显示现有的支付方式?

How to get Braintree v.zero to show existing payment methods?

使用 Braintree v.zero SDK 设置付款表格:

braintree.setup(response.value, 'dropin', {
  container : 'xyz',
  onPaymentMethodReceived : function(payment) { 
    pay(payment.nonce);
  },
});

输入付款信息后,表格显示:

...但仅在重新加载页面之前。有没有办法初始化 dropin 付款表格以列出客户现有的付款方式?

完全披露:我在 Braintree 工作。如果您有任何其他问题,请随时联系 support.

关键似乎在于您的 response.value(即您的客户端令牌)。我猜你用来生成它的服务器代码没有为该用户指定 customerId。 的 来自 Braintree documentation on generating client tokens:

Your server is responsible for generating a client token, which contains all authorization and configuration information your client needs to initialize the client SDK to communicate with Braintree. Including a customerId when generating the client token lets returning customers select from previously used payment method options, improving user experience over multiple checkouts. Set Up Your Client covers the client side of the exchange.

底线:如果您使用与您的客户匹配的 customer_id 生成您的客户令牌,则 Drop-in 将显示多张卡片。

client_token = braintree.ClientToken.generate({
     "customer_id": a_customer_id
})