我正在我的android项目上集成条带。我知道你可以使用这个为card生成stripetoken。
Card card = new Card("4242424242424242", "12", "2014", "123");
Stripe stripe = new Stripe("pk_test_6pRNASCoBOKtIshFeQd4XMUh");
stripe.createToken(
card,
new TokenCallback() {
public void onSuccess(Token token) {
// Send token to your server
}
public void onError(Exception error) {
// Show localized error message
Toast.makeText(getContext(),
error.getLocalizedString(getContext()),
Toast.LENGTH_LONG
).show();
}
}
)
我正在使用他们来自github的stripe-android库
那么如何为银行账户生成条带令牌?
我似乎无法在谷歌上找到任何关于此的例子。
谢谢!
没有办法让客户直接从银行帐户付款,因此没有API可以使用银行详细信息创建付款令牌。也许您正在考虑'Marketplaces'产品,让您通过银行详细信息为收款人设置并向他们转账(例如,支付收益)。
您可以使用此代码创建。
Stripe.apiKey = "sk_test_BQokikJOvBiI2HlWgH4olfQ2";
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", "Jane Austen");
bank_accountParams.put("account_holder_type", "individual");
bank_accountParams.put("routing_number", "11000000");
bank_accountParams.put("account_number", "000123456789");
tokenParams.put("bank_account", bank_accountParams);
try {
Token s = Token.create(tokenParams);
Log.d("Token",s.getId());
} catch (AuthenticationException e) {
//showAlertMessage("",e.getMessage());
} catch (CardException e) {
//showAlertMessage("",e.getMessage());
} catch (APIException e) {
//showAlertMessage("",e.getMessage());
} catch (InvalidRequestException e) {
//showAlertMessage("", e.getMessage());
} catch (APIConnectionException e) {
//showAlertMessage("",e.getMessage());
}
根据新文档,您需要在gradle构建中添加以下行:
compile 'com.stripe:stripe-android:4.0.1'
检查这个link的最新版本
然后使用以下代码段:
Stripe stripe = new Stripe(this);
stripe.setDefaultPublishableKey("your_publishable_key");
BankAccount bankAccount = new BankAccount("accountNumber","countryCode","currency","routingNumber");
stripe.createBankAccountToken(bankAccount, new TokenCallback() {
@Override
public void onError(Exception error) {
Log.e("Stripe Error",error.getMessage());
}
@Override
public void onSuccess(com.stripe.android.model.Token token) {
Log.e("Bank Token", token.getId());
}
});
这应该像魅力一样。
您只需使用ur stripe api key尝试下面的代码
Stripe stripe = new Stripe(this, "YOUR API KEY");
BankAccount bankAccount = new BankAccount("000123456789","US","usd","110000000");
stripe.createBankAccountToken(bankAccount, new TokenCallback() {
@Override
public void onError(Exception error) {
Log.e("Stripe Error",error.getMessage());
}
@Override
public void onSuccess(com.stripe.android.model.Token token) {
Log.e("Bank Token", token.getId());
}
});