Braintree dropin ui:如何查找已保存的卡片中的哪一张用于订单

问题描述

实施 Braintree 支付网关。

让我们假设一个场景,当注册用户第一次下订单时,我们已经使用 API 创建了一个客户。每次他们使用不同的卡时,我们都会将其与他们的客户 ID 一起保存到保险库中。现在如果他们保存了多张卡片,系统如何在下订单时知道选择了哪一张?

从 ui 中,我们确实从有效载荷中取回了随机数,但没有从令牌中取回。

这是必需的,以便我们可以使用正确的令牌收取付款。

// Approach 1: get the default payment method token
paymentMethodToken = customer.getDefaultPaymentMethod().getToken();
// doesn't work for the purpose because we are just using the default method irrespective of the method selected.
    
// Approach 2: create a payment method using nonce and get the token
PaymentMethodRequest pmRequest = new PaymentMethodRequest().customerId(checkoutData.getBraintreeCustomerId()).paymentMethodNonce(nonce);
Result<? extends PaymentMethod> pmResult = gateway.paymentMethod().create(pmRequest);
PaymentMethod pm = pmResult.getTarget();
paymentMethodToken = pm.getToken();
// approach 2 ends

方法 2 感觉比 1 稍微好一点,因为 1 只是每次都使用方法,但必须有一个正确的方法获取令牌。有没有办法使用这个随机数来找出它将映射到哪个令牌?或者,如果它是一张全新卡片的随机数,只需将卡片保存在保险库中并返回令牌即可。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...