让我解释一下添加帐户以使用条带接收付款的步骤。
有两种方法可以验证您的帐户
这里我说明第二种解决方案
第一步
我们要做的第一件事是收集用户帐户详细信息以创建需要发送到我们的服务器的条带令牌。
设置令牌元数据
Map<String, Object> tokenParams = new HashMap<String, Object>();
Map<String, Object> bank_accountParams = new HashMap<String, Object>();
bank_accountParams.put("country", "US");
bank_accountParams.put("currency", "usd");
bank_accountParams.put("account_holder_name", "name");
bank_accountParams.put("account_holder_type", "individual");
bank_accountParams.put("routing_number", "number");
bank_accountParams.put("account_number", "a/c no");
tokenParams.put("bank_account", bank_accountParams);
创建令牌
Token token = null;
try {
token = Token.create(params[0]);
} catch (AuthenticationException e) {
error = e.getMessage();
e.printStackTrace();
}
将令牌ID发送到服务器以供以后验证
token.getId()
第 2 步
收到代表令牌作为回报。完成后,将其附加到您帐户中的 Stripe 客户
// Set your secret key: remember to change this to your live secret key in production
// See your keys here: https://dashboard.stripe.com/account/apikeys
Stripe.apiKey = "sk_test_BQokikJOvBiI2HlWgH4olfQ2";
// Get the bank token submitted by the form
String tokenID = request.getParameter("stripeToken");
// Create a Customer
Map<String, Object> customerParams = new HashMap<String, Object>();
customerParams.put("source", tokenID);
customerParams.put("description", "Example customer");
Customer customer = Customer.create(customerParams);
将银行账户添加到客户后,需要进行验证。当使用 Stripe without Plaid 时,验证是通过将两笔小额存款存入 Stripe 将自动发送的银行账户来完成的。这些存款将需要 1-2 个工作日才能出现在客户的在线对帐单上。这些存款的声明描述将是VERIFICATION。您的客户需要将这两笔存款的价值转达给您。
在接受这些值时,请务必注意最多 10 次失败的验证尝试。一旦超过此限制,将无法验证银行帐户。关于这些小额存款是什么以及如何使用它们的详细信息可以帮助您的最终客户避免这个问题。获得这些值后,您可以验证银行帐户:
// Set your secret key: remember to change this to your live secret key in production
// See your keys here: https://dashboard.stripe.com/account/apikeys
Stripe.apiKey = "sk_test_BQokikJOvBiI2HlWgH4olfQ2";
// get the existing bank account
Customer customer = Customer.retrieve("cus_7iLOlPKxhQJ75a");
ExternalAccount source = customer.getSources().retrieve("ba_17SHwa2eZvKYlo2CUx7nphbZ");
// verify the account
Map params = new HashMap<String, Object>();
ArrayList amounts = new ArrayList();
amounts.add(32);
amounts.add(45);
params.put("amounts", amounts);
source.verify(params);
验证银行帐户后,您可以对其进行收费。
参考