2017-07-15 172 views
1

我正在尝试验证带有条纹的银行帐户。 Stripe文档中最接近的语言是Node.js,所以我的代码有点不同,但问题是从stripe.js创建的条带对象上没有“customers”对象。ACH条纹银行帐户验证

他们的代码(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 

有谁知道的方法,使 “客户” 对象来填充在条纹对象上?

+1

你正在尝试使用客户端库执行服务器端操作,它不会工作。 – Alex

+0

谢谢你指出我在正确的方向@亚历克斯! – SupposedlySam

回答

0

Per @ Alex的评论,我试图用stripe.js来验证银行账户,但是我应该使用Stripe API。由于我使用的是C# MVC,因此我需要将客户提供给我的控制器的小额付款金额通过,并按照文档https://github.com/stripe/stripe-dotnet致电Stripe.netBankAccountServiceVerfiy方法。