我之前在开发模式下尝试对实时卡/客户收费时遇到过这个问题。我以前从未使用条纹进行过 ACH 收费,而且我肯定处于开发模式。 https://stripe.com/docs/ach#integrating-plaid
js
var linkHandler = Plaid.create({
env: 'tartan',
clientName: 'Stripe / Plaid Test',
key: '[Plaid key]',
product: 'auth',
selectAccount: true,
onSuccess: function(public_token, metadata) {
// Token & Account ID - I use this for subsequent cURL requuest
console.log('public_token: ' + public_token);
console.log('account ID: ' + metadata.account_id);
},
});
// Trigger the Link UI
document.getElementById('linkButton').onclick = function() {
linkHandler.open();
};
响应有效。我使用上面的 public_token 和帐户 ID:
$data = array(
'client_id' => 'MY_CLIENT_ID',
'secret' => 'MY_SECRET',
'public_token' => 'MY_PUBLIC_TOKEN_FROM_ABOVE',
'account_id' => 'MY_ACCOUNT_ID_FROM_ABOVE'
);
$string = http_build_query($data);
//initialize session
$ch=curl_init("https://tartan.plaid.com/exchange_token");
//set options
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
//execute session
$keys = curl_exec($ch);
$keys = json_decode($keys);
//close session
curl_close($ch);
这也会产生一个有效的响应对象:
{
access_token: 'MY_ACCESS_TOKEN',
account_id: 'MY_ACCOUNT_ID',
stripe_bank_account_token: 'MY_STRIPE_BANK_ACCOUNT'
}
我想这就是我混淆的地方。文档说: 响应将包含经过验证的 Stripe 银行帐户令牌 ID。您可以将此令牌附加到 Stripe Customer 对象,或直接在其上创建费用。
但是,当我像这样在银行帐户令牌上创建费用时:
\Stripe\Stripe::setApiKey("sk_test_MY_TEST_KEY");
$charge = \Stripe\Charge::create(array(
"amount" => 2100,
"currency" => "usd",
"source" => $keys->stripe_bank_account_token, //(btok_MY_TOKEN_FROM_ABOVE)
"description" => "my description"
));
var_dump( $charge );
我得到的错误是:致命错误:未捕获的异常'Stripe\Error\InvalidRequest',消息'没有这样的令牌:btoken_MY_BANK_TOKEN; 类似的对象存在于实时模式中,但使用了测试模式密钥来发出此请求。