如何解决Stripe - 使用 Plaid 公共令牌更新未经验证的银行帐户用于交换 Stripe BTOK
这里的用例是用户通过传统验证创建一个银行账户(Stripe 在创建的银行账户中存入两笔小额款项)。
然后用户决定等待通过传统验证来验证帐户将花费太长时间,然后通过使用 Plaid 的替代方法登录他们的银行并实时验证银行。
问题变成了我有一个未经验证的银行账户,从初始设置到传统方法,Stripe 客户上已经有相同的路由和银行账户信息。在尝试向 Stripe 客户添加新的银行账户(通过 Plaid 验证)时,我收到一个错误,该账户已存在于该账户中。
从 Plaid 交换公共令牌后,如何使用从 Stripe 收到的 BTOK“更新”现有帐户?
PlaidClient plaidClient = PlaidClient.newBuilder()
.clientIdAndSecret(plaidid,plaidsecret)
.sandBoxBaseUrl()
.logLevel(HttpLoggingInterceptor.Level.BODY)
.build();
Response<ItempublicTokenExchangeResponse> exchangeResponse = plaidClient.service().itempublicTokenExchange(new ItempublicTokenExchangeRequest(rapidpay.getRapidpaypublictoken())).execute();
//Check if the public_token sent to Plaid was successful in creating an access_token
if (exchangeResponse.isSuccessful()) {
String accesstoken = exchangeResponse.body().getAccesstoken();
Response<ItemStripetokenCreateResponse> stripeResponse =
plaidClient.service().itemStripetokenCreate(new
ItemStripetokenCreateRequest(accesstoken,rapidpay.getRapidpayaccountid())).execute();
//Check if the access_token sent to Stripe was successful in creating a bank_token (BTOK)
if (stripeResponse.isSuccessful()) {
ItemStripetokenCreateResponse bankAccountToken = stripeResponse.body();
//Retrieve the customer that will be updated with updated/new bank account
HashMap<String,Object> customerParams = new HashMap<>();
List<String> expandList = new ArrayList<>();
expandList.add("sources");
customerParams.put("expand",expandList);
Customer customer = Customer.retrieve(invitee.getPaymentcustomerid(),customerParams,null);
//Submit a new bank account
HashMap<String,Object> newbankparams = new HashMap<>();
newbankparams.put("source",bankAccountToken.getStripeBankAccountToken());
customer.getSources().create(newbankparams);
}
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。