【发布时间】:2017-12-20 15:06:51
【问题描述】:
我正在尝试使用 Stripe 验证银行帐户。 Stripe 文档中最接近的语言是 Node.js,所以我的代码有点不同,但问题是从 stripe.js 创建的条带对象上没有“客户”对象。
他们的代码(https://stripe.com/docs/ach#manually-collecting-and-verifying-bank-accounts):
// 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
var stripe = require("stripe")("my_secret_key");
var data = {amounts: [32,45]}
stripe.customers.verifySource(
'customer_id',
'bank_account_id',
{
amounts: [32, 45]
},
function(err, bankAccount) {
});
我的代码:
<script src="https://js.stripe.com/v3/"></script>
<script>
$('input').on('keydown', function (e) {
if (e.which == 13) {
$('#VerificationAmounts').submit();
}
});
$('#VerificationAmounts').submit(function (e) {
e.preventDefault();
var stripe = Stripe("@publishKey");
var data = { amounts: [$('#Amount1').val(), $('#Amount2').val()] }
debugger;
stripe.customers.verifySource(
'@customerId',
'@bankAccount.Id',
data,
function (err, bankAccount) {
});
});
</script>
错误:
Uncaught TypeError: Cannot read property 'verifySource' of undefined
有谁知道让“客户”对象填充到条带对象上的方法?
【问题讨论】:
-
您正在尝试使用客户端库执行服务器端操作,它不起作用。
-
感谢您为我指明正确的方向@Alex!
标签: javascript jquery model-view-controller stripe-payments