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 (将#修改为@)